Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 2 | /* |
Vivien Didelot | 0d3cd4b | 2016-06-21 12:28:19 -0400 | [diff] [blame] | 3 | * Marvell 88e6xxx Ethernet switch single-chip support |
| 4 | * |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 5 | * Copyright (c) 2008 Marvell Semiconductor |
| 6 | * |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 7 | * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch> |
| 8 | * |
Vivien Didelot | 4333d61 | 2017-03-28 15:10:36 -0400 | [diff] [blame] | 9 | * Copyright (c) 2016-2017 Savoir-faire Linux Inc. |
| 10 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
Vivien Didelot | 19fb7f6 | 2019-08-09 18:47:55 -0400 | [diff] [blame] | 13 | #include <linux/bitfield.h> |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 14 | #include <linux/delay.h> |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 15 | #include <linux/etherdevice.h> |
Andrew Lunn | dea8702 | 2015-08-31 15:56:47 +0200 | [diff] [blame] | 16 | #include <linux/ethtool.h> |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 17 | #include <linux/if_bridge.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 18 | #include <linux/interrupt.h> |
| 19 | #include <linux/irq.h> |
| 20 | #include <linux/irqdomain.h> |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 21 | #include <linux/jiffies.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 22 | #include <linux/list.h> |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 23 | #include <linux/mdio.h> |
Paul Gortmaker | 2bbba27 | 2012-01-24 10:41:40 +0000 | [diff] [blame] | 24 | #include <linux/module.h> |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 25 | #include <linux/of_device.h> |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 26 | #include <linux/of_irq.h> |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 27 | #include <linux/of_mdio.h> |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 28 | #include <linux/platform_data/mv88e6xxx.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 29 | #include <linux/netdevice.h> |
Andrew Lunn | c8c1b39a | 2015-11-20 03:56:24 +0100 | [diff] [blame] | 30 | #include <linux/gpio/consumer.h> |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 31 | #include <linux/phylink.h> |
Ben Hutchings | c8f0b86 | 2011-11-27 17:06:08 +0000 | [diff] [blame] | 32 | #include <net/dsa.h> |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 33 | |
Vivien Didelot | 4d5f2ba7 | 2017-06-02 17:06:15 -0400 | [diff] [blame] | 34 | #include "chip.h" |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 35 | #include "global1.h" |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 36 | #include "global2.h" |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 37 | #include "hwtstamp.h" |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 38 | #include "phy.h" |
Vivien Didelot | 18abed2 | 2016-11-04 03:23:26 +0100 | [diff] [blame] | 39 | #include "port.h" |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 40 | #include "ptp.h" |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 41 | #include "serdes.h" |
Vivien Didelot | e7ba0fa | 2019-05-03 19:28:22 -0400 | [diff] [blame] | 42 | #include "smi.h" |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 43 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 44 | static void assert_reg_lock(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 45 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 46 | if (unlikely(!mutex_is_locked(&chip->reg_lock))) { |
| 47 | dev_err(chip->dev, "Switch registers lock not held!\n"); |
Vivien Didelot | 3996a4f | 2015-10-30 18:56:45 -0400 | [diff] [blame] | 48 | dump_stack(); |
| 49 | } |
| 50 | } |
| 51 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 52 | 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] | 53 | { |
| 54 | int err; |
| 55 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 56 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 57 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 58 | err = mv88e6xxx_smi_read(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 59 | if (err) |
| 60 | return err; |
| 61 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 62 | 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] | 63 | addr, reg, *val); |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
Vivien Didelot | ec56127 | 2016-09-02 14:45:33 -0400 | [diff] [blame] | 68 | 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] | 69 | { |
| 70 | int err; |
| 71 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 72 | assert_reg_lock(chip); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 73 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 74 | err = mv88e6xxx_smi_write(chip, addr, reg, val); |
Vivien Didelot | 914b32f | 2016-06-20 13:14:11 -0400 | [diff] [blame] | 75 | if (err) |
| 76 | return err; |
| 77 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 78 | 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] | 79 | addr, reg, val); |
| 80 | |
| 81 | return 0; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Vivien Didelot | 683f224 | 2019-08-09 18:47:54 -0400 | [diff] [blame] | 84 | int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg, |
| 85 | u16 mask, u16 val) |
| 86 | { |
| 87 | u16 data; |
| 88 | int err; |
| 89 | int i; |
| 90 | |
| 91 | /* There's no bus specific operation to wait for a mask */ |
| 92 | for (i = 0; i < 16; i++) { |
| 93 | err = mv88e6xxx_read(chip, addr, reg, &data); |
| 94 | if (err) |
| 95 | return err; |
| 96 | |
| 97 | if ((data & mask) == val) |
| 98 | return 0; |
| 99 | |
| 100 | usleep_range(1000, 2000); |
| 101 | } |
| 102 | |
| 103 | dev_err(chip->dev, "Timeout while waiting for switch\n"); |
| 104 | return -ETIMEDOUT; |
| 105 | } |
| 106 | |
Vivien Didelot | 19fb7f6 | 2019-08-09 18:47:55 -0400 | [diff] [blame] | 107 | int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg, |
| 108 | int bit, int val) |
| 109 | { |
| 110 | return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit), |
| 111 | val ? BIT(bit) : 0x0000); |
| 112 | } |
| 113 | |
Andrew Lunn | 10fa5bf | 2017-05-26 01:03:20 +0200 | [diff] [blame] | 114 | struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip) |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 115 | { |
| 116 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 117 | |
| 118 | mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus, |
| 119 | list); |
| 120 | if (!mdio_bus) |
| 121 | return NULL; |
| 122 | |
| 123 | return mdio_bus->bus; |
| 124 | } |
| 125 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 126 | static void mv88e6xxx_g1_irq_mask(struct irq_data *d) |
| 127 | { |
| 128 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 129 | unsigned int n = d->hwirq; |
| 130 | |
| 131 | chip->g1_irq.masked |= (1 << n); |
| 132 | } |
| 133 | |
| 134 | static void mv88e6xxx_g1_irq_unmask(struct irq_data *d) |
| 135 | { |
| 136 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 137 | unsigned int n = d->hwirq; |
| 138 | |
| 139 | chip->g1_irq.masked &= ~(1 << n); |
| 140 | } |
| 141 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 142 | static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 143 | { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 144 | unsigned int nhandled = 0; |
| 145 | unsigned int sub_irq; |
| 146 | unsigned int n; |
| 147 | u16 reg; |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 148 | u16 ctl1; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 149 | int err; |
| 150 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 151 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 152 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 153 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 154 | |
| 155 | if (err) |
| 156 | goto out; |
| 157 | |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 158 | do { |
| 159 | for (n = 0; n < chip->g1_irq.nirqs; ++n) { |
| 160 | if (reg & (1 << n)) { |
| 161 | sub_irq = irq_find_mapping(chip->g1_irq.domain, |
| 162 | n); |
| 163 | handle_nested_irq(sub_irq); |
| 164 | ++nhandled; |
| 165 | } |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 166 | } |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 167 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 168 | mv88e6xxx_reg_lock(chip); |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 169 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1); |
| 170 | if (err) |
| 171 | goto unlock; |
| 172 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
| 173 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 174 | mv88e6xxx_reg_unlock(chip); |
John David Anglin | 7c0db24 | 2019-02-11 13:40:21 -0500 | [diff] [blame] | 175 | if (err) |
| 176 | goto out; |
| 177 | ctl1 &= GENMASK(chip->g1_irq.nirqs, 0); |
| 178 | } while (reg & ctl1); |
| 179 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 180 | out: |
| 181 | return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE); |
| 182 | } |
| 183 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 184 | static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id) |
| 185 | { |
| 186 | struct mv88e6xxx_chip *chip = dev_id; |
| 187 | |
| 188 | return mv88e6xxx_g1_irq_thread_work(chip); |
| 189 | } |
| 190 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 191 | static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d) |
| 192 | { |
| 193 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 194 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 195 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d) |
| 199 | { |
| 200 | struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d); |
| 201 | u16 mask = GENMASK(chip->g1_irq.nirqs, 0); |
| 202 | u16 reg; |
| 203 | int err; |
| 204 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 205 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 206 | if (err) |
| 207 | goto out; |
| 208 | |
| 209 | reg &= ~mask; |
| 210 | reg |= (~chip->g1_irq.masked & mask); |
| 211 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 212 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 213 | if (err) |
| 214 | goto out; |
| 215 | |
| 216 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 217 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 218 | } |
| 219 | |
Bhumika Goyal | 6eb15e2 | 2017-08-19 16:25:52 +0530 | [diff] [blame] | 220 | static const struct irq_chip mv88e6xxx_g1_irq_chip = { |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 221 | .name = "mv88e6xxx-g1", |
| 222 | .irq_mask = mv88e6xxx_g1_irq_mask, |
| 223 | .irq_unmask = mv88e6xxx_g1_irq_unmask, |
| 224 | .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock, |
| 225 | .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock, |
| 226 | }; |
| 227 | |
| 228 | static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d, |
| 229 | unsigned int irq, |
| 230 | irq_hw_number_t hwirq) |
| 231 | { |
| 232 | struct mv88e6xxx_chip *chip = d->host_data; |
| 233 | |
| 234 | irq_set_chip_data(irq, d->host_data); |
| 235 | irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq); |
| 236 | irq_set_noprobe(irq); |
| 237 | |
| 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = { |
| 242 | .map = mv88e6xxx_g1_irq_domain_map, |
| 243 | .xlate = irq_domain_xlate_twocell, |
| 244 | }; |
| 245 | |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 246 | /* To be called with reg_lock held */ |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 247 | static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 248 | { |
| 249 | int irq, virq; |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 250 | u16 mask; |
| 251 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 252 | mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 253 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 254 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3460a57 | 2016-11-20 20:14:16 +0100 | [diff] [blame] | 255 | |
Andreas Färber | 5edef2f | 2016-11-27 23:26:28 +0100 | [diff] [blame] | 256 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) { |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 257 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 258 | irq_dispose_mapping(virq); |
| 259 | } |
| 260 | |
Andrew Lunn | a3db3d3 | 2016-11-20 20:14:14 +0100 | [diff] [blame] | 261 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 262 | } |
| 263 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 264 | static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip) |
| 265 | { |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 266 | /* |
| 267 | * free_irq must be called without reg_lock taken because the irq |
| 268 | * handler takes this lock, too. |
| 269 | */ |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 270 | free_irq(chip->irq, chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 271 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 272 | mv88e6xxx_reg_lock(chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 273 | mv88e6xxx_g1_irq_free_common(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 274 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 278 | { |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 279 | int err, irq, virq; |
| 280 | u16 reg, mask; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 281 | |
| 282 | chip->g1_irq.nirqs = chip->info->g1_irqs; |
| 283 | chip->g1_irq.domain = irq_domain_add_simple( |
| 284 | NULL, chip->g1_irq.nirqs, 0, |
| 285 | &mv88e6xxx_g1_irq_domain_ops, chip); |
| 286 | if (!chip->g1_irq.domain) |
| 287 | return -ENOMEM; |
| 288 | |
| 289 | for (irq = 0; irq < chip->g1_irq.nirqs; irq++) |
| 290 | irq_create_mapping(chip->g1_irq.domain, irq); |
| 291 | |
| 292 | chip->g1_irq.chip = mv88e6xxx_g1_irq_chip; |
| 293 | chip->g1_irq.masked = ~0; |
| 294 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 295 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 296 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 297 | goto out_mapping; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 298 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 299 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 300 | |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 301 | err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 302 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 303 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 304 | |
| 305 | /* Reading the interrupt status clears (most of) them */ |
Vivien Didelot | 8246692 | 2017-06-15 12:13:59 -0400 | [diff] [blame] | 306 | err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 307 | if (err) |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 308 | goto out_disable; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 309 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 310 | return 0; |
| 311 | |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 312 | out_disable: |
Andrew Lunn | 3d5fdba | 2017-12-07 01:05:56 +0100 | [diff] [blame] | 313 | mask &= ~GENMASK(chip->g1_irq.nirqs, 0); |
Vivien Didelot | d77f432 | 2017-06-15 12:14:03 -0400 | [diff] [blame] | 314 | mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask); |
Andrew Lunn | 3dd0ef0 | 2016-11-20 20:14:17 +0100 | [diff] [blame] | 315 | |
| 316 | out_mapping: |
| 317 | for (irq = 0; irq < 16; irq++) { |
| 318 | virq = irq_find_mapping(chip->g1_irq.domain, irq); |
| 319 | irq_dispose_mapping(virq); |
| 320 | } |
| 321 | |
| 322 | irq_domain_remove(chip->g1_irq.domain); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 323 | |
| 324 | return err; |
| 325 | } |
| 326 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 327 | static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip) |
| 328 | { |
Andrew Lunn | f6d9758 | 2019-02-23 17:43:56 +0100 | [diff] [blame] | 329 | static struct lock_class_key lock_key; |
| 330 | static struct lock_class_key request_key; |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 331 | int err; |
| 332 | |
| 333 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 334 | if (err) |
| 335 | return err; |
| 336 | |
Andrew Lunn | f6d9758 | 2019-02-23 17:43:56 +0100 | [diff] [blame] | 337 | /* These lock classes tells lockdep that global 1 irqs are in |
| 338 | * a different category than their parent GPIO, so it won't |
| 339 | * report false recursion. |
| 340 | */ |
| 341 | irq_set_lockdep_class(chip->irq, &lock_key, &request_key); |
| 342 | |
Andrew Lunn | 3095383 | 2020-01-06 17:13:48 +0100 | [diff] [blame] | 343 | snprintf(chip->irq_name, sizeof(chip->irq_name), |
| 344 | "mv88e6xxx-%s", dev_name(chip->dev)); |
| 345 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 346 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 347 | err = request_threaded_irq(chip->irq, NULL, |
| 348 | mv88e6xxx_g1_irq_thread_fn, |
Marek Behún | 0340376 | 2018-08-30 02:13:50 +0200 | [diff] [blame] | 349 | IRQF_ONESHOT | IRQF_SHARED, |
Andrew Lunn | 3095383 | 2020-01-06 17:13:48 +0100 | [diff] [blame] | 350 | chip->irq_name, chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 351 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 352 | if (err) |
| 353 | mv88e6xxx_g1_irq_free_common(chip); |
| 354 | |
| 355 | return err; |
| 356 | } |
| 357 | |
| 358 | static void mv88e6xxx_irq_poll(struct kthread_work *work) |
| 359 | { |
| 360 | struct mv88e6xxx_chip *chip = container_of(work, |
| 361 | struct mv88e6xxx_chip, |
| 362 | irq_poll_work.work); |
| 363 | mv88e6xxx_g1_irq_thread_work(chip); |
| 364 | |
| 365 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 366 | msecs_to_jiffies(100)); |
| 367 | } |
| 368 | |
| 369 | static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip) |
| 370 | { |
| 371 | int err; |
| 372 | |
| 373 | err = mv88e6xxx_g1_irq_setup_common(chip); |
| 374 | if (err) |
| 375 | return err; |
| 376 | |
| 377 | kthread_init_delayed_work(&chip->irq_poll_work, |
| 378 | mv88e6xxx_irq_poll); |
| 379 | |
Florian Fainelli | 3f8b869 | 2019-02-21 20:09:27 -0800 | [diff] [blame] | 380 | chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev)); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 381 | if (IS_ERR(chip->kworker)) |
| 382 | return PTR_ERR(chip->kworker); |
| 383 | |
| 384 | kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work, |
| 385 | msecs_to_jiffies(100)); |
| 386 | |
| 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip) |
| 391 | { |
| 392 | kthread_cancel_delayed_work_sync(&chip->irq_poll_work); |
| 393 | kthread_destroy_worker(chip->kworker); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 394 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 395 | mv88e6xxx_reg_lock(chip); |
Uwe Kleine-König | 3d82475 | 2018-07-20 11:53:15 +0200 | [diff] [blame] | 396 | mv88e6xxx_g1_irq_free_common(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 397 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 398 | } |
| 399 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame^] | 400 | static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip, |
| 401 | int port, phy_interface_t interface) |
| 402 | { |
| 403 | int err; |
| 404 | |
| 405 | if (chip->info->ops->port_set_rgmii_delay) { |
| 406 | err = chip->info->ops->port_set_rgmii_delay(chip, port, |
| 407 | interface); |
| 408 | if (err && err != -EOPNOTSUPP) |
| 409 | return err; |
| 410 | } |
| 411 | |
| 412 | if (chip->info->ops->port_set_cmode) { |
| 413 | err = chip->info->ops->port_set_cmode(chip, port, |
| 414 | interface); |
| 415 | if (err && err != -EOPNOTSUPP) |
| 416 | return err; |
| 417 | } |
| 418 | |
| 419 | return 0; |
| 420 | } |
| 421 | |
Heiner Kallweit | 72d8b4f | 2019-03-01 20:41:00 +0100 | [diff] [blame] | 422 | int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link, |
| 423 | int speed, int duplex, int pause, |
| 424 | phy_interface_t mode) |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 425 | { |
Andrew Lunn | a26deec | 2019-04-18 03:11:39 +0200 | [diff] [blame] | 426 | struct phylink_link_state state; |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 427 | int err; |
| 428 | |
| 429 | if (!chip->info->ops->port_set_link) |
| 430 | return 0; |
| 431 | |
Andrew Lunn | a26deec | 2019-04-18 03:11:39 +0200 | [diff] [blame] | 432 | if (!chip->info->ops->port_link_state) |
| 433 | return 0; |
| 434 | |
| 435 | err = chip->info->ops->port_link_state(chip, port, &state); |
| 436 | if (err) |
| 437 | return err; |
| 438 | |
| 439 | /* Has anything actually changed? We don't expect the |
| 440 | * interface mode to change without one of the other |
| 441 | * parameters also changing |
| 442 | */ |
| 443 | if (state.link == link && |
| 444 | state.speed == speed && |
Marek Behún | 927441a | 2019-08-14 16:40:24 +0200 | [diff] [blame] | 445 | state.duplex == duplex && |
| 446 | (state.interface == mode || |
| 447 | state.interface == PHY_INTERFACE_MODE_NA)) |
Andrew Lunn | a26deec | 2019-04-18 03:11:39 +0200 | [diff] [blame] | 448 | return 0; |
| 449 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 450 | /* 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] | 451 | err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 452 | if (err) |
| 453 | return err; |
| 454 | |
| 455 | if (chip->info->ops->port_set_speed) { |
| 456 | err = chip->info->ops->port_set_speed(chip, port, speed); |
| 457 | if (err && err != -EOPNOTSUPP) |
| 458 | goto restore_link; |
| 459 | } |
| 460 | |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 461 | if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode) |
| 462 | mode = chip->info->ops->port_max_speed_mode(port); |
| 463 | |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 464 | if (chip->info->ops->port_set_pause) { |
| 465 | err = chip->info->ops->port_set_pause(chip, port, pause); |
| 466 | if (err) |
| 467 | goto restore_link; |
| 468 | } |
| 469 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 470 | if (chip->info->ops->port_set_duplex) { |
| 471 | err = chip->info->ops->port_set_duplex(chip, port, duplex); |
| 472 | if (err && err != -EOPNOTSUPP) |
| 473 | goto restore_link; |
| 474 | } |
| 475 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame^] | 476 | err = mv88e6xxx_port_config_interface(chip, port, mode); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 477 | restore_link: |
| 478 | if (chip->info->ops->port_set_link(chip, port, link)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 479 | 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] | 480 | |
| 481 | return err; |
| 482 | } |
| 483 | |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 484 | static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port) |
| 485 | { |
| 486 | struct mv88e6xxx_chip *chip = ds->priv; |
| 487 | |
| 488 | return port < chip->info->num_internal_phys; |
| 489 | } |
| 490 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 491 | static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 492 | unsigned long *mask, |
| 493 | struct phylink_link_state *state) |
| 494 | { |
| 495 | if (!phy_interface_mode_is_8023z(state->interface)) { |
| 496 | /* 10M and 100M are only supported in non-802.3z mode */ |
| 497 | phylink_set(mask, 10baseT_Half); |
| 498 | phylink_set(mask, 10baseT_Full); |
| 499 | phylink_set(mask, 100baseT_Half); |
| 500 | phylink_set(mask, 100baseT_Full); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 505 | unsigned long *mask, |
| 506 | struct phylink_link_state *state) |
| 507 | { |
| 508 | /* FIXME: if the port is in 1000Base-X mode, then it only supports |
| 509 | * 1000M FD speeds. In this case, CMODE will indicate 5. |
| 510 | */ |
| 511 | phylink_set(mask, 1000baseT_Full); |
| 512 | phylink_set(mask, 1000baseX_Full); |
| 513 | |
| 514 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 515 | } |
| 516 | |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 517 | static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 518 | unsigned long *mask, |
| 519 | struct phylink_link_state *state) |
| 520 | { |
| 521 | if (port >= 5) |
| 522 | phylink_set(mask, 2500baseX_Full); |
| 523 | |
| 524 | /* No ethtool bits for 200Mbps */ |
| 525 | phylink_set(mask, 1000baseT_Full); |
| 526 | phylink_set(mask, 1000baseX_Full); |
| 527 | |
| 528 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 529 | } |
| 530 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 531 | static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 532 | unsigned long *mask, |
| 533 | struct phylink_link_state *state) |
| 534 | { |
| 535 | /* No ethtool bits for 200Mbps */ |
| 536 | phylink_set(mask, 1000baseT_Full); |
| 537 | phylink_set(mask, 1000baseX_Full); |
| 538 | |
| 539 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 540 | } |
| 541 | |
| 542 | static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 543 | unsigned long *mask, |
| 544 | struct phylink_link_state *state) |
| 545 | { |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 546 | if (port >= 9) { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 547 | phylink_set(mask, 2500baseX_Full); |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 548 | phylink_set(mask, 2500baseT_Full); |
| 549 | } |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 550 | |
| 551 | /* No ethtool bits for 200Mbps */ |
| 552 | phylink_set(mask, 1000baseT_Full); |
| 553 | phylink_set(mask, 1000baseX_Full); |
| 554 | |
| 555 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 556 | } |
| 557 | |
| 558 | static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 559 | unsigned long *mask, |
| 560 | struct phylink_link_state *state) |
| 561 | { |
| 562 | if (port >= 9) { |
| 563 | phylink_set(mask, 10000baseT_Full); |
| 564 | phylink_set(mask, 10000baseKR_Full); |
| 565 | } |
| 566 | |
| 567 | mv88e6390_phylink_validate(chip, port, mask, state); |
| 568 | } |
| 569 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 570 | static void mv88e6xxx_validate(struct dsa_switch *ds, int port, |
| 571 | unsigned long *supported, |
| 572 | struct phylink_link_state *state) |
| 573 | { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 574 | __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; |
| 575 | struct mv88e6xxx_chip *chip = ds->priv; |
| 576 | |
| 577 | /* Allow all the expected bits */ |
| 578 | phylink_set(mask, Autoneg); |
| 579 | phylink_set(mask, Pause); |
| 580 | phylink_set_port_modes(mask); |
| 581 | |
| 582 | if (chip->info->ops->phylink_validate) |
| 583 | chip->info->ops->phylink_validate(chip, port, mask, state); |
| 584 | |
| 585 | bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 586 | bitmap_and(state->advertising, state->advertising, mask, |
| 587 | __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 588 | |
| 589 | /* We can only operate at 2500BaseX or 1000BaseX. If requested |
| 590 | * to advertise both, only report advertising at 2500BaseX. |
| 591 | */ |
| 592 | phylink_helper_basex_speed(state); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | static int mv88e6xxx_link_state(struct dsa_switch *ds, int port, |
| 596 | struct phylink_link_state *state) |
| 597 | { |
| 598 | struct mv88e6xxx_chip *chip = ds->priv; |
| 599 | int err; |
| 600 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 601 | mv88e6xxx_reg_lock(chip); |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 602 | if (chip->info->ops->port_link_state) |
| 603 | err = chip->info->ops->port_link_state(chip, port, state); |
| 604 | else |
| 605 | err = -EOPNOTSUPP; |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 606 | mv88e6xxx_reg_unlock(chip); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 607 | |
| 608 | return err; |
| 609 | } |
| 610 | |
| 611 | static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, |
| 612 | unsigned int mode, |
| 613 | const struct phylink_link_state *state) |
| 614 | { |
| 615 | struct mv88e6xxx_chip *chip = ds->priv; |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame^] | 616 | int err; |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 617 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame^] | 618 | /* FIXME: is this the correct test? If we're in fixed mode on an |
| 619 | * internal port, why should we process this any different from |
| 620 | * PHY mode? On the other hand, the port may be automedia between |
| 621 | * an internal PHY and the serdes... |
| 622 | */ |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 623 | if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port)) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 624 | return; |
| 625 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 626 | mv88e6xxx_reg_lock(chip); |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame^] | 627 | /* FIXME: should we force the link down here - but if we do, how |
| 628 | * do we restore the link force/unforce state? The driver layering |
| 629 | * gets in the way. |
| 630 | */ |
| 631 | err = mv88e6xxx_port_config_interface(chip, port, state->interface); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 632 | mv88e6xxx_reg_unlock(chip); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 633 | |
| 634 | if (err && err != -EOPNOTSUPP) |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame^] | 635 | 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] | 636 | } |
| 637 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 638 | static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port, |
| 639 | unsigned int mode, |
| 640 | phy_interface_t interface) |
| 641 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 642 | struct mv88e6xxx_chip *chip = ds->priv; |
| 643 | const struct mv88e6xxx_ops *ops; |
| 644 | int err = 0; |
| 645 | |
| 646 | ops = chip->info->ops; |
| 647 | |
| 648 | /* Internal PHYs propagate their configuration directly to the MAC. |
| 649 | * External PHYs depend on whether the PPU is enabled for this port. |
| 650 | * FIXME: we should be using the PPU enable state here. What about |
| 651 | * an automedia port? |
| 652 | */ |
| 653 | if (!mv88e6xxx_phy_is_internal(ds, port) && ops->port_set_link) { |
| 654 | mv88e6xxx_reg_lock(chip); |
| 655 | err = ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
| 656 | mv88e6xxx_reg_unlock(chip); |
| 657 | |
| 658 | if (err) |
| 659 | dev_err(chip->dev, |
| 660 | "p%d: failed to force MAC link down\n", port); |
| 661 | } |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port, |
| 665 | unsigned int mode, phy_interface_t interface, |
Russell King | 5b502a7 | 2020-02-26 10:23:46 +0000 | [diff] [blame] | 666 | struct phy_device *phydev, |
| 667 | int speed, int duplex, |
| 668 | bool tx_pause, bool rx_pause) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 669 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 670 | struct mv88e6xxx_chip *chip = ds->priv; |
| 671 | const struct mv88e6xxx_ops *ops; |
| 672 | int err = 0; |
| 673 | |
| 674 | ops = chip->info->ops; |
| 675 | |
| 676 | /* Internal PHYs propagate their configuration directly to the MAC. |
| 677 | * External PHYs depend on whether the PPU is enabled for this port. |
| 678 | * FIXME: we should be using the PPU enable state here. What about |
| 679 | * an automedia port? |
| 680 | */ |
| 681 | if (!mv88e6xxx_phy_is_internal(ds, port)) { |
| 682 | mv88e6xxx_reg_lock(chip); |
| 683 | /* FIXME: for an automedia port, should we force the link |
| 684 | * down here - what if the link comes up due to "other" media |
| 685 | * while we're bringing the port up, how is the exclusivity |
| 686 | * handled in the Marvell hardware? E.g. port 4 on 88E6532 |
| 687 | * shared between internal PHY and Serdes. |
| 688 | */ |
| 689 | if (ops->port_set_speed) { |
| 690 | err = ops->port_set_speed(chip, port, speed); |
| 691 | if (err && err != -EOPNOTSUPP) |
| 692 | goto error; |
| 693 | } |
| 694 | |
| 695 | if (ops->port_set_duplex) { |
| 696 | err = ops->port_set_duplex(chip, port, duplex); |
| 697 | if (err && err != -EOPNOTSUPP) |
| 698 | goto error; |
| 699 | } |
| 700 | |
| 701 | if (ops->port_set_link) |
| 702 | err = ops->port_set_link(chip, port, LINK_FORCED_UP); |
| 703 | error: |
| 704 | mv88e6xxx_reg_unlock(chip); |
| 705 | |
| 706 | if (err && err != -EOPNOTSUPP) |
| 707 | dev_err(ds->dev, |
| 708 | "p%d: failed to configure MAC link up\n", port); |
| 709 | } |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 710 | } |
| 711 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 712 | static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 713 | { |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 714 | if (!chip->info->ops->stats_snapshot) |
| 715 | return -EOPNOTSUPP; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 716 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 717 | return chip->info->ops->stats_snapshot(chip, port); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 718 | } |
| 719 | |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 720 | static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 721 | { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, }, |
| 722 | { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, }, |
| 723 | { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, }, |
| 724 | { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, }, |
| 725 | { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, }, |
| 726 | { "in_pause", 4, 0x16, STATS_TYPE_BANK0, }, |
| 727 | { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, }, |
| 728 | { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, }, |
| 729 | { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, }, |
| 730 | { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, }, |
| 731 | { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, }, |
| 732 | { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, }, |
| 733 | { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, }, |
| 734 | { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, }, |
| 735 | { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, }, |
| 736 | { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, }, |
| 737 | { "out_pause", 4, 0x15, STATS_TYPE_BANK0, }, |
| 738 | { "excessive", 4, 0x11, STATS_TYPE_BANK0, }, |
| 739 | { "collisions", 4, 0x1e, STATS_TYPE_BANK0, }, |
| 740 | { "deferred", 4, 0x05, STATS_TYPE_BANK0, }, |
| 741 | { "single", 4, 0x14, STATS_TYPE_BANK0, }, |
| 742 | { "multiple", 4, 0x17, STATS_TYPE_BANK0, }, |
| 743 | { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, }, |
| 744 | { "late", 4, 0x1f, STATS_TYPE_BANK0, }, |
| 745 | { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, }, |
| 746 | { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, }, |
| 747 | { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, }, |
| 748 | { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, }, |
| 749 | { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, }, |
| 750 | { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, }, |
| 751 | { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, }, |
| 752 | { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, }, |
| 753 | { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, }, |
| 754 | { "in_discards", 4, 0x00, STATS_TYPE_BANK1, }, |
| 755 | { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, }, |
| 756 | { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, }, |
| 757 | { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, }, |
| 758 | { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, }, |
| 759 | { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, }, |
| 760 | { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, }, |
| 761 | { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, }, |
| 762 | { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, }, |
| 763 | { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, }, |
| 764 | { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, }, |
| 765 | { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, }, |
| 766 | { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, }, |
| 767 | { "in_management", 4, 0x0f, STATS_TYPE_BANK1, }, |
| 768 | { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, }, |
| 769 | { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, }, |
| 770 | { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, }, |
| 771 | { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, }, |
| 772 | { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, }, |
| 773 | { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, }, |
| 774 | { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, }, |
| 775 | { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, }, |
| 776 | { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, }, |
| 777 | { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, }, |
| 778 | { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, }, |
| 779 | { "out_management", 4, 0x1f, STATS_TYPE_BANK1, }, |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 780 | }; |
| 781 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 782 | static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip, |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 783 | struct mv88e6xxx_hw_stat *s, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 784 | int port, u16 bank1_select, |
| 785 | u16 histogram) |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 786 | { |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 787 | u32 low; |
| 788 | u32 high = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 789 | u16 reg = 0; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 790 | int err; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 791 | u64 value; |
| 792 | |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 793 | switch (s->type) { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 794 | case STATS_TYPE_PORT: |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 795 | err = mv88e6xxx_port_read(chip, port, s->reg, ®); |
| 796 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 797 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 798 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 799 | low = reg; |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 800 | if (s->size == 4) { |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 801 | err = mv88e6xxx_port_read(chip, port, s->reg + 1, ®); |
| 802 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 803 | return U64_MAX; |
Rasmus Villemoes | 84b3fd1 | 2019-05-29 07:02:11 +0000 | [diff] [blame] | 804 | low |= ((u32)reg) << 16; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 805 | } |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 806 | break; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 807 | case STATS_TYPE_BANK1: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 808 | reg = bank1_select; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 809 | /* fall through */ |
| 810 | case STATS_TYPE_BANK0: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 811 | reg |= s->reg | histogram; |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 812 | mv88e6xxx_g1_stats_read(chip, reg, &low); |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 813 | if (s->size == 8) |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 814 | mv88e6xxx_g1_stats_read(chip, reg + 1, &high); |
Gustavo A. R. Silva | 9fc3e4d | 2017-05-11 22:11:29 -0500 | [diff] [blame] | 815 | break; |
| 816 | default: |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 817 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 818 | } |
Andrew Lunn | 6e46e2d | 2019-02-28 18:14:03 +0100 | [diff] [blame] | 819 | value = (((u64)high) << 32) | low; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 820 | return value; |
| 821 | } |
| 822 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 823 | static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 824 | uint8_t *data, int types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 825 | { |
| 826 | struct mv88e6xxx_hw_stat *stat; |
| 827 | int i, j; |
| 828 | |
| 829 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 830 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 831 | if (stat->type & types) { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 832 | memcpy(data + j * ETH_GSTRING_LEN, stat->string, |
| 833 | ETH_GSTRING_LEN); |
| 834 | j++; |
| 835 | } |
| 836 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 837 | |
| 838 | return j; |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 839 | } |
| 840 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 841 | static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 842 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 843 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 844 | return mv88e6xxx_stats_get_strings(chip, data, |
| 845 | STATS_TYPE_BANK0 | STATS_TYPE_PORT); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 846 | } |
| 847 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 848 | static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 849 | uint8_t *data) |
| 850 | { |
| 851 | return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0); |
| 852 | } |
| 853 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 854 | static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 855 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 856 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 857 | return mv88e6xxx_stats_get_strings(chip, data, |
| 858 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 859 | } |
| 860 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 861 | static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = { |
| 862 | "atu_member_violation", |
| 863 | "atu_miss_violation", |
| 864 | "atu_full_violation", |
| 865 | "vtu_member_violation", |
| 866 | "vtu_miss_violation", |
| 867 | }; |
| 868 | |
| 869 | static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data) |
| 870 | { |
| 871 | unsigned int i; |
| 872 | |
| 873 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++) |
| 874 | strlcpy(data + i * ETH_GSTRING_LEN, |
| 875 | mv88e6xxx_atu_vtu_stats_strings[i], |
| 876 | ETH_GSTRING_LEN); |
| 877 | } |
| 878 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 879 | static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 880 | u32 stringset, uint8_t *data) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 881 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 882 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 883 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 884 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 885 | if (stringset != ETH_SS_STATS) |
| 886 | return; |
| 887 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 888 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 889 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 890 | if (chip->info->ops->stats_get_strings) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 891 | count = chip->info->ops->stats_get_strings(chip, data); |
| 892 | |
| 893 | if (chip->info->ops->serdes_get_strings) { |
| 894 | data += count * ETH_GSTRING_LEN; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 895 | count = chip->info->ops->serdes_get_strings(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 896 | } |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 897 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 898 | data += count * ETH_GSTRING_LEN; |
| 899 | mv88e6xxx_atu_vtu_get_strings(data); |
| 900 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 901 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 902 | } |
| 903 | |
| 904 | static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip, |
| 905 | int types) |
| 906 | { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 907 | struct mv88e6xxx_hw_stat *stat; |
| 908 | int i, j; |
| 909 | |
| 910 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 911 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 912 | if (stat->type & types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 913 | j++; |
| 914 | } |
| 915 | return j; |
| 916 | } |
| 917 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 918 | static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 919 | { |
| 920 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 921 | STATS_TYPE_PORT); |
| 922 | } |
| 923 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 924 | static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 925 | { |
| 926 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0); |
| 927 | } |
| 928 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 929 | static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 930 | { |
| 931 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 932 | STATS_TYPE_BANK1); |
| 933 | } |
| 934 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 935 | 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] | 936 | { |
| 937 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 938 | int serdes_count = 0; |
| 939 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 940 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 941 | if (sset != ETH_SS_STATS) |
| 942 | return 0; |
| 943 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 944 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 945 | if (chip->info->ops->stats_get_sset_count) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 946 | count = chip->info->ops->stats_get_sset_count(chip); |
| 947 | if (count < 0) |
| 948 | goto out; |
| 949 | |
| 950 | if (chip->info->ops->serdes_get_sset_count) |
| 951 | serdes_count = chip->info->ops->serdes_get_sset_count(chip, |
| 952 | port); |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 953 | if (serdes_count < 0) { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 954 | count = serdes_count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 955 | goto out; |
| 956 | } |
| 957 | count += serdes_count; |
| 958 | count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); |
| 959 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 960 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 961 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 962 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 963 | return count; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 964 | } |
| 965 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 966 | static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 967 | uint64_t *data, int types, |
| 968 | u16 bank1_select, u16 histogram) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 969 | { |
| 970 | struct mv88e6xxx_hw_stat *stat; |
| 971 | int i, j; |
| 972 | |
| 973 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 974 | stat = &mv88e6xxx_hw_stats[i]; |
| 975 | if (stat->type & types) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 976 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 977 | data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, |
| 978 | bank1_select, |
| 979 | histogram); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 980 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 981 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 982 | j++; |
| 983 | } |
| 984 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 985 | return j; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 986 | } |
| 987 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 988 | static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 989 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 990 | { |
| 991 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 992 | STATS_TYPE_BANK0 | STATS_TYPE_PORT, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 993 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 994 | } |
| 995 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 996 | static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 997 | uint64_t *data) |
| 998 | { |
| 999 | return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0, |
| 1000 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
| 1001 | } |
| 1002 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1003 | static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1004 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1005 | { |
| 1006 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1007 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1008 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9, |
| 1009 | MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1010 | } |
| 1011 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1012 | static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1013 | uint64_t *data) |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1014 | { |
| 1015 | return mv88e6xxx_stats_get_stats(chip, port, data, |
| 1016 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1017 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10, |
| 1018 | 0); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1019 | } |
| 1020 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1021 | static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1022 | uint64_t *data) |
| 1023 | { |
| 1024 | *data++ = chip->ports[port].atu_member_violation; |
| 1025 | *data++ = chip->ports[port].atu_miss_violation; |
| 1026 | *data++ = chip->ports[port].atu_full_violation; |
| 1027 | *data++ = chip->ports[port].vtu_member_violation; |
| 1028 | *data++ = chip->ports[port].vtu_miss_violation; |
| 1029 | } |
| 1030 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1031 | static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1032 | uint64_t *data) |
| 1033 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1034 | int count = 0; |
| 1035 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1036 | if (chip->info->ops->stats_get_stats) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1037 | count = chip->info->ops->stats_get_stats(chip, port, data); |
| 1038 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1039 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1040 | if (chip->info->ops->serdes_get_stats) { |
| 1041 | data += count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1042 | count = chip->info->ops->serdes_get_stats(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1043 | } |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1044 | data += count; |
| 1045 | mv88e6xxx_atu_vtu_get_stats(chip, port, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1046 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1047 | } |
| 1048 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1049 | static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, |
| 1050 | uint64_t *data) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1051 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1052 | struct mv88e6xxx_chip *chip = ds->priv; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1053 | int ret; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1054 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1055 | mv88e6xxx_reg_lock(chip); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1056 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 1057 | ret = mv88e6xxx_stats_snapshot(chip, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1058 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1059 | |
| 1060 | if (ret < 0) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1061 | return; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1062 | |
| 1063 | mv88e6xxx_get_stats(chip, port, data); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1064 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1065 | } |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 1066 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1067 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1068 | { |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1069 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1070 | int len; |
| 1071 | |
| 1072 | len = 32 * sizeof(u16); |
| 1073 | if (chip->info->ops->serdes_get_regs_len) |
| 1074 | len += chip->info->ops->serdes_get_regs_len(chip, port); |
| 1075 | |
| 1076 | return len; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1077 | } |
| 1078 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1079 | static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, |
| 1080 | struct ethtool_regs *regs, void *_p) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1081 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1082 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1083 | int err; |
| 1084 | u16 reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1085 | u16 *p = _p; |
| 1086 | int i; |
| 1087 | |
Vivien Didelot | a5f3932 | 2018-12-17 16:05:21 -0500 | [diff] [blame] | 1088 | regs->version = chip->info->prod_num; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1089 | |
| 1090 | memset(p, 0xff, 32 * sizeof(u16)); |
| 1091 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1092 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1093 | |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1094 | for (i = 0; i < 32; i++) { |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1095 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1096 | err = mv88e6xxx_port_read(chip, port, i, ®); |
| 1097 | if (!err) |
| 1098 | p[i] = reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1099 | } |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1100 | |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1101 | if (chip->info->ops->serdes_get_regs) |
| 1102 | chip->info->ops->serdes_get_regs(chip, port, &p[i]); |
| 1103 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1104 | mv88e6xxx_reg_unlock(chip); |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1105 | } |
| 1106 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1107 | static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port, |
| 1108 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1109 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1110 | /* Nothing to do on the port's MAC */ |
| 1111 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1112 | } |
| 1113 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1114 | static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port, |
| 1115 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1116 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1117 | /* Nothing to do on the port's MAC */ |
| 1118 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1119 | } |
| 1120 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1121 | /* 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] | 1122 | 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] | 1123 | { |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1124 | struct dsa_switch *ds = chip->ds; |
| 1125 | struct dsa_switch_tree *dst = ds->dst; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1126 | struct net_device *br; |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1127 | struct dsa_port *dp; |
| 1128 | bool found = false; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1129 | u16 pvlan; |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1130 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1131 | list_for_each_entry(dp, &dst->ports, list) { |
| 1132 | if (dp->ds->index == dev && dp->index == port) { |
| 1133 | found = true; |
| 1134 | break; |
| 1135 | } |
| 1136 | } |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1137 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1138 | /* Prevent frames from unknown switch or port */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1139 | if (!found) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1140 | return 0; |
| 1141 | |
| 1142 | /* Frames from DSA links and CPU ports can egress any local port */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1143 | 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] | 1144 | return mv88e6xxx_port_mask(chip); |
| 1145 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1146 | br = dp->bridge_dev; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1147 | pvlan = 0; |
| 1148 | |
| 1149 | /* Frames from user ports can egress any local DSA links and CPU ports, |
| 1150 | * as well as any local member of their bridge group. |
| 1151 | */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1152 | list_for_each_entry(dp, &dst->ports, list) |
| 1153 | if (dp->ds == ds && |
| 1154 | (dp->type == DSA_PORT_TYPE_CPU || |
| 1155 | dp->type == DSA_PORT_TYPE_DSA || |
| 1156 | (br && dp->bridge_dev == br))) |
| 1157 | pvlan |= BIT(dp->index); |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1158 | |
| 1159 | return pvlan; |
| 1160 | } |
| 1161 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1162 | static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1163 | { |
| 1164 | u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port); |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1165 | |
| 1166 | /* prevent frames from going back out of the port they came in on */ |
| 1167 | output_ports &= ~BIT(port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1168 | |
Vivien Didelot | 5a7921f | 2016-11-04 03:23:28 +0100 | [diff] [blame] | 1169 | return mv88e6xxx_port_set_vlan_map(chip, port, output_ports); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1170 | } |
| 1171 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1172 | static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, |
| 1173 | u8 state) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1174 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1175 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1176 | int err; |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1177 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1178 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 1179 | err = mv88e6xxx_port_set_state(chip, port, state); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1180 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1181 | |
| 1182 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1183 | dev_err(ds->dev, "p%d: failed to update state\n", port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 1186 | static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip) |
| 1187 | { |
| 1188 | int err; |
| 1189 | |
| 1190 | if (chip->info->ops->ieee_pri_map) { |
| 1191 | err = chip->info->ops->ieee_pri_map(chip); |
| 1192 | if (err) |
| 1193 | return err; |
| 1194 | } |
| 1195 | |
| 1196 | if (chip->info->ops->ip_pri_map) { |
| 1197 | err = chip->info->ops->ip_pri_map(chip); |
| 1198 | if (err) |
| 1199 | return err; |
| 1200 | } |
| 1201 | |
| 1202 | return 0; |
| 1203 | } |
| 1204 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1205 | static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip) |
| 1206 | { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1207 | struct dsa_switch *ds = chip->ds; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1208 | int target, port; |
| 1209 | int err; |
| 1210 | |
| 1211 | if (!chip->info->global2_addr) |
| 1212 | return 0; |
| 1213 | |
| 1214 | /* Initialize the routing port to the 32 possible target devices */ |
| 1215 | for (target = 0; target < 32; target++) { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1216 | port = dsa_routing_port(ds, target); |
| 1217 | if (port == ds->num_ports) |
| 1218 | port = 0x1f; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1219 | |
| 1220 | err = mv88e6xxx_g2_device_mapping_write(chip, target, port); |
| 1221 | if (err) |
| 1222 | return err; |
| 1223 | } |
| 1224 | |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 1225 | if (chip->info->ops->set_cascade_port) { |
| 1226 | port = MV88E6XXX_CASCADE_PORT_MULTIPLE; |
| 1227 | err = chip->info->ops->set_cascade_port(chip, port); |
| 1228 | if (err) |
| 1229 | return err; |
| 1230 | } |
| 1231 | |
Vivien Didelot | 23c9891 | 2018-05-09 11:38:50 -0400 | [diff] [blame] | 1232 | err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index); |
| 1233 | if (err) |
| 1234 | return err; |
| 1235 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1236 | return 0; |
| 1237 | } |
| 1238 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 1239 | static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip) |
| 1240 | { |
| 1241 | /* Clear all trunk masks and mapping */ |
| 1242 | if (chip->info->global2_addr) |
| 1243 | return mv88e6xxx_g2_trunk_clear(chip); |
| 1244 | |
| 1245 | return 0; |
| 1246 | } |
| 1247 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 1248 | static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip) |
| 1249 | { |
| 1250 | if (chip->info->ops->rmu_disable) |
| 1251 | return chip->info->ops->rmu_disable(chip); |
| 1252 | |
| 1253 | return 0; |
| 1254 | } |
| 1255 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 1256 | static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip) |
| 1257 | { |
| 1258 | if (chip->info->ops->pot_clear) |
| 1259 | return chip->info->ops->pot_clear(chip); |
| 1260 | |
| 1261 | return 0; |
| 1262 | } |
| 1263 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 1264 | static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip) |
| 1265 | { |
| 1266 | if (chip->info->ops->mgmt_rsvd2cpu) |
| 1267 | return chip->info->ops->mgmt_rsvd2cpu(chip); |
| 1268 | |
| 1269 | return 0; |
| 1270 | } |
| 1271 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1272 | static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip) |
| 1273 | { |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1274 | int err; |
| 1275 | |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1276 | err = mv88e6xxx_g1_atu_flush(chip, 0, true); |
| 1277 | if (err) |
| 1278 | return err; |
| 1279 | |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1280 | err = mv88e6xxx_g1_atu_set_learn2all(chip, true); |
| 1281 | if (err) |
| 1282 | return err; |
| 1283 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1284 | return mv88e6xxx_g1_atu_set_age_time(chip, 300000); |
| 1285 | } |
| 1286 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 1287 | static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip) |
| 1288 | { |
| 1289 | int port; |
| 1290 | int err; |
| 1291 | |
| 1292 | if (!chip->info->ops->irl_init_all) |
| 1293 | return 0; |
| 1294 | |
| 1295 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1296 | /* Disable ingress rate limiting by resetting all per port |
| 1297 | * ingress rate limit resources to their initial state. |
| 1298 | */ |
| 1299 | err = chip->info->ops->irl_init_all(chip, port); |
| 1300 | if (err) |
| 1301 | return err; |
| 1302 | } |
| 1303 | |
| 1304 | return 0; |
| 1305 | } |
| 1306 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 1307 | static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip) |
| 1308 | { |
| 1309 | if (chip->info->ops->set_switch_mac) { |
| 1310 | u8 addr[ETH_ALEN]; |
| 1311 | |
| 1312 | eth_random_addr(addr); |
| 1313 | |
| 1314 | return chip->info->ops->set_switch_mac(chip, addr); |
| 1315 | } |
| 1316 | |
| 1317 | return 0; |
| 1318 | } |
| 1319 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1320 | static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port) |
| 1321 | { |
| 1322 | u16 pvlan = 0; |
| 1323 | |
| 1324 | if (!mv88e6xxx_has_pvt(chip)) |
Vivien Didelot | d14939b | 2019-10-21 16:51:25 -0400 | [diff] [blame] | 1325 | return 0; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1326 | |
| 1327 | /* Skip the local source device, which uses in-chip port VLAN */ |
| 1328 | if (dev != chip->ds->index) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 1329 | pvlan = mv88e6xxx_port_vlan(chip, dev, port); |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1330 | |
| 1331 | return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan); |
| 1332 | } |
| 1333 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1334 | static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip) |
| 1335 | { |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1336 | int dev, port; |
| 1337 | int err; |
| 1338 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1339 | if (!mv88e6xxx_has_pvt(chip)) |
| 1340 | return 0; |
| 1341 | |
| 1342 | /* Clear 5 Bit Port for usage with Marvell Link Street devices: |
| 1343 | * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev. |
| 1344 | */ |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1345 | err = mv88e6xxx_g2_misc_4_bit_port(chip); |
| 1346 | if (err) |
| 1347 | return err; |
| 1348 | |
| 1349 | for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) { |
| 1350 | for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) { |
| 1351 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1352 | if (err) |
| 1353 | return err; |
| 1354 | } |
| 1355 | } |
| 1356 | |
| 1357 | return 0; |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1358 | } |
| 1359 | |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1360 | static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port) |
| 1361 | { |
| 1362 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1363 | int err; |
| 1364 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1365 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1366 | err = mv88e6xxx_g1_atu_remove(chip, 0, port, false); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1367 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1368 | |
| 1369 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1370 | dev_err(ds->dev, "p%d: failed to flush ATU\n", port); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1371 | } |
| 1372 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1373 | static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip) |
| 1374 | { |
| 1375 | if (!chip->info->max_vid) |
| 1376 | return 0; |
| 1377 | |
| 1378 | return mv88e6xxx_g1_vtu_flush(chip); |
| 1379 | } |
| 1380 | |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1381 | static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip, |
| 1382 | struct mv88e6xxx_vtu_entry *entry) |
| 1383 | { |
| 1384 | if (!chip->info->ops->vtu_getnext) |
| 1385 | return -EOPNOTSUPP; |
| 1386 | |
| 1387 | return chip->info->ops->vtu_getnext(chip, entry); |
| 1388 | } |
| 1389 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1390 | static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, |
| 1391 | struct mv88e6xxx_vtu_entry *entry) |
| 1392 | { |
| 1393 | if (!chip->info->ops->vtu_loadpurge) |
| 1394 | return -EOPNOTSUPP; |
| 1395 | |
| 1396 | return chip->info->ops->vtu_loadpurge(chip, entry); |
| 1397 | } |
| 1398 | |
Vivien Didelot | d7f435f | 2017-03-11 16:12:56 -0500 | [diff] [blame] | 1399 | static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1400 | { |
| 1401 | DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1402 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1403 | int i, err; |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1404 | |
| 1405 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); |
| 1406 | |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1407 | /* Set every FID bit used by the (un)bridged ports */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1408 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 1409 | err = mv88e6xxx_port_get_fid(chip, i, fid); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1410 | if (err) |
| 1411 | return err; |
| 1412 | |
| 1413 | set_bit(*fid, fid_bitmap); |
| 1414 | } |
| 1415 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1416 | /* Set every FID bit used by the VLAN entries */ |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1417 | vlan.vid = chip->info->max_vid; |
| 1418 | vlan.valid = false; |
| 1419 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1420 | do { |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1421 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1422 | if (err) |
| 1423 | return err; |
| 1424 | |
| 1425 | if (!vlan.valid) |
| 1426 | break; |
| 1427 | |
| 1428 | set_bit(vlan.fid, fid_bitmap); |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1429 | } while (vlan.vid < chip->info->max_vid); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1430 | |
| 1431 | /* The reset value 0x000 is used to indicate that multiple address |
| 1432 | * databases are not needed. Return the next positive available. |
| 1433 | */ |
| 1434 | *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1435 | if (unlikely(*fid >= mv88e6xxx_num_databases(chip))) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1436 | return -ENOSPC; |
| 1437 | |
| 1438 | /* Clear the database */ |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1439 | return mv88e6xxx_g1_atu_flush(chip, *fid, true); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1440 | } |
| 1441 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 1442 | static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash) |
| 1443 | { |
| 1444 | if (chip->info->ops->atu_get_hash) |
| 1445 | return chip->info->ops->atu_get_hash(chip, hash); |
| 1446 | |
| 1447 | return -EOPNOTSUPP; |
| 1448 | } |
| 1449 | |
| 1450 | static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash) |
| 1451 | { |
| 1452 | if (chip->info->ops->atu_set_hash) |
| 1453 | return chip->info->ops->atu_set_hash(chip, hash); |
| 1454 | |
| 1455 | return -EOPNOTSUPP; |
| 1456 | } |
| 1457 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1458 | static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, |
| 1459 | u16 vid_begin, u16 vid_end) |
| 1460 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1461 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1462 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1463 | int i, err; |
| 1464 | |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1465 | /* DSA and CPU ports have to be members of multiple vlans */ |
| 1466 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
| 1467 | return 0; |
| 1468 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1469 | if (!vid_begin) |
| 1470 | return -EOPNOTSUPP; |
| 1471 | |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1472 | vlan.vid = vid_begin - 1; |
| 1473 | vlan.valid = false; |
| 1474 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1475 | do { |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1476 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1477 | if (err) |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1478 | return err; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1479 | |
| 1480 | if (!vlan.valid) |
| 1481 | break; |
| 1482 | |
| 1483 | if (vlan.vid > vid_end) |
| 1484 | break; |
| 1485 | |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1486 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1487 | if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) |
| 1488 | continue; |
| 1489 | |
Vivien Didelot | 68bb8ea | 2019-10-21 16:51:15 -0400 | [diff] [blame] | 1490 | if (!dsa_to_port(ds, i)->slave) |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1491 | continue; |
| 1492 | |
Vivien Didelot | bd00e05 | 2017-05-01 14:05:11 -0400 | [diff] [blame] | 1493 | if (vlan.member[i] == |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1494 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1495 | continue; |
| 1496 | |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1497 | if (dsa_to_port(ds, i)->bridge_dev == |
Vivien Didelot | 68bb8ea | 2019-10-21 16:51:15 -0400 | [diff] [blame] | 1498 | dsa_to_port(ds, port)->bridge_dev) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1499 | break; /* same bridge, check next VLAN */ |
| 1500 | |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1501 | if (!dsa_to_port(ds, i)->bridge_dev) |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1502 | continue; |
| 1503 | |
Andrew Lunn | 743fcc2 | 2017-11-09 22:29:54 +0100 | [diff] [blame] | 1504 | dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", |
| 1505 | port, vlan.vid, i, |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1506 | netdev_name(dsa_to_port(ds, i)->bridge_dev)); |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1507 | return -EOPNOTSUPP; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1508 | } |
| 1509 | } while (vlan.vid < vid_end); |
| 1510 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1511 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1512 | } |
| 1513 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1514 | static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, |
| 1515 | bool vlan_filtering) |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1516 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1517 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 1518 | u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE : |
| 1519 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1520 | int err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1521 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1522 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1523 | return -EOPNOTSUPP; |
| 1524 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1525 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 385a099 | 2016-11-04 03:23:31 +0100 | [diff] [blame] | 1526 | err = mv88e6xxx_port_set_8021q_mode(chip, port, mode); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1527 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1528 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1529 | return err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1530 | } |
| 1531 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 1532 | static int |
| 1533 | mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1534 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1535 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1536 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1537 | int err; |
| 1538 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1539 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1540 | return -EOPNOTSUPP; |
| 1541 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1542 | /* If the requested port doesn't belong to the same bridge as the VLAN |
| 1543 | * members, do not support it (yet) and fallback to software VLAN. |
| 1544 | */ |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1545 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1546 | err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin, |
| 1547 | vlan->vid_end); |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1548 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1549 | |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1550 | /* We don't need any dynamic resource from the kernel (yet), |
| 1551 | * so skip the prepare phase. |
| 1552 | */ |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1553 | return err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1554 | } |
| 1555 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1556 | static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, |
| 1557 | const unsigned char *addr, u16 vid, |
| 1558 | u8 state) |
| 1559 | { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1560 | struct mv88e6xxx_atu_entry entry; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1561 | struct mv88e6xxx_vtu_entry vlan; |
| 1562 | u16 fid; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1563 | int err; |
| 1564 | |
| 1565 | /* Null VLAN ID corresponds to the port private database */ |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1566 | if (vid == 0) { |
| 1567 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
| 1568 | if (err) |
| 1569 | return err; |
| 1570 | } else { |
| 1571 | vlan.vid = vid - 1; |
| 1572 | vlan.valid = false; |
| 1573 | |
| 1574 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
| 1575 | if (err) |
| 1576 | return err; |
| 1577 | |
| 1578 | /* switchdev expects -EOPNOTSUPP to honor software VLANs */ |
| 1579 | if (vlan.vid != vid || !vlan.valid) |
| 1580 | return -EOPNOTSUPP; |
| 1581 | |
| 1582 | fid = vlan.fid; |
| 1583 | } |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1584 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1585 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1586 | ether_addr_copy(entry.mac, addr); |
| 1587 | eth_addr_dec(entry.mac); |
| 1588 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1589 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1590 | if (err) |
| 1591 | return err; |
| 1592 | |
| 1593 | /* Initialize a fresh ATU entry if it isn't found */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1594 | if (!entry.state || !ether_addr_equal(entry.mac, addr)) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1595 | memset(&entry, 0, sizeof(entry)); |
| 1596 | ether_addr_copy(entry.mac, addr); |
| 1597 | } |
| 1598 | |
| 1599 | /* Purge the ATU entry only if no port is using it anymore */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1600 | if (!state) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1601 | entry.portvec &= ~BIT(port); |
| 1602 | if (!entry.portvec) |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1603 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1604 | } else { |
| 1605 | entry.portvec |= BIT(port); |
| 1606 | entry.state = state; |
| 1607 | } |
| 1608 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1609 | return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1610 | } |
| 1611 | |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1612 | static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port, |
| 1613 | const struct mv88e6xxx_policy *policy) |
| 1614 | { |
| 1615 | enum mv88e6xxx_policy_mapping mapping = policy->mapping; |
| 1616 | enum mv88e6xxx_policy_action action = policy->action; |
| 1617 | const u8 *addr = policy->addr; |
| 1618 | u16 vid = policy->vid; |
| 1619 | u8 state; |
| 1620 | int err; |
| 1621 | int id; |
| 1622 | |
| 1623 | if (!chip->info->ops->port_set_policy) |
| 1624 | return -EOPNOTSUPP; |
| 1625 | |
| 1626 | switch (mapping) { |
| 1627 | case MV88E6XXX_POLICY_MAPPING_DA: |
| 1628 | case MV88E6XXX_POLICY_MAPPING_SA: |
| 1629 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1630 | state = 0; /* Dissociate the port and address */ |
| 1631 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1632 | is_multicast_ether_addr(addr)) |
| 1633 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY; |
| 1634 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1635 | is_unicast_ether_addr(addr)) |
| 1636 | state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY; |
| 1637 | else |
| 1638 | return -EOPNOTSUPP; |
| 1639 | |
| 1640 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 1641 | state); |
| 1642 | if (err) |
| 1643 | return err; |
| 1644 | break; |
| 1645 | default: |
| 1646 | return -EOPNOTSUPP; |
| 1647 | } |
| 1648 | |
| 1649 | /* Skip the port's policy clearing if the mapping is still in use */ |
| 1650 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1651 | idr_for_each_entry(&chip->policies, policy, id) |
| 1652 | if (policy->port == port && |
| 1653 | policy->mapping == mapping && |
| 1654 | policy->action != action) |
| 1655 | return 0; |
| 1656 | |
| 1657 | return chip->info->ops->port_set_policy(chip, port, mapping, action); |
| 1658 | } |
| 1659 | |
| 1660 | static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port, |
| 1661 | struct ethtool_rx_flow_spec *fs) |
| 1662 | { |
| 1663 | struct ethhdr *mac_entry = &fs->h_u.ether_spec; |
| 1664 | struct ethhdr *mac_mask = &fs->m_u.ether_spec; |
| 1665 | enum mv88e6xxx_policy_mapping mapping; |
| 1666 | enum mv88e6xxx_policy_action action; |
| 1667 | struct mv88e6xxx_policy *policy; |
| 1668 | u16 vid = 0; |
| 1669 | u8 *addr; |
| 1670 | int err; |
| 1671 | int id; |
| 1672 | |
| 1673 | if (fs->location != RX_CLS_LOC_ANY) |
| 1674 | return -EINVAL; |
| 1675 | |
| 1676 | if (fs->ring_cookie == RX_CLS_FLOW_DISC) |
| 1677 | action = MV88E6XXX_POLICY_ACTION_DISCARD; |
| 1678 | else |
| 1679 | return -EOPNOTSUPP; |
| 1680 | |
| 1681 | switch (fs->flow_type & ~FLOW_EXT) { |
| 1682 | case ETHER_FLOW: |
| 1683 | if (!is_zero_ether_addr(mac_mask->h_dest) && |
| 1684 | is_zero_ether_addr(mac_mask->h_source)) { |
| 1685 | mapping = MV88E6XXX_POLICY_MAPPING_DA; |
| 1686 | addr = mac_entry->h_dest; |
| 1687 | } else if (is_zero_ether_addr(mac_mask->h_dest) && |
| 1688 | !is_zero_ether_addr(mac_mask->h_source)) { |
| 1689 | mapping = MV88E6XXX_POLICY_MAPPING_SA; |
| 1690 | addr = mac_entry->h_source; |
| 1691 | } else { |
| 1692 | /* Cannot support DA and SA mapping in the same rule */ |
| 1693 | return -EOPNOTSUPP; |
| 1694 | } |
| 1695 | break; |
| 1696 | default: |
| 1697 | return -EOPNOTSUPP; |
| 1698 | } |
| 1699 | |
| 1700 | if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) { |
| 1701 | if (fs->m_ext.vlan_tci != 0xffff) |
| 1702 | return -EOPNOTSUPP; |
| 1703 | vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK; |
| 1704 | } |
| 1705 | |
| 1706 | idr_for_each_entry(&chip->policies, policy, id) { |
| 1707 | if (policy->port == port && policy->mapping == mapping && |
| 1708 | policy->action == action && policy->vid == vid && |
| 1709 | ether_addr_equal(policy->addr, addr)) |
| 1710 | return -EEXIST; |
| 1711 | } |
| 1712 | |
| 1713 | policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL); |
| 1714 | if (!policy) |
| 1715 | return -ENOMEM; |
| 1716 | |
| 1717 | fs->location = 0; |
| 1718 | err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff, |
| 1719 | GFP_KERNEL); |
| 1720 | if (err) { |
| 1721 | devm_kfree(chip->dev, policy); |
| 1722 | return err; |
| 1723 | } |
| 1724 | |
| 1725 | memcpy(&policy->fs, fs, sizeof(*fs)); |
| 1726 | ether_addr_copy(policy->addr, addr); |
| 1727 | policy->mapping = mapping; |
| 1728 | policy->action = action; |
| 1729 | policy->port = port; |
| 1730 | policy->vid = vid; |
| 1731 | |
| 1732 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1733 | if (err) { |
| 1734 | idr_remove(&chip->policies, fs->location); |
| 1735 | devm_kfree(chip->dev, policy); |
| 1736 | return err; |
| 1737 | } |
| 1738 | |
| 1739 | return 0; |
| 1740 | } |
| 1741 | |
| 1742 | static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port, |
| 1743 | struct ethtool_rxnfc *rxnfc, u32 *rule_locs) |
| 1744 | { |
| 1745 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1746 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1747 | struct mv88e6xxx_policy *policy; |
| 1748 | int err; |
| 1749 | int id; |
| 1750 | |
| 1751 | mv88e6xxx_reg_lock(chip); |
| 1752 | |
| 1753 | switch (rxnfc->cmd) { |
| 1754 | case ETHTOOL_GRXCLSRLCNT: |
| 1755 | rxnfc->data = 0; |
| 1756 | rxnfc->data |= RX_CLS_LOC_SPECIAL; |
| 1757 | rxnfc->rule_cnt = 0; |
| 1758 | idr_for_each_entry(&chip->policies, policy, id) |
| 1759 | if (policy->port == port) |
| 1760 | rxnfc->rule_cnt++; |
| 1761 | err = 0; |
| 1762 | break; |
| 1763 | case ETHTOOL_GRXCLSRULE: |
| 1764 | err = -ENOENT; |
| 1765 | policy = idr_find(&chip->policies, fs->location); |
| 1766 | if (policy) { |
| 1767 | memcpy(fs, &policy->fs, sizeof(*fs)); |
| 1768 | err = 0; |
| 1769 | } |
| 1770 | break; |
| 1771 | case ETHTOOL_GRXCLSRLALL: |
| 1772 | rxnfc->data = 0; |
| 1773 | rxnfc->rule_cnt = 0; |
| 1774 | idr_for_each_entry(&chip->policies, policy, id) |
| 1775 | if (policy->port == port) |
| 1776 | rule_locs[rxnfc->rule_cnt++] = id; |
| 1777 | err = 0; |
| 1778 | break; |
| 1779 | default: |
| 1780 | err = -EOPNOTSUPP; |
| 1781 | break; |
| 1782 | } |
| 1783 | |
| 1784 | mv88e6xxx_reg_unlock(chip); |
| 1785 | |
| 1786 | return err; |
| 1787 | } |
| 1788 | |
| 1789 | static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port, |
| 1790 | struct ethtool_rxnfc *rxnfc) |
| 1791 | { |
| 1792 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1793 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1794 | struct mv88e6xxx_policy *policy; |
| 1795 | int err; |
| 1796 | |
| 1797 | mv88e6xxx_reg_lock(chip); |
| 1798 | |
| 1799 | switch (rxnfc->cmd) { |
| 1800 | case ETHTOOL_SRXCLSRLINS: |
| 1801 | err = mv88e6xxx_policy_insert(chip, port, fs); |
| 1802 | break; |
| 1803 | case ETHTOOL_SRXCLSRLDEL: |
| 1804 | err = -ENOENT; |
| 1805 | policy = idr_remove(&chip->policies, fs->location); |
| 1806 | if (policy) { |
| 1807 | policy->action = MV88E6XXX_POLICY_ACTION_NORMAL; |
| 1808 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1809 | devm_kfree(chip->dev, policy); |
| 1810 | } |
| 1811 | break; |
| 1812 | default: |
| 1813 | err = -EOPNOTSUPP; |
| 1814 | break; |
| 1815 | } |
| 1816 | |
| 1817 | mv88e6xxx_reg_unlock(chip); |
| 1818 | |
| 1819 | return err; |
| 1820 | } |
| 1821 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1822 | static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port, |
| 1823 | u16 vid) |
| 1824 | { |
| 1825 | const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 1826 | u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
| 1827 | |
| 1828 | return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state); |
| 1829 | } |
| 1830 | |
| 1831 | static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) |
| 1832 | { |
| 1833 | int port; |
| 1834 | int err; |
| 1835 | |
| 1836 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1837 | err = mv88e6xxx_port_add_broadcast(chip, port, vid); |
| 1838 | if (err) |
| 1839 | return err; |
| 1840 | } |
| 1841 | |
| 1842 | return 0; |
| 1843 | } |
| 1844 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1845 | static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port, |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1846 | u16 vid, u8 member, bool warn) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1847 | { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1848 | const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 1849 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1850 | int i, err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1851 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1852 | if (!vid) |
| 1853 | return -EOPNOTSUPP; |
| 1854 | |
| 1855 | vlan.vid = vid - 1; |
| 1856 | vlan.valid = false; |
| 1857 | |
| 1858 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1859 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1860 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1861 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1862 | if (vlan.vid != vid || !vlan.valid) { |
| 1863 | memset(&vlan, 0, sizeof(vlan)); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1864 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1865 | err = mv88e6xxx_atu_new(chip, &vlan.fid); |
| 1866 | if (err) |
| 1867 | return err; |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1868 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1869 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) |
| 1870 | if (i == port) |
| 1871 | vlan.member[i] = member; |
| 1872 | else |
| 1873 | vlan.member[i] = non_member; |
| 1874 | |
| 1875 | vlan.vid = vid; |
| 1876 | vlan.valid = true; |
| 1877 | |
| 1878 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 1879 | if (err) |
| 1880 | return err; |
| 1881 | |
| 1882 | err = mv88e6xxx_broadcast_setup(chip, vlan.vid); |
| 1883 | if (err) |
| 1884 | return err; |
| 1885 | } else if (vlan.member[port] != member) { |
| 1886 | vlan.member[port] = member; |
| 1887 | |
| 1888 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 1889 | if (err) |
| 1890 | return err; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1891 | } else if (warn) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1892 | dev_info(chip->dev, "p%d: already a member of VLAN %d\n", |
| 1893 | port, vid); |
| 1894 | } |
| 1895 | |
| 1896 | return 0; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1897 | } |
| 1898 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1899 | static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1900 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1901 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1902 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1903 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; |
| 1904 | bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1905 | bool warn; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1906 | u8 member; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1907 | u16 vid; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1908 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1909 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1910 | return; |
| 1911 | |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1912 | 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] | 1913 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1914 | else if (untagged) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1915 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1916 | else |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1917 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1918 | |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1919 | /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port |
| 1920 | * and then the CPU port. Do not warn for duplicates for the CPU port. |
| 1921 | */ |
| 1922 | warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port); |
| 1923 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1924 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1925 | |
Vivien Didelot | 4d5770b | 2016-04-06 11:55:05 -0400 | [diff] [blame] | 1926 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1927 | if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1928 | dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port, |
| 1929 | vid, untagged ? 'u' : 't'); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1930 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 1931 | if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1932 | dev_err(ds->dev, "p%d: failed to set PVID %d\n", port, |
| 1933 | vlan->vid_end); |
Vivien Didelot | 4d5770b | 2016-04-06 11:55:05 -0400 | [diff] [blame] | 1934 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1935 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1936 | } |
| 1937 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 1938 | static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip, |
| 1939 | int port, u16 vid) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1940 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 1941 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1942 | int i, err; |
| 1943 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 1944 | if (!vid) |
| 1945 | return -EOPNOTSUPP; |
| 1946 | |
| 1947 | vlan.vid = vid - 1; |
| 1948 | vlan.valid = false; |
| 1949 | |
| 1950 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1951 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1952 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1953 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 1954 | /* If the VLAN doesn't exist in hardware or the port isn't a member, |
| 1955 | * tell switchdev that this VLAN is likely handled in software. |
| 1956 | */ |
| 1957 | if (vlan.vid != vid || !vlan.valid || |
| 1958 | vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | 3c06f08 | 2016-02-05 14:04:39 -0500 | [diff] [blame] | 1959 | return -EOPNOTSUPP; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1960 | |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1961 | vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1962 | |
| 1963 | /* keep the VLAN unless all ports are excluded */ |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 1964 | vlan.valid = false; |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1965 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1966 | if (vlan.member[i] != |
| 1967 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) { |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 1968 | vlan.valid = true; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1969 | break; |
| 1970 | } |
| 1971 | } |
| 1972 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1973 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1974 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1975 | return err; |
| 1976 | |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1977 | return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1978 | } |
| 1979 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1980 | static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, |
| 1981 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1982 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1983 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1984 | u16 pvid, vid; |
| 1985 | int err = 0; |
| 1986 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1987 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1988 | return -EOPNOTSUPP; |
| 1989 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1990 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1991 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 1992 | err = mv88e6xxx_port_get_pvid(chip, port, &pvid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1993 | if (err) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1994 | goto unlock; |
| 1995 | |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1996 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 1997 | err = mv88e6xxx_port_vlan_leave(chip, port, vid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1998 | if (err) |
| 1999 | goto unlock; |
| 2000 | |
| 2001 | if (vid == pvid) { |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 2002 | err = mv88e6xxx_port_set_pvid(chip, port, 0); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2003 | if (err) |
| 2004 | goto unlock; |
| 2005 | } |
| 2006 | } |
| 2007 | |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2008 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2009 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2010 | |
| 2011 | return err; |
| 2012 | } |
| 2013 | |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2014 | static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, |
| 2015 | const unsigned char *addr, u16 vid) |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 2016 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2017 | struct mv88e6xxx_chip *chip = ds->priv; |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2018 | int err; |
Vivien Didelot | 6630e23 | 2015-08-06 01:44:07 -0400 | [diff] [blame] | 2019 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2020 | mv88e6xxx_reg_lock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2021 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 2022 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2023 | mv88e6xxx_reg_unlock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2024 | |
| 2025 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2026 | } |
| 2027 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2028 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 6c2c1dc | 2017-08-06 16:15:39 +0300 | [diff] [blame] | 2029 | const unsigned char *addr, u16 vid) |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2030 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2031 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2032 | int err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2033 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2034 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2035 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2036 | mv88e6xxx_reg_unlock(chip); |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2037 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2038 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2039 | } |
| 2040 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2041 | static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, |
| 2042 | u16 fid, u16 vid, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2043 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2044 | { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2045 | struct mv88e6xxx_atu_entry addr; |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2046 | bool is_static; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2047 | int err; |
| 2048 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2049 | addr.state = 0; |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2050 | eth_broadcast_addr(addr.mac); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2051 | |
| 2052 | do { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2053 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2054 | if (err) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2055 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2056 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2057 | if (!addr.state) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2058 | break; |
| 2059 | |
Vivien Didelot | 01bd96c | 2017-03-11 16:12:57 -0500 | [diff] [blame] | 2060 | if (addr.trunk || (addr.portvec & BIT(port)) == 0) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2061 | continue; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2062 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2063 | if (!is_unicast_ether_addr(addr.mac)) |
| 2064 | continue; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2065 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2066 | is_static = (addr.state == |
| 2067 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
| 2068 | err = cb(addr.mac, vid, is_static, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2069 | if (err) |
| 2070 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2071 | } while (!is_broadcast_ether_addr(addr.mac)); |
| 2072 | |
| 2073 | return err; |
| 2074 | } |
| 2075 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2076 | static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2077 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2078 | { |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 2079 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2080 | u16 fid; |
| 2081 | int err; |
| 2082 | |
| 2083 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2084 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2085 | if (err) |
| 2086 | return err; |
| 2087 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2088 | err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2089 | if (err) |
| 2090 | return err; |
| 2091 | |
| 2092 | /* Dump VLANs' Filtering Information Databases */ |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 2093 | vlan.vid = chip->info->max_vid; |
| 2094 | vlan.valid = false; |
| 2095 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2096 | do { |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2097 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2098 | if (err) |
| 2099 | return err; |
| 2100 | |
| 2101 | if (!vlan.valid) |
| 2102 | break; |
| 2103 | |
| 2104 | err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2105 | cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2106 | if (err) |
| 2107 | return err; |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 2108 | } while (vlan.vid < chip->info->max_vid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2109 | |
| 2110 | return err; |
| 2111 | } |
| 2112 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2113 | static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2114 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2115 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2116 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2117 | int err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2118 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2119 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2120 | err = mv88e6xxx_port_db_dump(chip, port, cb, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2121 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2122 | |
| 2123 | return err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2124 | } |
| 2125 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2126 | static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, |
| 2127 | struct net_device *br) |
| 2128 | { |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2129 | struct dsa_switch *ds = chip->ds; |
| 2130 | struct dsa_switch_tree *dst = ds->dst; |
| 2131 | struct dsa_port *dp; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2132 | int err; |
| 2133 | |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2134 | list_for_each_entry(dp, &dst->ports, list) { |
| 2135 | if (dp->bridge_dev == br) { |
| 2136 | if (dp->ds == ds) { |
| 2137 | /* This is a local bridge group member, |
| 2138 | * remap its Port VLAN Map. |
| 2139 | */ |
| 2140 | err = mv88e6xxx_port_vlan_map(chip, dp->index); |
| 2141 | if (err) |
| 2142 | return err; |
| 2143 | } else { |
| 2144 | /* This is an external bridge group member, |
| 2145 | * remap its cross-chip Port VLAN Table entry. |
| 2146 | */ |
| 2147 | err = mv88e6xxx_pvt_map(chip, dp->ds->index, |
| 2148 | dp->index); |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 2149 | if (err) |
| 2150 | return err; |
| 2151 | } |
| 2152 | } |
| 2153 | } |
| 2154 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2155 | return 0; |
| 2156 | } |
| 2157 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2158 | static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, |
Vivien Didelot | fae8a25 | 2017-01-27 15:29:42 -0500 | [diff] [blame] | 2159 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2160 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2161 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2162 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2163 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2164 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2165 | err = mv88e6xxx_bridge_map(chip, br); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2166 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | a669275 | 2016-02-12 12:09:39 -0500 | [diff] [blame] | 2167 | |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2168 | return err; |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2169 | } |
| 2170 | |
Vivien Didelot | f123f2f | 2017-01-27 15:29:41 -0500 | [diff] [blame] | 2171 | static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, |
| 2172 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2173 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2174 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2175 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2176 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2177 | if (mv88e6xxx_bridge_map(chip, br) || |
| 2178 | mv88e6xxx_port_vlan_map(chip, port)) |
| 2179 | dev_err(ds->dev, "failed to remap in-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2180 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 66d9cd0 | 2016-02-05 14:07:14 -0500 | [diff] [blame] | 2181 | } |
| 2182 | |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2183 | static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev, |
| 2184 | int port, struct net_device *br) |
| 2185 | { |
| 2186 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2187 | int err; |
| 2188 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2189 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2190 | err = mv88e6xxx_pvt_map(chip, dev, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2191 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2192 | |
| 2193 | return err; |
| 2194 | } |
| 2195 | |
| 2196 | static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev, |
| 2197 | int port, struct net_device *br) |
| 2198 | { |
| 2199 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2200 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2201 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2202 | if (mv88e6xxx_pvt_map(chip, dev, port)) |
| 2203 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2204 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2205 | } |
| 2206 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2207 | static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip) |
| 2208 | { |
| 2209 | if (chip->info->ops->reset) |
| 2210 | return chip->info->ops->reset(chip); |
| 2211 | |
| 2212 | return 0; |
| 2213 | } |
| 2214 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2215 | static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip) |
| 2216 | { |
| 2217 | struct gpio_desc *gpiod = chip->reset; |
| 2218 | |
| 2219 | /* If there is a GPIO connected to the reset pin, toggle it */ |
| 2220 | if (gpiod) { |
| 2221 | gpiod_set_value_cansleep(gpiod, 1); |
| 2222 | usleep_range(10000, 20000); |
| 2223 | gpiod_set_value_cansleep(gpiod, 0); |
| 2224 | usleep_range(10000, 20000); |
| 2225 | } |
| 2226 | } |
| 2227 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2228 | static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip) |
| 2229 | { |
| 2230 | int i, err; |
| 2231 | |
| 2232 | /* Set all ports to the Disabled state */ |
| 2233 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 2234 | err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED); |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2235 | if (err) |
| 2236 | return err; |
| 2237 | } |
| 2238 | |
| 2239 | /* Wait for transmit queues to drain, |
| 2240 | * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps. |
| 2241 | */ |
| 2242 | usleep_range(2000, 4000); |
| 2243 | |
| 2244 | return 0; |
| 2245 | } |
| 2246 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2247 | static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2248 | { |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 2249 | int err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2250 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2251 | err = mv88e6xxx_disable_ports(chip); |
| 2252 | if (err) |
| 2253 | return err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2254 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2255 | mv88e6xxx_hardware_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2256 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2257 | return mv88e6xxx_software_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2258 | } |
| 2259 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2260 | static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2261 | enum mv88e6xxx_frame_mode frame, |
| 2262 | enum mv88e6xxx_egress_mode egress, u16 etype) |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2263 | { |
| 2264 | int err; |
| 2265 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2266 | if (!chip->info->ops->port_set_frame_mode) |
| 2267 | return -EOPNOTSUPP; |
| 2268 | |
| 2269 | err = mv88e6xxx_port_set_egress_mode(chip, port, egress); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2270 | if (err) |
| 2271 | return err; |
| 2272 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2273 | err = chip->info->ops->port_set_frame_mode(chip, port, frame); |
| 2274 | if (err) |
| 2275 | return err; |
| 2276 | |
| 2277 | if (chip->info->ops->port_set_ether_type) |
| 2278 | return chip->info->ops->port_set_ether_type(chip, port, etype); |
| 2279 | |
| 2280 | return 0; |
| 2281 | } |
| 2282 | |
| 2283 | static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port) |
| 2284 | { |
| 2285 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2286 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2287 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2288 | } |
| 2289 | |
| 2290 | static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port) |
| 2291 | { |
| 2292 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2293 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2294 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2295 | } |
| 2296 | |
| 2297 | static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port) |
| 2298 | { |
| 2299 | return mv88e6xxx_set_port_mode(chip, port, |
| 2300 | MV88E6XXX_FRAME_MODE_ETHERTYPE, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2301 | MV88E6XXX_EGRESS_MODE_ETHERTYPE, |
| 2302 | ETH_P_EDSA); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port) |
| 2306 | { |
| 2307 | if (dsa_is_dsa_port(chip->ds, port)) |
| 2308 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2309 | |
Vivien Didelot | 2b3e989 | 2017-10-26 11:22:54 -0400 | [diff] [blame] | 2310 | if (dsa_is_user_port(chip->ds, port)) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2311 | return mv88e6xxx_set_port_mode_normal(chip, port); |
| 2312 | |
| 2313 | /* Setup CPU port mode depending on its supported tag format */ |
| 2314 | if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA) |
| 2315 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2316 | |
| 2317 | if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA) |
| 2318 | return mv88e6xxx_set_port_mode_edsa(chip, port); |
| 2319 | |
| 2320 | return -EINVAL; |
| 2321 | } |
| 2322 | |
Vivien Didelot | ea698f4 | 2017-03-11 16:12:50 -0500 | [diff] [blame] | 2323 | static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port) |
| 2324 | { |
| 2325 | bool message = dsa_is_dsa_port(chip->ds, port); |
| 2326 | |
| 2327 | return mv88e6xxx_port_set_message_port(chip, port, message); |
| 2328 | } |
| 2329 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2330 | static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) |
| 2331 | { |
Vivien Didelot | 3ee50cb | 2017-12-05 15:34:09 -0500 | [diff] [blame] | 2332 | struct dsa_switch *ds = chip->ds; |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2333 | bool flood; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2334 | |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2335 | /* Upstream ports flood frames with unknown unicast or multicast DA */ |
| 2336 | flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port); |
| 2337 | if (chip->info->ops->port_set_egress_floods) |
| 2338 | return chip->info->ops->port_set_egress_floods(chip, port, |
| 2339 | flood, flood); |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2340 | |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2341 | return 0; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2342 | } |
| 2343 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2344 | static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id) |
| 2345 | { |
| 2346 | struct mv88e6xxx_port *mvp = dev_id; |
| 2347 | struct mv88e6xxx_chip *chip = mvp->chip; |
| 2348 | irqreturn_t ret = IRQ_NONE; |
| 2349 | int port = mvp->port; |
| 2350 | u8 lane; |
| 2351 | |
| 2352 | mv88e6xxx_reg_lock(chip); |
| 2353 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
| 2354 | if (lane) |
| 2355 | ret = mv88e6xxx_serdes_irq_status(chip, port, lane); |
| 2356 | mv88e6xxx_reg_unlock(chip); |
| 2357 | |
| 2358 | return ret; |
| 2359 | } |
| 2360 | |
| 2361 | static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port, |
| 2362 | u8 lane) |
| 2363 | { |
| 2364 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2365 | unsigned int irq; |
| 2366 | int err; |
| 2367 | |
| 2368 | /* Nothing to request if this SERDES port has no IRQ */ |
| 2369 | irq = mv88e6xxx_serdes_irq_mapping(chip, port); |
| 2370 | if (!irq) |
| 2371 | return 0; |
| 2372 | |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2373 | snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name), |
| 2374 | "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port); |
| 2375 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2376 | /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2377 | mv88e6xxx_reg_unlock(chip); |
| 2378 | err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn, |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2379 | IRQF_ONESHOT, dev_id->serdes_irq_name, |
| 2380 | dev_id); |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2381 | mv88e6xxx_reg_lock(chip); |
| 2382 | if (err) |
| 2383 | return err; |
| 2384 | |
| 2385 | dev_id->serdes_irq = irq; |
| 2386 | |
| 2387 | return mv88e6xxx_serdes_irq_enable(chip, port, lane); |
| 2388 | } |
| 2389 | |
| 2390 | static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port, |
| 2391 | u8 lane) |
| 2392 | { |
| 2393 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2394 | unsigned int irq = dev_id->serdes_irq; |
| 2395 | int err; |
| 2396 | |
| 2397 | /* Nothing to free if no IRQ has been requested */ |
| 2398 | if (!irq) |
| 2399 | return 0; |
| 2400 | |
| 2401 | err = mv88e6xxx_serdes_irq_disable(chip, port, lane); |
| 2402 | |
| 2403 | /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2404 | mv88e6xxx_reg_unlock(chip); |
| 2405 | free_irq(irq, dev_id); |
| 2406 | mv88e6xxx_reg_lock(chip); |
| 2407 | |
| 2408 | dev_id->serdes_irq = 0; |
| 2409 | |
| 2410 | return err; |
| 2411 | } |
| 2412 | |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2413 | static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, |
| 2414 | bool on) |
| 2415 | { |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2416 | u8 lane; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2417 | int err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2418 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2419 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
| 2420 | if (!lane) |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2421 | return 0; |
| 2422 | |
| 2423 | if (on) { |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2424 | err = mv88e6xxx_serdes_power_up(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2425 | if (err) |
| 2426 | return err; |
| 2427 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2428 | err = mv88e6xxx_serdes_irq_request(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2429 | } else { |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2430 | err = mv88e6xxx_serdes_irq_free(chip, port, lane); |
| 2431 | if (err) |
| 2432 | return err; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2433 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2434 | err = mv88e6xxx_serdes_power_down(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2435 | } |
| 2436 | |
| 2437 | return err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2438 | } |
| 2439 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2440 | static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port) |
| 2441 | { |
| 2442 | struct dsa_switch *ds = chip->ds; |
| 2443 | int upstream_port; |
| 2444 | int err; |
| 2445 | |
Vivien Didelot | 07073c7 | 2017-12-05 15:34:13 -0500 | [diff] [blame] | 2446 | upstream_port = dsa_upstream_port(ds, port); |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2447 | if (chip->info->ops->port_set_upstream_port) { |
| 2448 | err = chip->info->ops->port_set_upstream_port(chip, port, |
| 2449 | upstream_port); |
| 2450 | if (err) |
| 2451 | return err; |
| 2452 | } |
| 2453 | |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2454 | if (port == upstream_port) { |
| 2455 | if (chip->info->ops->set_cpu_port) { |
| 2456 | err = chip->info->ops->set_cpu_port(chip, |
| 2457 | upstream_port); |
| 2458 | if (err) |
| 2459 | return err; |
| 2460 | } |
| 2461 | |
| 2462 | if (chip->info->ops->set_egress_port) { |
| 2463 | err = chip->info->ops->set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2464 | MV88E6XXX_EGRESS_DIR_INGRESS, |
| 2465 | upstream_port); |
| 2466 | if (err) |
| 2467 | return err; |
| 2468 | |
| 2469 | err = chip->info->ops->set_egress_port(chip, |
| 2470 | MV88E6XXX_EGRESS_DIR_EGRESS, |
| 2471 | upstream_port); |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2472 | if (err) |
| 2473 | return err; |
| 2474 | } |
| 2475 | } |
| 2476 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2477 | return 0; |
| 2478 | } |
| 2479 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2480 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2481 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2482 | struct dsa_switch *ds = chip->ds; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2483 | int err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2484 | u16 reg; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2485 | |
Andrew Lunn | 7b89846 | 2018-08-09 15:38:47 +0200 | [diff] [blame] | 2486 | chip->ports[port].chip = chip; |
| 2487 | chip->ports[port].port = port; |
| 2488 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2489 | /* MAC Forcing register: don't force link, speed, duplex or flow control |
| 2490 | * state to any particular values on physical ports, but force the CPU |
| 2491 | * port and all DSA ports to their maximum bandwidth and full duplex. |
| 2492 | */ |
| 2493 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
| 2494 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, |
| 2495 | SPEED_MAX, DUPLEX_FULL, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2496 | PAUSE_OFF, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2497 | PHY_INTERFACE_MODE_NA); |
| 2498 | else |
| 2499 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, |
| 2500 | SPEED_UNFORCED, DUPLEX_UNFORCED, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2501 | PAUSE_ON, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2502 | PHY_INTERFACE_MODE_NA); |
| 2503 | if (err) |
| 2504 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2505 | |
| 2506 | /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock, |
| 2507 | * disable Header mode, enable IGMP/MLD snooping, disable VLAN |
| 2508 | * tunneling, determine priority by looking at 802.1p and IP |
| 2509 | * priority fields (IP prio has precedence), and set STP state |
| 2510 | * to Forwarding. |
| 2511 | * |
| 2512 | * If this is the CPU link, use DSA or EDSA tagging depending |
| 2513 | * on which tagging mode was configured. |
| 2514 | * |
| 2515 | * If this is a link to another switch, use DSA tagging mode. |
| 2516 | * |
| 2517 | * If this is the upstream port for this switch, enable |
| 2518 | * forwarding of unknown unicasts and multicasts. |
| 2519 | */ |
Vivien Didelot | a89b433be | 2017-06-12 12:37:37 -0400 | [diff] [blame] | 2520 | reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP | |
| 2521 | MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP | |
| 2522 | MV88E6XXX_PORT_CTL0_STATE_FORWARDING; |
| 2523 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2524 | if (err) |
| 2525 | return err; |
Andrew Lunn | 6083ce7 | 2015-08-17 23:52:52 +0200 | [diff] [blame] | 2526 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2527 | err = mv88e6xxx_setup_port_mode(chip, port); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2528 | if (err) |
| 2529 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2530 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2531 | err = mv88e6xxx_setup_egress_floods(chip, port); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2532 | if (err) |
| 2533 | return err; |
| 2534 | |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2535 | /* Port Control 2: don't force a good FCS, set the maximum frame size to |
Vivien Didelot | 46fbe5e | 2016-02-26 13:16:07 -0500 | [diff] [blame] | 2536 | * 10240 bytes, disable 802.1q tags checking, don't discard tagged or |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2537 | * untagged frames on this port, do a destination address lookup on all |
| 2538 | * received packets as usual, disable ARP mirroring and don't send a |
| 2539 | * copy of all transmitted/received frames on this port to the CPU. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2540 | */ |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2541 | err = mv88e6xxx_port_set_map_da(chip, port); |
| 2542 | if (err) |
| 2543 | return err; |
| 2544 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2545 | err = mv88e6xxx_setup_upstream_port(chip, port); |
| 2546 | if (err) |
| 2547 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2548 | |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2549 | err = mv88e6xxx_port_set_8021q_mode(chip, port, |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 2550 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED); |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2551 | if (err) |
| 2552 | return err; |
| 2553 | |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2554 | if (chip->info->ops->port_set_jumbo_size) { |
| 2555 | err = chip->info->ops->port_set_jumbo_size(chip, port, 10240); |
Andrew Lunn | 5f43666 | 2016-12-03 04:45:17 +0100 | [diff] [blame] | 2556 | if (err) |
| 2557 | return err; |
| 2558 | } |
| 2559 | |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2560 | /* Port Association Vector: when learning source addresses |
| 2561 | * of packets, add the address to the address database using |
| 2562 | * a port bitmap that has only the bit for this port set and |
| 2563 | * the other bits clear. |
| 2564 | */ |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2565 | reg = 1 << port; |
Vivien Didelot | 996ecb8 | 2016-04-14 14:42:08 -0400 | [diff] [blame] | 2566 | /* Disable learning for CPU port */ |
| 2567 | if (dsa_is_cpu_port(ds, port)) |
Vivien Didelot | 65fa402 | 2016-04-14 14:42:07 -0400 | [diff] [blame] | 2568 | reg = 0; |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2569 | |
Vivien Didelot | 2a4614e | 2017-06-12 12:37:43 -0400 | [diff] [blame] | 2570 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, |
| 2571 | reg); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2572 | if (err) |
| 2573 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2574 | |
| 2575 | /* Egress rate control 2: disable egress rate control. */ |
Vivien Didelot | 2cb8cb1 | 2017-06-12 12:37:42 -0400 | [diff] [blame] | 2576 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2, |
| 2577 | 0x0000); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2578 | if (err) |
| 2579 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2580 | |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2581 | if (chip->info->ops->port_pause_limit) { |
| 2582 | err = chip->info->ops->port_pause_limit(chip, port, 0, 0); |
Andrew Lunn | b35d322a | 2016-12-03 04:45:19 +0100 | [diff] [blame] | 2583 | if (err) |
| 2584 | return err; |
| 2585 | } |
| 2586 | |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2587 | if (chip->info->ops->port_disable_learn_limit) { |
| 2588 | err = chip->info->ops->port_disable_learn_limit(chip, port); |
| 2589 | if (err) |
| 2590 | return err; |
| 2591 | } |
| 2592 | |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2593 | if (chip->info->ops->port_disable_pri_override) { |
| 2594 | err = chip->info->ops->port_disable_pri_override(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2595 | if (err) |
| 2596 | return err; |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2597 | } |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 2598 | |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2599 | if (chip->info->ops->port_tag_remap) { |
| 2600 | err = chip->info->ops->port_tag_remap(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2601 | if (err) |
| 2602 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2603 | } |
| 2604 | |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2605 | if (chip->info->ops->port_egress_rate_limiting) { |
| 2606 | err = chip->info->ops->port_egress_rate_limiting(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2607 | if (err) |
| 2608 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2609 | } |
| 2610 | |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 2611 | if (chip->info->ops->port_setup_message_port) { |
| 2612 | err = chip->info->ops->port_setup_message_port(chip, port); |
| 2613 | if (err) |
| 2614 | return err; |
| 2615 | } |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2616 | |
Vivien Didelot | 207afda | 2016-04-14 14:42:09 -0400 | [diff] [blame] | 2617 | /* Port based VLAN map: give each port the same default address |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 2618 | * database, and allow bidirectional communication between the |
| 2619 | * CPU and DSA port(s), and the other ports. |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2620 | */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2621 | err = mv88e6xxx_port_set_fid(chip, port, 0); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2622 | if (err) |
| 2623 | return err; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 2624 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2625 | err = mv88e6xxx_port_vlan_map(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2626 | if (err) |
| 2627 | return err; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2628 | |
| 2629 | /* Default VLAN ID and priority: don't set a default VLAN |
| 2630 | * ID, and set the default packet priority to zero. |
| 2631 | */ |
Vivien Didelot | b7929fb | 2017-06-12 12:37:40 -0400 | [diff] [blame] | 2632 | return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0); |
Andrew Lunn | dbde9e6 | 2015-05-06 01:09:48 +0200 | [diff] [blame] | 2633 | } |
| 2634 | |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2635 | static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port, |
| 2636 | struct phy_device *phydev) |
| 2637 | { |
| 2638 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2639 | int err; |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2640 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2641 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2642 | err = mv88e6xxx_serdes_power(chip, port, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2643 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2644 | |
| 2645 | return err; |
| 2646 | } |
| 2647 | |
Andrew Lunn | 75104db | 2019-02-24 20:44:43 +0100 | [diff] [blame] | 2648 | static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port) |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2649 | { |
| 2650 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2651 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2652 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2653 | if (mv88e6xxx_serdes_power(chip, port, false)) |
| 2654 | dev_err(chip->dev, "failed to power off SERDES\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2655 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2656 | } |
| 2657 | |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2658 | static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds, |
| 2659 | unsigned int ageing_time) |
| 2660 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2661 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2662 | int err; |
| 2663 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2664 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 720c634 | 2017-03-11 16:12:48 -0500 | [diff] [blame] | 2665 | err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2666 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2667 | |
| 2668 | return err; |
| 2669 | } |
| 2670 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 2671 | static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2672 | { |
| 2673 | int err; |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2674 | |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 2675 | /* Initialize the statistics unit */ |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 2676 | if (chip->info->ops->stats_set_histogram) { |
| 2677 | err = chip->info->ops->stats_set_histogram(chip); |
| 2678 | if (err) |
| 2679 | return err; |
| 2680 | } |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 2681 | |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2682 | return mv88e6xxx_g1_stats_clear(chip); |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 2683 | } |
| 2684 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 2685 | /* Check if the errata has already been applied. */ |
| 2686 | static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip) |
| 2687 | { |
| 2688 | int port; |
| 2689 | int err; |
| 2690 | u16 val; |
| 2691 | |
| 2692 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 2693 | err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 2694 | if (err) { |
| 2695 | dev_err(chip->dev, |
| 2696 | "Error reading hidden register: %d\n", err); |
| 2697 | return false; |
| 2698 | } |
| 2699 | if (val != 0x01c0) |
| 2700 | return false; |
| 2701 | } |
| 2702 | |
| 2703 | return true; |
| 2704 | } |
| 2705 | |
| 2706 | /* The 6390 copper ports have an errata which require poking magic |
| 2707 | * values into undocumented hidden registers and then performing a |
| 2708 | * software reset. |
| 2709 | */ |
| 2710 | static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip) |
| 2711 | { |
| 2712 | int port; |
| 2713 | int err; |
| 2714 | |
| 2715 | if (mv88e6390_setup_errata_applied(chip)) |
| 2716 | return 0; |
| 2717 | |
| 2718 | /* Set the ports into blocking mode */ |
| 2719 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 2720 | err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED); |
| 2721 | if (err) |
| 2722 | return err; |
| 2723 | } |
| 2724 | |
| 2725 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 2726 | err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 2727 | if (err) |
| 2728 | return err; |
| 2729 | } |
| 2730 | |
| 2731 | return mv88e6xxx_software_reset(chip); |
| 2732 | } |
| 2733 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 2734 | enum mv88e6xxx_devlink_param_id { |
| 2735 | MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, |
| 2736 | MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH, |
| 2737 | }; |
| 2738 | |
| 2739 | static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id, |
| 2740 | struct devlink_param_gset_ctx *ctx) |
| 2741 | { |
| 2742 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2743 | int err; |
| 2744 | |
| 2745 | mv88e6xxx_reg_lock(chip); |
| 2746 | |
| 2747 | switch (id) { |
| 2748 | case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH: |
| 2749 | err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8); |
| 2750 | break; |
| 2751 | default: |
| 2752 | err = -EOPNOTSUPP; |
| 2753 | break; |
| 2754 | } |
| 2755 | |
| 2756 | mv88e6xxx_reg_unlock(chip); |
| 2757 | |
| 2758 | return err; |
| 2759 | } |
| 2760 | |
| 2761 | static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id, |
| 2762 | struct devlink_param_gset_ctx *ctx) |
| 2763 | { |
| 2764 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2765 | int err; |
| 2766 | |
| 2767 | mv88e6xxx_reg_lock(chip); |
| 2768 | |
| 2769 | switch (id) { |
| 2770 | case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH: |
| 2771 | err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8); |
| 2772 | break; |
| 2773 | default: |
| 2774 | err = -EOPNOTSUPP; |
| 2775 | break; |
| 2776 | } |
| 2777 | |
| 2778 | mv88e6xxx_reg_unlock(chip); |
| 2779 | |
| 2780 | return err; |
| 2781 | } |
| 2782 | |
| 2783 | static const struct devlink_param mv88e6xxx_devlink_params[] = { |
| 2784 | DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH, |
| 2785 | "ATU_hash", DEVLINK_PARAM_TYPE_U8, |
| 2786 | BIT(DEVLINK_PARAM_CMODE_RUNTIME)), |
| 2787 | }; |
| 2788 | |
| 2789 | static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds) |
| 2790 | { |
| 2791 | return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params, |
| 2792 | ARRAY_SIZE(mv88e6xxx_devlink_params)); |
| 2793 | } |
| 2794 | |
| 2795 | static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds) |
| 2796 | { |
| 2797 | dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params, |
| 2798 | ARRAY_SIZE(mv88e6xxx_devlink_params)); |
| 2799 | } |
| 2800 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 2801 | enum mv88e6xxx_devlink_resource_id { |
| 2802 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2803 | MV88E6XXX_RESOURCE_ID_ATU_BIN_0, |
| 2804 | MV88E6XXX_RESOURCE_ID_ATU_BIN_1, |
| 2805 | MV88E6XXX_RESOURCE_ID_ATU_BIN_2, |
| 2806 | MV88E6XXX_RESOURCE_ID_ATU_BIN_3, |
| 2807 | }; |
| 2808 | |
| 2809 | static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip, |
| 2810 | u16 bin) |
| 2811 | { |
| 2812 | u16 occupancy = 0; |
| 2813 | int err; |
| 2814 | |
| 2815 | mv88e6xxx_reg_lock(chip); |
| 2816 | |
| 2817 | err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL, |
| 2818 | bin); |
| 2819 | if (err) { |
| 2820 | dev_err(chip->dev, "failed to set ATU stats kind/bin\n"); |
| 2821 | goto unlock; |
| 2822 | } |
| 2823 | |
| 2824 | err = mv88e6xxx_g1_atu_get_next(chip, 0); |
| 2825 | if (err) { |
| 2826 | dev_err(chip->dev, "failed to perform ATU get next\n"); |
| 2827 | goto unlock; |
| 2828 | } |
| 2829 | |
| 2830 | err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy); |
| 2831 | if (err) { |
| 2832 | dev_err(chip->dev, "failed to get ATU stats\n"); |
| 2833 | goto unlock; |
| 2834 | } |
| 2835 | |
Andrew Lunn | 012fc74 | 2020-03-11 21:02:31 +0100 | [diff] [blame] | 2836 | occupancy &= MV88E6XXX_G2_ATU_STATS_MASK; |
| 2837 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 2838 | unlock: |
| 2839 | mv88e6xxx_reg_unlock(chip); |
| 2840 | |
| 2841 | return occupancy; |
| 2842 | } |
| 2843 | |
| 2844 | static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv) |
| 2845 | { |
| 2846 | struct mv88e6xxx_chip *chip = priv; |
| 2847 | |
| 2848 | return mv88e6xxx_devlink_atu_bin_get(chip, |
| 2849 | MV88E6XXX_G2_ATU_STATS_BIN_0); |
| 2850 | } |
| 2851 | |
| 2852 | static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv) |
| 2853 | { |
| 2854 | struct mv88e6xxx_chip *chip = priv; |
| 2855 | |
| 2856 | return mv88e6xxx_devlink_atu_bin_get(chip, |
| 2857 | MV88E6XXX_G2_ATU_STATS_BIN_1); |
| 2858 | } |
| 2859 | |
| 2860 | static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv) |
| 2861 | { |
| 2862 | struct mv88e6xxx_chip *chip = priv; |
| 2863 | |
| 2864 | return mv88e6xxx_devlink_atu_bin_get(chip, |
| 2865 | MV88E6XXX_G2_ATU_STATS_BIN_2); |
| 2866 | } |
| 2867 | |
| 2868 | static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv) |
| 2869 | { |
| 2870 | struct mv88e6xxx_chip *chip = priv; |
| 2871 | |
| 2872 | return mv88e6xxx_devlink_atu_bin_get(chip, |
| 2873 | MV88E6XXX_G2_ATU_STATS_BIN_3); |
| 2874 | } |
| 2875 | |
| 2876 | static u64 mv88e6xxx_devlink_atu_get(void *priv) |
| 2877 | { |
| 2878 | return mv88e6xxx_devlink_atu_bin_0_get(priv) + |
| 2879 | mv88e6xxx_devlink_atu_bin_1_get(priv) + |
| 2880 | mv88e6xxx_devlink_atu_bin_2_get(priv) + |
| 2881 | mv88e6xxx_devlink_atu_bin_3_get(priv); |
| 2882 | } |
| 2883 | |
| 2884 | static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds) |
| 2885 | { |
| 2886 | struct devlink_resource_size_params size_params; |
| 2887 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2888 | int err; |
| 2889 | |
| 2890 | devlink_resource_size_params_init(&size_params, |
| 2891 | mv88e6xxx_num_macs(chip), |
| 2892 | mv88e6xxx_num_macs(chip), |
| 2893 | 1, DEVLINK_RESOURCE_UNIT_ENTRY); |
| 2894 | |
| 2895 | err = dsa_devlink_resource_register(ds, "ATU", |
| 2896 | mv88e6xxx_num_macs(chip), |
| 2897 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2898 | DEVLINK_RESOURCE_ID_PARENT_TOP, |
| 2899 | &size_params); |
| 2900 | if (err) |
| 2901 | goto out; |
| 2902 | |
| 2903 | devlink_resource_size_params_init(&size_params, |
| 2904 | mv88e6xxx_num_macs(chip) / 4, |
| 2905 | mv88e6xxx_num_macs(chip) / 4, |
| 2906 | 1, DEVLINK_RESOURCE_UNIT_ENTRY); |
| 2907 | |
| 2908 | err = dsa_devlink_resource_register(ds, "ATU_bin_0", |
| 2909 | mv88e6xxx_num_macs(chip) / 4, |
| 2910 | MV88E6XXX_RESOURCE_ID_ATU_BIN_0, |
| 2911 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2912 | &size_params); |
| 2913 | if (err) |
| 2914 | goto out; |
| 2915 | |
| 2916 | err = dsa_devlink_resource_register(ds, "ATU_bin_1", |
| 2917 | mv88e6xxx_num_macs(chip) / 4, |
| 2918 | MV88E6XXX_RESOURCE_ID_ATU_BIN_1, |
| 2919 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2920 | &size_params); |
| 2921 | if (err) |
| 2922 | goto out; |
| 2923 | |
| 2924 | err = dsa_devlink_resource_register(ds, "ATU_bin_2", |
| 2925 | mv88e6xxx_num_macs(chip) / 4, |
| 2926 | MV88E6XXX_RESOURCE_ID_ATU_BIN_2, |
| 2927 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2928 | &size_params); |
| 2929 | if (err) |
| 2930 | goto out; |
| 2931 | |
| 2932 | err = dsa_devlink_resource_register(ds, "ATU_bin_3", |
| 2933 | mv88e6xxx_num_macs(chip) / 4, |
| 2934 | MV88E6XXX_RESOURCE_ID_ATU_BIN_3, |
| 2935 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2936 | &size_params); |
| 2937 | if (err) |
| 2938 | goto out; |
| 2939 | |
| 2940 | dsa_devlink_resource_occ_get_register(ds, |
| 2941 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2942 | mv88e6xxx_devlink_atu_get, |
| 2943 | chip); |
| 2944 | |
| 2945 | dsa_devlink_resource_occ_get_register(ds, |
| 2946 | MV88E6XXX_RESOURCE_ID_ATU_BIN_0, |
| 2947 | mv88e6xxx_devlink_atu_bin_0_get, |
| 2948 | chip); |
| 2949 | |
| 2950 | dsa_devlink_resource_occ_get_register(ds, |
| 2951 | MV88E6XXX_RESOURCE_ID_ATU_BIN_1, |
| 2952 | mv88e6xxx_devlink_atu_bin_1_get, |
| 2953 | chip); |
| 2954 | |
| 2955 | dsa_devlink_resource_occ_get_register(ds, |
| 2956 | MV88E6XXX_RESOURCE_ID_ATU_BIN_2, |
| 2957 | mv88e6xxx_devlink_atu_bin_2_get, |
| 2958 | chip); |
| 2959 | |
| 2960 | dsa_devlink_resource_occ_get_register(ds, |
| 2961 | MV88E6XXX_RESOURCE_ID_ATU_BIN_3, |
| 2962 | mv88e6xxx_devlink_atu_bin_3_get, |
| 2963 | chip); |
| 2964 | |
| 2965 | return 0; |
| 2966 | |
| 2967 | out: |
| 2968 | dsa_devlink_resources_unregister(ds); |
| 2969 | return err; |
| 2970 | } |
| 2971 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 2972 | static void mv88e6xxx_teardown(struct dsa_switch *ds) |
| 2973 | { |
| 2974 | mv88e6xxx_teardown_devlink_params(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 2975 | dsa_devlink_resources_unregister(ds); |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 2976 | } |
| 2977 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2978 | static int mv88e6xxx_setup(struct dsa_switch *ds) |
Guenter Roeck | acdaffc | 2015-03-26 18:36:28 -0700 | [diff] [blame] | 2979 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2980 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 2981 | u8 cmode; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2982 | int err; |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 2983 | int i; |
| 2984 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2985 | chip->ds = ds; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 2986 | ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2987 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2988 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2989 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 2990 | if (chip->info->ops->setup_errata) { |
| 2991 | err = chip->info->ops->setup_errata(chip); |
| 2992 | if (err) |
| 2993 | goto unlock; |
| 2994 | } |
| 2995 | |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 2996 | /* Cache the cmode of each port. */ |
| 2997 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
| 2998 | if (chip->info->ops->port_get_cmode) { |
| 2999 | err = chip->info->ops->port_get_cmode(chip, i, &cmode); |
| 3000 | if (err) |
Dan Carpenter | e29129f | 2018-08-14 12:09:05 +0300 | [diff] [blame] | 3001 | goto unlock; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3002 | |
| 3003 | chip->ports[i].cmode = cmode; |
| 3004 | } |
| 3005 | } |
| 3006 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3007 | /* Setup Switch Port Registers */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 3008 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3009 | if (dsa_is_unused_port(ds, i)) |
| 3010 | continue; |
| 3011 | |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3012 | /* Prevent the use of an invalid port. */ |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3013 | if (mv88e6xxx_is_invalid_port(chip, i)) { |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3014 | dev_err(chip->dev, "port %d is invalid\n", i); |
| 3015 | err = -EINVAL; |
| 3016 | goto unlock; |
| 3017 | } |
| 3018 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3019 | err = mv88e6xxx_setup_port(chip, i); |
| 3020 | if (err) |
| 3021 | goto unlock; |
| 3022 | } |
| 3023 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3024 | err = mv88e6xxx_irl_setup(chip); |
| 3025 | if (err) |
| 3026 | goto unlock; |
| 3027 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 3028 | err = mv88e6xxx_mac_setup(chip); |
| 3029 | if (err) |
| 3030 | goto unlock; |
| 3031 | |
Vivien Didelot | 1b17aed | 2017-05-26 18:03:05 -0400 | [diff] [blame] | 3032 | err = mv88e6xxx_phy_setup(chip); |
| 3033 | if (err) |
| 3034 | goto unlock; |
| 3035 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 3036 | err = mv88e6xxx_vtu_setup(chip); |
| 3037 | if (err) |
| 3038 | goto unlock; |
| 3039 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 3040 | err = mv88e6xxx_pvt_setup(chip); |
| 3041 | if (err) |
| 3042 | goto unlock; |
| 3043 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 3044 | err = mv88e6xxx_atu_setup(chip); |
| 3045 | if (err) |
| 3046 | goto unlock; |
| 3047 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 3048 | err = mv88e6xxx_broadcast_setup(chip, 0); |
| 3049 | if (err) |
| 3050 | goto unlock; |
| 3051 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3052 | err = mv88e6xxx_pot_setup(chip); |
| 3053 | if (err) |
| 3054 | goto unlock; |
| 3055 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3056 | err = mv88e6xxx_rmu_setup(chip); |
| 3057 | if (err) |
| 3058 | goto unlock; |
| 3059 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3060 | err = mv88e6xxx_rsvd2cpu_setup(chip); |
| 3061 | if (err) |
| 3062 | goto unlock; |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3063 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 3064 | err = mv88e6xxx_trunk_setup(chip); |
| 3065 | if (err) |
| 3066 | goto unlock; |
| 3067 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 3068 | err = mv88e6xxx_devmap_setup(chip); |
| 3069 | if (err) |
| 3070 | goto unlock; |
| 3071 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3072 | err = mv88e6xxx_pri_setup(chip); |
| 3073 | if (err) |
| 3074 | goto unlock; |
| 3075 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3076 | /* Setup PTP Hardware Clock and timestamping */ |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3077 | if (chip->info->ptp_support) { |
| 3078 | err = mv88e6xxx_ptp_setup(chip); |
| 3079 | if (err) |
| 3080 | goto unlock; |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3081 | |
| 3082 | err = mv88e6xxx_hwtstamp_setup(chip); |
| 3083 | if (err) |
| 3084 | goto unlock; |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3085 | } |
| 3086 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3087 | err = mv88e6xxx_stats_setup(chip); |
| 3088 | if (err) |
| 3089 | goto unlock; |
| 3090 | |
Vivien Didelot | 6b17e86 | 2015-08-13 12:52:18 -0400 | [diff] [blame] | 3091 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3092 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | db687a5 | 2015-06-20 21:31:29 +0200 | [diff] [blame] | 3093 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3094 | if (err) |
| 3095 | return err; |
| 3096 | |
| 3097 | /* Have to be called without holding the register lock, since |
| 3098 | * they take the devlink lock, and we later take the locks in |
| 3099 | * the reverse order when getting/setting parameters or |
| 3100 | * resource occupancy. |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3101 | */ |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3102 | err = mv88e6xxx_setup_devlink_resources(ds); |
| 3103 | if (err) |
| 3104 | return err; |
| 3105 | |
| 3106 | err = mv88e6xxx_setup_devlink_params(ds); |
| 3107 | if (err) |
| 3108 | dsa_devlink_resources_unregister(ds); |
| 3109 | |
| 3110 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3111 | } |
| 3112 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3113 | 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] | 3114 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3115 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3116 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3117 | u16 val; |
| 3118 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3119 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3120 | if (!chip->info->ops->phy_read) |
| 3121 | return -EOPNOTSUPP; |
| 3122 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3123 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3124 | err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3125 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3126 | |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 3127 | if (reg == MII_PHYSID2) { |
Andrew Lunn | ddc49ac | 2018-11-12 18:51:01 +0100 | [diff] [blame] | 3128 | /* Some internal PHYs don't have a model number. */ |
| 3129 | if (chip->info->family != MV88E6XXX_FAMILY_6165) |
| 3130 | /* Then there is the 6165 family. It gets is |
| 3131 | * PHYs correct. But it can also have two |
| 3132 | * SERDES interfaces in the PHY address |
| 3133 | * space. And these don't have a model |
| 3134 | * number. But they are not PHYs, so we don't |
| 3135 | * want to give them something a PHY driver |
| 3136 | * will recognise. |
| 3137 | * |
| 3138 | * Use the mv88e6390 family model number |
| 3139 | * instead, for anything which really could be |
| 3140 | * a PHY, |
| 3141 | */ |
| 3142 | if (!(val & 0x3f0)) |
| 3143 | val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4; |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 3144 | } |
| 3145 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3146 | return err ? err : val; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3147 | } |
| 3148 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3149 | 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] | 3150 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3151 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3152 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3153 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3154 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3155 | if (!chip->info->ops->phy_write) |
| 3156 | return -EOPNOTSUPP; |
| 3157 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3158 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3159 | err = chip->info->ops->phy_write(chip, bus, phy, reg, val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3160 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3161 | |
| 3162 | return err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3163 | } |
| 3164 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3165 | static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3166 | struct device_node *np, |
| 3167 | bool external) |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3168 | { |
| 3169 | static int index; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3170 | struct mv88e6xxx_mdio_bus *mdio_bus; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3171 | struct mii_bus *bus; |
| 3172 | int err; |
| 3173 | |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3174 | if (external) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3175 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3176 | err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3177 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3178 | |
| 3179 | if (err) |
| 3180 | return err; |
| 3181 | } |
| 3182 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3183 | bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus)); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3184 | if (!bus) |
| 3185 | return -ENOMEM; |
| 3186 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3187 | mdio_bus = bus->priv; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3188 | mdio_bus->bus = bus; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3189 | mdio_bus->chip = chip; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3190 | INIT_LIST_HEAD(&mdio_bus->list); |
| 3191 | mdio_bus->external = external; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3192 | |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3193 | if (np) { |
| 3194 | bus->name = np->full_name; |
Rob Herring | f7ce910 | 2017-07-18 16:43:19 -0500 | [diff] [blame] | 3195 | snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3196 | } else { |
| 3197 | bus->name = "mv88e6xxx SMI"; |
| 3198 | snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); |
| 3199 | } |
| 3200 | |
| 3201 | bus->read = mv88e6xxx_mdio_read; |
| 3202 | bus->write = mv88e6xxx_mdio_write; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3203 | bus->parent = chip->dev; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3204 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3205 | if (!external) { |
| 3206 | err = mv88e6xxx_g2_irq_mdio_setup(chip, bus); |
| 3207 | if (err) |
| 3208 | return err; |
| 3209 | } |
| 3210 | |
Florian Fainelli | 00e798c | 2018-05-15 16:56:19 -0700 | [diff] [blame] | 3211 | err = of_mdiobus_register(bus, np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3212 | if (err) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3213 | dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3214 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3215 | return err; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3216 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3217 | |
| 3218 | if (external) |
| 3219 | list_add_tail(&mdio_bus->list, &chip->mdios); |
| 3220 | else |
| 3221 | list_add(&mdio_bus->list, &chip->mdios); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3222 | |
| 3223 | return 0; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3224 | } |
| 3225 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3226 | static const struct of_device_id mv88e6xxx_mdio_external_match[] = { |
| 3227 | { .compatible = "marvell,mv88e6xxx-mdio-external", |
| 3228 | .data = (void *)true }, |
| 3229 | { }, |
| 3230 | }; |
| 3231 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3232 | static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) |
| 3233 | |
| 3234 | { |
| 3235 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 3236 | struct mii_bus *bus; |
| 3237 | |
| 3238 | list_for_each_entry(mdio_bus, &chip->mdios, list) { |
| 3239 | bus = mdio_bus->bus; |
| 3240 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3241 | if (!mdio_bus->external) |
| 3242 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
| 3243 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3244 | mdiobus_unregister(bus); |
| 3245 | } |
| 3246 | } |
| 3247 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3248 | static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, |
| 3249 | struct device_node *np) |
| 3250 | { |
| 3251 | const struct of_device_id *match; |
| 3252 | struct device_node *child; |
| 3253 | int err; |
| 3254 | |
| 3255 | /* Always register one mdio bus for the internal/default mdio |
| 3256 | * bus. This maybe represented in the device tree, but is |
| 3257 | * optional. |
| 3258 | */ |
| 3259 | child = of_get_child_by_name(np, "mdio"); |
| 3260 | err = mv88e6xxx_mdio_register(chip, child, false); |
| 3261 | if (err) |
| 3262 | return err; |
| 3263 | |
| 3264 | /* Walk the device tree, and see if there are any other nodes |
| 3265 | * which say they are compatible with the external mdio |
| 3266 | * bus. |
| 3267 | */ |
| 3268 | for_each_available_child_of_node(np, child) { |
| 3269 | match = of_match_node(mv88e6xxx_mdio_external_match, child); |
| 3270 | if (match) { |
| 3271 | err = mv88e6xxx_mdio_register(chip, child, true); |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3272 | if (err) { |
| 3273 | mv88e6xxx_mdios_unregister(chip); |
Nishka Dasgupta | 78e4204 | 2019-07-23 16:13:07 +0530 | [diff] [blame] | 3274 | of_node_put(child); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3275 | return err; |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3276 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3277 | } |
| 3278 | } |
| 3279 | |
| 3280 | return 0; |
| 3281 | } |
| 3282 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3283 | static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) |
| 3284 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3285 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3286 | |
| 3287 | return chip->eeprom_len; |
| 3288 | } |
| 3289 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3290 | static int mv88e6xxx_get_eeprom(struct dsa_switch *ds, |
| 3291 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3292 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3293 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3294 | int err; |
| 3295 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3296 | if (!chip->info->ops->get_eeprom) |
| 3297 | return -EOPNOTSUPP; |
| 3298 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3299 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3300 | err = chip->info->ops->get_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3301 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3302 | |
| 3303 | if (err) |
| 3304 | return err; |
| 3305 | |
| 3306 | eeprom->magic = 0xc3ec4951; |
| 3307 | |
| 3308 | return 0; |
| 3309 | } |
| 3310 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3311 | static int mv88e6xxx_set_eeprom(struct dsa_switch *ds, |
| 3312 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3313 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3314 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3315 | int err; |
| 3316 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3317 | if (!chip->info->ops->set_eeprom) |
| 3318 | return -EOPNOTSUPP; |
| 3319 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3320 | if (eeprom->magic != 0xc3ec4951) |
| 3321 | return -EINVAL; |
| 3322 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3323 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3324 | err = chip->info->ops->set_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3325 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3326 | |
| 3327 | return err; |
| 3328 | } |
| 3329 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3330 | static const struct mv88e6xxx_ops mv88e6085_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3331 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3332 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3333 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3334 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3335 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3336 | .phy_read = mv88e6185_phy_ppu_read, |
| 3337 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3338 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3339 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3340 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3341 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3342 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3343 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3344 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3345 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3346 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3347 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3348 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3349 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3350 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3351 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3352 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3353 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3354 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3355 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3356 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3357 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3358 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3359 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3360 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3361 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3362 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3363 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3364 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3365 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3366 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3367 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3368 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3369 | }; |
| 3370 | |
| 3371 | static const struct mv88e6xxx_ops mv88e6095_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3372 | /* MV88E6XXX_FAMILY_6095 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3373 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3374 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3375 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3376 | .phy_read = mv88e6185_phy_ppu_read, |
| 3377 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3378 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3379 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3380 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3381 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3382 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3383 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3384 | .port_link_state = mv88e6185_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3385 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3386 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3387 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3388 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3389 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3390 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3391 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3392 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3393 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3394 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3395 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3396 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3397 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3398 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3399 | }; |
| 3400 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3401 | static const struct mv88e6xxx_ops mv88e6097_ops = { |
Stefan Eichenberger | 15da3cc | 2016-11-25 09:41:30 +0100 | [diff] [blame] | 3402 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3403 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3404 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3405 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3406 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3407 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3408 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3409 | .port_set_link = mv88e6xxx_port_set_link, |
| 3410 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3411 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3412 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3413 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3414 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3415 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3416 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3417 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3418 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3419 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3420 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3421 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3422 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3423 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3424 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3425 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3426 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3427 | .stats_get_strings = mv88e6095_stats_get_strings, |
| 3428 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3429 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3430 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Volodymyr Bendiuga | 91eaa47 | 2017-02-14 11:29:30 +0100 | [diff] [blame] | 3431 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3432 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3433 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3434 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3435 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3436 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3437 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3438 | .phylink_validate = mv88e6185_phylink_validate, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3439 | }; |
| 3440 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3441 | static const struct mv88e6xxx_ops mv88e6123_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3442 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3443 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3444 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3445 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3446 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3447 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3448 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3449 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3450 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3451 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3452 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3453 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3454 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3455 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3456 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3457 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3458 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 0ac64c3 | 2017-06-02 23:22:46 +0200 | [diff] [blame] | 3459 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3460 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3461 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3462 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3463 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3464 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3465 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3466 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3467 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3468 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3469 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3470 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3471 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3472 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3473 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3474 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3475 | }; |
| 3476 | |
| 3477 | static const struct mv88e6xxx_ops mv88e6131_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3478 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3479 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3480 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3481 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3482 | .phy_read = mv88e6185_phy_ppu_read, |
| 3483 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3484 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3485 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3486 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3487 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3488 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3489 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3490 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3491 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3492 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3493 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3494 | .port_pause_limit = mv88e6097_port_pause_limit, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 3495 | .port_set_pause = mv88e6185_port_set_pause, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3496 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3497 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3498 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3499 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3500 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3501 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3502 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3503 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3504 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3505 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3506 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3507 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3508 | .ppu_enable = mv88e6185_g1_ppu_enable, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 3509 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3510 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3511 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3512 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3513 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3514 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3515 | }; |
| 3516 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3517 | static const struct mv88e6xxx_ops mv88e6141_ops = { |
| 3518 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3519 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3520 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3521 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3522 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3523 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 3524 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3525 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3526 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3527 | .port_set_link = mv88e6xxx_port_set_link, |
| 3528 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3529 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Marek Behún | 2642234 | 2018-10-13 14:40:31 +0200 | [diff] [blame] | 3530 | .port_set_speed = mv88e6341_port_set_speed, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3531 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3532 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 3533 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 3534 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
| 3535 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3536 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3537 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3538 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3539 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 3540 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3541 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3542 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 3543 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3544 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3545 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3546 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3547 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3548 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 3549 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3550 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3551 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3552 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 3553 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3554 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3555 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3556 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3557 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 3558 | .serdes_power = mv88e6390_serdes_power, |
| 3559 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3560 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3561 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3562 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3563 | .gpio_ops = &mv88e6352_gpio_ops, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 3564 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3565 | }; |
| 3566 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3567 | static const struct mv88e6xxx_ops mv88e6161_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3568 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3569 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3570 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3571 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3572 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3573 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3574 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3575 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3576 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3577 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3578 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3579 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3580 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3581 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3582 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3583 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3584 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3585 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3586 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3587 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3588 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3589 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a6da21b | 2019-03-01 23:43:39 +0100 | [diff] [blame] | 3590 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3591 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3592 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3593 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3594 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3595 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3596 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3597 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3598 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3599 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3600 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3601 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3602 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3603 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3604 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3605 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3606 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3607 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3608 | }; |
| 3609 | |
| 3610 | static const struct mv88e6xxx_ops mv88e6165_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3611 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3612 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3613 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3614 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3615 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | efb3e74 | 2017-01-24 14:53:47 +0100 | [diff] [blame] | 3616 | .phy_read = mv88e6165_phy_read, |
| 3617 | .phy_write = mv88e6165_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3618 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3619 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3620 | .port_set_speed = mv88e6185_port_set_speed, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3621 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3622 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3623 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3624 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3625 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3626 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3627 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3628 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3629 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3630 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3631 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3632 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3633 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3634 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3635 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3636 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3637 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3638 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3639 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3640 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3641 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3642 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3643 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3644 | }; |
| 3645 | |
| 3646 | static const struct mv88e6xxx_ops mv88e6171_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3647 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3648 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3649 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3650 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3651 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3652 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3653 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3654 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3655 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3656 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3657 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3658 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3659 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3660 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3661 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3662 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3663 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3664 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3665 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3666 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3667 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3668 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3669 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3670 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3671 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3672 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3673 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3674 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3675 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3676 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3677 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3678 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3679 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3680 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3681 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3682 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3683 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3684 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3685 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3686 | }; |
| 3687 | |
| 3688 | static const struct mv88e6xxx_ops mv88e6172_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3689 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3690 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3691 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3692 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3693 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3694 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3695 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3696 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3697 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3698 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3699 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3700 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3701 | .port_set_speed = mv88e6352_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3702 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3703 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3704 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3705 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3706 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3707 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3708 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3709 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3710 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3711 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3712 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3713 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3714 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3715 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3716 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3717 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3718 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3719 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3720 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3721 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3722 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3723 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3724 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3725 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3726 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3727 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3728 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3729 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3730 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3731 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3732 | .serdes_power = mv88e6352_serdes_power, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3733 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3734 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3735 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3736 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3737 | }; |
| 3738 | |
| 3739 | static const struct mv88e6xxx_ops mv88e6175_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3740 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3741 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3742 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3743 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3744 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3745 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3746 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3747 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3748 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3749 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3750 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3751 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3752 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3753 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3754 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3755 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3756 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3757 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3758 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3759 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3760 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3761 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3762 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3763 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3764 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3765 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3766 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3767 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3768 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3769 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3770 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3771 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3772 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3773 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3774 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3775 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3776 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3777 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3778 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3779 | }; |
| 3780 | |
| 3781 | static const struct mv88e6xxx_ops mv88e6176_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3782 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3783 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3784 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3785 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3786 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3787 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3788 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3789 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3790 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3791 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3792 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3793 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3794 | .port_set_speed = mv88e6352_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3795 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3796 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3797 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3798 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3799 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3800 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3801 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3802 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3803 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3804 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3805 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3806 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3807 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3808 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3809 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3810 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3811 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3812 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3813 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3814 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3815 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3816 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3817 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3818 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3819 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3820 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3821 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3822 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3823 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3824 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3825 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3826 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3827 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3828 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3829 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3830 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3831 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3832 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3833 | }; |
| 3834 | |
| 3835 | static const struct mv88e6xxx_ops mv88e6185_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3836 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3837 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3838 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3839 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3840 | .phy_read = mv88e6185_phy_ppu_read, |
| 3841 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3842 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 3843 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 3844 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3845 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3846 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3847 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3848 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 3849 | .port_set_pause = mv88e6185_port_set_pause, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3850 | .port_link_state = mv88e6185_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3851 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3852 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3853 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3854 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3855 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3856 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3857 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3858 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3859 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3860 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3861 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 3862 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3863 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3864 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3865 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3866 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3867 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3868 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3869 | }; |
| 3870 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3871 | static const struct mv88e6xxx_ops mv88e6190_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3872 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3873 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3874 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 3875 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3876 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3877 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3878 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3879 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3880 | .port_set_link = mv88e6xxx_port_set_link, |
| 3881 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3882 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 3883 | .port_set_speed = mv88e6390_port_set_speed, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3884 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3885 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3886 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3887 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3888 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3889 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3890 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3891 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3892 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3893 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3894 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 3895 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3896 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 3897 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3898 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3899 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3900 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 3901 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3902 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3903 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 3904 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3905 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3906 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3907 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3908 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3909 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3910 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3911 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 3912 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 3913 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 3914 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3915 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3916 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3917 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 3918 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 3919 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 3920 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 3921 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 3922 | .phylink_validate = mv88e6390_phylink_validate, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3923 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3924 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3925 | }; |
| 3926 | |
| 3927 | static const struct mv88e6xxx_ops mv88e6190x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3928 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3929 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3930 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 3931 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3932 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3933 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3934 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3935 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3936 | .port_set_link = mv88e6xxx_port_set_link, |
| 3937 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3938 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 3939 | .port_set_speed = mv88e6390x_port_set_speed, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3940 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3941 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3942 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3943 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3944 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3945 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3946 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3947 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3948 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3949 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3950 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 3951 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3952 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 3953 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3954 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3955 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3956 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 3957 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3958 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3959 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 3960 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3961 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3962 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3963 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3964 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3965 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3966 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3967 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 3968 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 3969 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 3970 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3971 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3972 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3973 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 3974 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 3975 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 3976 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 3977 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 3978 | .phylink_validate = mv88e6390_phylink_validate, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3979 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3980 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3981 | }; |
| 3982 | |
| 3983 | static const struct mv88e6xxx_ops mv88e6191_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3984 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3985 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3986 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 3987 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3988 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3989 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3990 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3991 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3992 | .port_set_link = mv88e6xxx_port_set_link, |
| 3993 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 3994 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 3995 | .port_set_speed = mv88e6390_port_set_speed, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3996 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3997 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3998 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3999 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4000 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4001 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4002 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4003 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4004 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4005 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4006 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4007 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4008 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4009 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4010 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4011 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4012 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4013 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4014 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4015 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4016 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4017 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4018 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4019 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4020 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4021 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4022 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4023 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4024 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4025 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4026 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4027 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4028 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4029 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4030 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4031 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4032 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4033 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4034 | .avb_ops = &mv88e6390_avb_ops, |
| 4035 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4036 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4037 | }; |
| 4038 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4039 | static const struct mv88e6xxx_ops mv88e6240_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4040 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4041 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4042 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4043 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4044 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4045 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4046 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4047 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4048 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4049 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 4050 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4051 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 4052 | .port_set_speed = mv88e6352_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4053 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4054 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4055 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4056 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4057 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4058 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4059 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4060 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4061 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4062 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4063 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4064 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4065 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4066 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4067 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4068 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4069 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4070 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4071 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4072 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4073 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4074 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4075 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4076 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4077 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4078 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4079 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4080 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4081 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4082 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4083 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4084 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4085 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4086 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4087 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4088 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4089 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4090 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4091 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4092 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4093 | }; |
| 4094 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4095 | static const struct mv88e6xxx_ops mv88e6250_ops = { |
| 4096 | /* MV88E6XXX_FAMILY_6250 */ |
| 4097 | .ieee_pri_map = mv88e6250_g1_ieee_pri_map, |
| 4098 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
| 4099 | .irl_init_all = mv88e6352_g2_irl_init_all, |
| 4100 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4101 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
| 4102 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4103 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4104 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4105 | .port_set_link = mv88e6xxx_port_set_link, |
| 4106 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 4107 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
| 4108 | .port_set_speed = mv88e6250_port_set_speed, |
| 4109 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 4110 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 4111 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
| 4112 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
| 4113 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4114 | .port_pause_limit = mv88e6097_port_pause_limit, |
| 4115 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
| 4116 | .port_link_state = mv88e6250_port_link_state, |
| 4117 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
| 4118 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
| 4119 | .stats_get_sset_count = mv88e6250_stats_get_sset_count, |
| 4120 | .stats_get_strings = mv88e6250_stats_get_strings, |
| 4121 | .stats_get_stats = mv88e6250_stats_get_stats, |
| 4122 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4123 | .set_egress_port = mv88e6095_g1_set_egress_port, |
| 4124 | .watchdog_ops = &mv88e6250_watchdog_ops, |
| 4125 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
| 4126 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4127 | .reset = mv88e6250_g1_reset, |
| 4128 | .vtu_getnext = mv88e6250_g1_vtu_getnext, |
| 4129 | .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 4130 | .avb_ops = &mv88e6352_avb_ops, |
| 4131 | .ptp_ops = &mv88e6250_ptp_ops, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4132 | .phylink_validate = mv88e6065_phylink_validate, |
| 4133 | }; |
| 4134 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4135 | static const struct mv88e6xxx_ops mv88e6290_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4136 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4137 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4138 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4139 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4140 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4141 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4142 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4143 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4144 | .port_set_link = mv88e6xxx_port_set_link, |
| 4145 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 4146 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 4147 | .port_set_speed = mv88e6390_port_set_speed, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4148 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4149 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4150 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4151 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4152 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4153 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4154 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4155 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4156 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4157 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4158 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4159 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4160 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4161 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4162 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4163 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4164 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4165 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4166 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4167 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4168 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4169 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4170 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4171 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4172 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4173 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4174 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4175 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4176 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4177 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4178 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4179 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4180 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4181 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4182 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4183 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4184 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4185 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4186 | .phylink_validate = mv88e6390_phylink_validate, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4187 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4188 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4189 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4190 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4191 | }; |
| 4192 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4193 | static const struct mv88e6xxx_ops mv88e6320_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4194 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4195 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4196 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4197 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4198 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4199 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4200 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4201 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4202 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4203 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 4204 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 4205 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4206 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4207 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4208 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4209 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4210 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4211 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4212 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4213 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4214 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4215 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4216 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4217 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4218 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4219 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4220 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4221 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4222 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4223 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4224 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4225 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4226 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4227 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4228 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4229 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4230 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4231 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4232 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4233 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4234 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4235 | }; |
| 4236 | |
| 4237 | static const struct mv88e6xxx_ops mv88e6321_ops = { |
Vivien Didelot | bd80720 | 2017-07-17 13:03:37 -0400 | [diff] [blame] | 4238 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4239 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4240 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4241 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4242 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4243 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4244 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4245 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4246 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4247 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 4248 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 4249 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4250 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4251 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4252 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4253 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4254 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4255 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4256 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4257 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4258 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4259 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4260 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4261 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4262 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4263 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4264 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4265 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4266 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4267 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4268 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4269 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4270 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4271 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4272 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4273 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4274 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4275 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4276 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4277 | }; |
| 4278 | |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4279 | static const struct mv88e6xxx_ops mv88e6341_ops = { |
| 4280 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4281 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4282 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4283 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4284 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4285 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4286 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4287 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4288 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4289 | .port_set_link = mv88e6xxx_port_set_link, |
| 4290 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 4291 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Marek Behún | 2642234 | 2018-10-13 14:40:31 +0200 | [diff] [blame] | 4292 | .port_set_speed = mv88e6341_port_set_speed, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4293 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4294 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 4295 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 4296 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
| 4297 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4298 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4299 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4300 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4301 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4302 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4303 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4304 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 4305 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4306 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4307 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4308 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4309 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4310 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4311 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4312 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4313 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4314 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4315 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4316 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4317 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4318 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4319 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4320 | .serdes_power = mv88e6390_serdes_power, |
| 4321 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4322 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4323 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4324 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4325 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4326 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4327 | .ptp_ops = &mv88e6352_ptp_ops, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 4328 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4329 | }; |
| 4330 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4331 | static const struct mv88e6xxx_ops mv88e6350_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4332 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4333 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4334 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4335 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4336 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4337 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4338 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4339 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 4340 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4341 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 4342 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4343 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4344 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4345 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4346 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4347 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4348 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4349 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4350 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4351 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4352 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4353 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4354 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4355 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4356 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4357 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4358 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4359 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4360 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4361 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4362 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4363 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4364 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4365 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4366 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4367 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4368 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4369 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4370 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4371 | }; |
| 4372 | |
| 4373 | static const struct mv88e6xxx_ops mv88e6351_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4374 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4375 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4376 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4377 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4378 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4379 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4380 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4381 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 4382 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4383 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 4384 | .port_set_speed = mv88e6185_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4385 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4386 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4387 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4388 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4389 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4390 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4391 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4392 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4393 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4394 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4395 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4396 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4397 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4398 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4399 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4400 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4401 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4402 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4403 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4404 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4405 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4406 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4407 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4408 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4409 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4410 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4411 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4412 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4413 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4414 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4415 | }; |
| 4416 | |
| 4417 | static const struct mv88e6xxx_ops mv88e6352_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4418 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4419 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4420 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4421 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4422 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4423 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4424 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4425 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4426 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4427 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 7f1ae07 | 2016-11-04 03:23:33 +0100 | [diff] [blame] | 4428 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4429 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Vivien Didelot | 96a2b40 | 2016-11-04 03:23:35 +0100 | [diff] [blame] | 4430 | .port_set_speed = mv88e6352_port_set_speed, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4431 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4432 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4433 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4434 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4435 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4436 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4437 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4438 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4439 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4440 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4441 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4442 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4443 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4444 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4445 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4446 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4447 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4448 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4449 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4450 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4451 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4452 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4453 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4454 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4455 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4456 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4457 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4458 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4459 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4460 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4461 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4462 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4463 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4464 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4465 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4466 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4467 | .ptp_ops = &mv88e6352_ptp_ops, |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 4468 | .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, |
| 4469 | .serdes_get_strings = mv88e6352_serdes_get_strings, |
| 4470 | .serdes_get_stats = mv88e6352_serdes_get_stats, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4471 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4472 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4473 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4474 | }; |
| 4475 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4476 | static const struct mv88e6xxx_ops mv88e6390_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4477 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4478 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4479 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4480 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4481 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4482 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4483 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4484 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4485 | .port_set_link = mv88e6xxx_port_set_link, |
| 4486 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 4487 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 4488 | .port_set_speed = mv88e6390_port_set_speed, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4489 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4490 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4491 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4492 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4493 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4494 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4495 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4496 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4497 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4498 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4499 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4500 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4501 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4502 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4503 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4504 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4505 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4506 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4507 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4508 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4509 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4510 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4511 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4512 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4513 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4514 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4515 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4516 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4517 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4518 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4519 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4520 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4521 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4522 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4523 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4524 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4525 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4526 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4527 | .ptp_ops = &mv88e6352_ptp_ops, |
Nikita Yushchenko | 0df9528 | 2019-12-25 08:22:38 +0300 | [diff] [blame] | 4528 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4529 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4530 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4531 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4532 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4533 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4534 | }; |
| 4535 | |
| 4536 | static const struct mv88e6xxx_ops mv88e6390x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4537 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4538 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4539 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4540 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4541 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4542 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4543 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4544 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4545 | .port_set_link = mv88e6xxx_port_set_link, |
| 4546 | .port_set_duplex = mv88e6xxx_port_set_duplex, |
| 4547 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
| 4548 | .port_set_speed = mv88e6390x_port_set_speed, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4549 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4550 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4551 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4552 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4553 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4554 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4555 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4556 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4557 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4558 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4559 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4560 | .port_link_state = mv88e6352_port_link_state, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4561 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | b3dce4d | 2018-11-11 00:32:14 +0100 | [diff] [blame] | 4562 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4563 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4564 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4565 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4566 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4567 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4568 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4569 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4570 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4571 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4572 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4573 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4574 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4575 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4576 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4577 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4578 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4579 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4580 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4581 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4582 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4583 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4584 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4585 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4586 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4587 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4588 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4589 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4590 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4591 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4592 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4593 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4594 | }; |
| 4595 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4596 | static const struct mv88e6xxx_info mv88e6xxx_table[] = { |
| 4597 | [MV88E6085] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4598 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4599 | .family = MV88E6XXX_FAMILY_6097, |
| 4600 | .name = "Marvell 88E6085", |
| 4601 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4602 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4603 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4604 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4605 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4606 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4607 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4608 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4609 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4610 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4611 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4612 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4613 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4614 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4615 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4616 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4617 | .ops = &mv88e6085_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4618 | }, |
| 4619 | |
| 4620 | [MV88E6095] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4621 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4622 | .family = MV88E6XXX_FAMILY_6095, |
| 4623 | .name = "Marvell 88E6095/88E6095F", |
| 4624 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4625 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4626 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4627 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4628 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4629 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4630 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4631 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4632 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4633 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4634 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4635 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4636 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4637 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4638 | .ops = &mv88e6095_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4639 | }, |
| 4640 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4641 | [MV88E6097] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4642 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4643 | .family = MV88E6XXX_FAMILY_6097, |
| 4644 | .name = "Marvell 88E6097/88E6097F", |
| 4645 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4646 | .num_macs = 8192, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4647 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4648 | .num_internal_phys = 8, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4649 | .max_vid = 4095, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4650 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4651 | .phy_base_addr = 0x0, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4652 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4653 | .global2_addr = 0x1c, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4654 | .age_time_coeff = 15000, |
Stefan Eichenberger | c534178 | 2016-11-25 09:41:29 +0100 | [diff] [blame] | 4655 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4656 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4657 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4658 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4659 | .multi_chip = true, |
Stefan Eichenberger | 2bfcfcd | 2016-12-05 14:12:42 +0100 | [diff] [blame] | 4660 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4661 | .ops = &mv88e6097_ops, |
| 4662 | }, |
| 4663 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4664 | [MV88E6123] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4665 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4666 | .family = MV88E6XXX_FAMILY_6165, |
| 4667 | .name = "Marvell 88E6123", |
| 4668 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4669 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4670 | .num_ports = 3, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4671 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4672 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4673 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4674 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4675 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4676 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4677 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4678 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4679 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4680 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4681 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4682 | .multi_chip = true, |
Andrew Lunn | 5ebe31d | 2017-06-07 15:06:19 +0200 | [diff] [blame] | 4683 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4684 | .ops = &mv88e6123_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4685 | }, |
| 4686 | |
| 4687 | [MV88E6131] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4688 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4689 | .family = MV88E6XXX_FAMILY_6185, |
| 4690 | .name = "Marvell 88E6131", |
| 4691 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4692 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4693 | .num_ports = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4694 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4695 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4696 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4697 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4698 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4699 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4700 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4701 | .g1_irqs = 9, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4702 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4703 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4704 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4705 | .ops = &mv88e6131_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4706 | }, |
| 4707 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4708 | [MV88E6141] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4709 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4710 | .family = MV88E6XXX_FAMILY_6341, |
Uwe Kleine-König | 79a68b2 | 2018-03-20 10:44:40 +0100 | [diff] [blame] | 4711 | .name = "Marvell 88E6141", |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4712 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4713 | .num_macs = 2048, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4714 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4715 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4716 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4717 | .max_vid = 4095, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4718 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4719 | .phy_base_addr = 0x10, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4720 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4721 | .global2_addr = 0x1c, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4722 | .age_time_coeff = 3750, |
| 4723 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 4724 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4725 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4726 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4727 | .multi_chip = true, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4728 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4729 | .ops = &mv88e6141_ops, |
| 4730 | }, |
| 4731 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4732 | [MV88E6161] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4733 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4734 | .family = MV88E6XXX_FAMILY_6165, |
| 4735 | .name = "Marvell 88E6161", |
| 4736 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4737 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4738 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4739 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4740 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4741 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4742 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4743 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4744 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4745 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4746 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4747 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4748 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4749 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4750 | .multi_chip = true, |
Andrew Lunn | 5ebe31d | 2017-06-07 15:06:19 +0200 | [diff] [blame] | 4751 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 4752 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4753 | .ops = &mv88e6161_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4754 | }, |
| 4755 | |
| 4756 | [MV88E6165] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4757 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4758 | .family = MV88E6XXX_FAMILY_6165, |
| 4759 | .name = "Marvell 88E6165", |
| 4760 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4761 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4762 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4763 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4764 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4765 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4766 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4767 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4768 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4769 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4770 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4771 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4772 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4773 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4774 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4775 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 4776 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4777 | .ops = &mv88e6165_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4778 | }, |
| 4779 | |
| 4780 | [MV88E6171] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4781 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4782 | .family = MV88E6XXX_FAMILY_6351, |
| 4783 | .name = "Marvell 88E6171", |
| 4784 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4785 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4786 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4787 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4788 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4789 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4790 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4791 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4792 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4793 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4794 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4795 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4796 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4797 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4798 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4799 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4800 | .ops = &mv88e6171_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4801 | }, |
| 4802 | |
| 4803 | [MV88E6172] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4804 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4805 | .family = MV88E6XXX_FAMILY_6352, |
| 4806 | .name = "Marvell 88E6172", |
| 4807 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4808 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4809 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4810 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4811 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4812 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4813 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4814 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4815 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4816 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4817 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4818 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4819 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4820 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4821 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4822 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4823 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4824 | .ops = &mv88e6172_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4825 | }, |
| 4826 | |
| 4827 | [MV88E6175] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4828 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4829 | .family = MV88E6XXX_FAMILY_6351, |
| 4830 | .name = "Marvell 88E6175", |
| 4831 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4832 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4833 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4834 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4835 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4836 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4837 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4838 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4839 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4840 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4841 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4842 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4843 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4844 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4845 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4846 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4847 | .ops = &mv88e6175_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4848 | }, |
| 4849 | |
| 4850 | [MV88E6176] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4851 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4852 | .family = MV88E6XXX_FAMILY_6352, |
| 4853 | .name = "Marvell 88E6176", |
| 4854 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4855 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4856 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4857 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4858 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4859 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4860 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4861 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4862 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4863 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4864 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4865 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4866 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4867 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4868 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4869 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4870 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4871 | .ops = &mv88e6176_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4872 | }, |
| 4873 | |
| 4874 | [MV88E6185] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4875 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4876 | .family = MV88E6XXX_FAMILY_6185, |
| 4877 | .name = "Marvell 88E6185", |
| 4878 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4879 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4880 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4881 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4882 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4883 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4884 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4885 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4886 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4887 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4888 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4889 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4890 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4891 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4892 | .ops = &mv88e6185_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4893 | }, |
| 4894 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4895 | [MV88E6190] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4896 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4897 | .family = MV88E6XXX_FAMILY_6390, |
| 4898 | .name = "Marvell 88E6190", |
| 4899 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4900 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4901 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 4902 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4903 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4904 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4905 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4906 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4907 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4908 | .global2_addr = 0x1c, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4909 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 4910 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4911 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4912 | .g2_irqs = 14, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4913 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4914 | .multi_chip = true, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4915 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4916 | .ops = &mv88e6190_ops, |
| 4917 | }, |
| 4918 | |
| 4919 | [MV88E6190X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4920 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4921 | .family = MV88E6XXX_FAMILY_6390, |
| 4922 | .name = "Marvell 88E6190X", |
| 4923 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4924 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4925 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 4926 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4927 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4928 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4929 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4930 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4931 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4932 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 4933 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4934 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4935 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4936 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4937 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4938 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4939 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4940 | .ops = &mv88e6190x_ops, |
| 4941 | }, |
| 4942 | |
| 4943 | [MV88E6191] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4944 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4945 | .family = MV88E6XXX_FAMILY_6390, |
| 4946 | .name = "Marvell 88E6191", |
| 4947 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4948 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4949 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 4950 | .num_internal_phys = 9, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4951 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4952 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4953 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4954 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4955 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 4956 | .age_time_coeff = 3750, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4957 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4958 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4959 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4960 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4961 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4962 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 4963 | .ptp_support = true, |
Vivien Didelot | 2cf4cefb | 2017-03-28 13:50:34 -0400 | [diff] [blame] | 4964 | .ops = &mv88e6191_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4965 | }, |
| 4966 | |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 4967 | [MV88E6220] = { |
| 4968 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220, |
| 4969 | .family = MV88E6XXX_FAMILY_6250, |
| 4970 | .name = "Marvell 88E6220", |
| 4971 | .num_databases = 64, |
| 4972 | |
| 4973 | /* Ports 2-4 are not routed to pins |
| 4974 | * => usable ports 0, 1, 5, 6 |
| 4975 | */ |
| 4976 | .num_ports = 7, |
| 4977 | .num_internal_phys = 2, |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 4978 | .invalid_port_mask = BIT(2) | BIT(3) | BIT(4), |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 4979 | .max_vid = 4095, |
| 4980 | .port_base_addr = 0x08, |
| 4981 | .phy_base_addr = 0x00, |
| 4982 | .global1_addr = 0x0f, |
| 4983 | .global2_addr = 0x07, |
| 4984 | .age_time_coeff = 15000, |
| 4985 | .g1_irqs = 9, |
| 4986 | .g2_irqs = 10, |
| 4987 | .atu_move_port_mask = 0xf, |
| 4988 | .dual_chip = true, |
| 4989 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 4990 | .ptp_support = true, |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 4991 | .ops = &mv88e6250_ops, |
| 4992 | }, |
| 4993 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4994 | [MV88E6240] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4995 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4996 | .family = MV88E6XXX_FAMILY_6352, |
| 4997 | .name = "Marvell 88E6240", |
| 4998 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4999 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5000 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5001 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5002 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5003 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5004 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5005 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5006 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5007 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5008 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5009 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5010 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5011 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5012 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5013 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5014 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5015 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5016 | .ops = &mv88e6240_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5017 | }, |
| 5018 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5019 | [MV88E6250] = { |
| 5020 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250, |
| 5021 | .family = MV88E6XXX_FAMILY_6250, |
| 5022 | .name = "Marvell 88E6250", |
| 5023 | .num_databases = 64, |
| 5024 | .num_ports = 7, |
| 5025 | .num_internal_phys = 5, |
| 5026 | .max_vid = 4095, |
| 5027 | .port_base_addr = 0x08, |
| 5028 | .phy_base_addr = 0x00, |
| 5029 | .global1_addr = 0x0f, |
| 5030 | .global2_addr = 0x07, |
| 5031 | .age_time_coeff = 15000, |
| 5032 | .g1_irqs = 9, |
| 5033 | .g2_irqs = 10, |
| 5034 | .atu_move_port_mask = 0xf, |
| 5035 | .dual_chip = true, |
| 5036 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5037 | .ptp_support = true, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5038 | .ops = &mv88e6250_ops, |
| 5039 | }, |
| 5040 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5041 | [MV88E6290] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5042 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5043 | .family = MV88E6XXX_FAMILY_6390, |
| 5044 | .name = "Marvell 88E6290", |
| 5045 | .num_databases = 4096, |
| 5046 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5047 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5048 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5049 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5050 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5051 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5052 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5053 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5054 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5055 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5056 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5057 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5058 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5059 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5060 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5061 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5062 | .ops = &mv88e6290_ops, |
| 5063 | }, |
| 5064 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5065 | [MV88E6320] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5066 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5067 | .family = MV88E6XXX_FAMILY_6320, |
| 5068 | .name = "Marvell 88E6320", |
| 5069 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5070 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5071 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5072 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5073 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5074 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5075 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5076 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5077 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5078 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5079 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5080 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5081 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5082 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5083 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5084 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5085 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5086 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5087 | .ops = &mv88e6320_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5088 | }, |
| 5089 | |
| 5090 | [MV88E6321] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5091 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5092 | .family = MV88E6XXX_FAMILY_6320, |
| 5093 | .name = "Marvell 88E6321", |
| 5094 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5095 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5096 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5097 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5098 | .num_gpio = 15, |
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 = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [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 | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5108 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5109 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5110 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5111 | .ops = &mv88e6321_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5112 | }, |
| 5113 | |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5114 | [MV88E6341] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5115 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5116 | .family = MV88E6XXX_FAMILY_6341, |
| 5117 | .name = "Marvell 88E6341", |
| 5118 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5119 | .num_macs = 2048, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5120 | .num_internal_phys = 5, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5121 | .num_ports = 6, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5122 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5123 | .max_vid = 4095, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5124 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5125 | .phy_base_addr = 0x10, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5126 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5127 | .global2_addr = 0x1c, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5128 | .age_time_coeff = 3750, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5129 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5130 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5131 | .g2_irqs = 10, |
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, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5134 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5135 | .ptp_support = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5136 | .ops = &mv88e6341_ops, |
| 5137 | }, |
| 5138 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5139 | [MV88E6350] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5140 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5141 | .family = MV88E6XXX_FAMILY_6351, |
| 5142 | .name = "Marvell 88E6350", |
| 5143 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5144 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5145 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5146 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5147 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5148 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5149 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5150 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5151 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5152 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5153 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5154 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5155 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5156 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5157 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5158 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5159 | .ops = &mv88e6350_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5160 | }, |
| 5161 | |
| 5162 | [MV88E6351] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5163 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5164 | .family = MV88E6XXX_FAMILY_6351, |
| 5165 | .name = "Marvell 88E6351", |
| 5166 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5167 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5168 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5169 | .num_internal_phys = 5, |
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, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5181 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5182 | .ops = &mv88e6351_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5183 | }, |
| 5184 | |
| 5185 | [MV88E6352] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5186 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5187 | .family = MV88E6XXX_FAMILY_6352, |
| 5188 | .name = "Marvell 88E6352", |
| 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, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5193 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5194 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5195 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5196 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5197 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5198 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5199 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5200 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5201 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5202 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5203 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5204 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5205 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5206 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5207 | .ops = &mv88e6352_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5208 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5209 | [MV88E6390] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5210 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5211 | .family = MV88E6XXX_FAMILY_6390, |
| 5212 | .name = "Marvell 88E6390", |
| 5213 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5214 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5215 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5216 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5217 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5218 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5219 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5220 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5221 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5222 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5223 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5224 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5225 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5226 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5227 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5228 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5229 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5230 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5231 | .ops = &mv88e6390_ops, |
| 5232 | }, |
| 5233 | [MV88E6390X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5234 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5235 | .family = MV88E6XXX_FAMILY_6390, |
| 5236 | .name = "Marvell 88E6390X", |
| 5237 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5238 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5239 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5240 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5241 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5242 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5243 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5244 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5245 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5246 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5247 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5248 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5249 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5250 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5251 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5252 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5253 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5254 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5255 | .ops = &mv88e6390x_ops, |
| 5256 | }, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5257 | }; |
| 5258 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5259 | static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num) |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5260 | { |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 5261 | int i; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5262 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5263 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i) |
| 5264 | if (mv88e6xxx_table[i].prod_num == prod_num) |
| 5265 | return &mv88e6xxx_table[i]; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5266 | |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5267 | return NULL; |
| 5268 | } |
| 5269 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5270 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5271 | { |
| 5272 | const struct mv88e6xxx_info *info; |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5273 | unsigned int prod_num, rev; |
| 5274 | u16 id; |
| 5275 | int err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5276 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5277 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5278 | err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5279 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5280 | if (err) |
| 5281 | return err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5282 | |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5283 | prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK; |
| 5284 | rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5285 | |
| 5286 | info = mv88e6xxx_lookup_info(prod_num); |
| 5287 | if (!info) |
| 5288 | return -ENODEV; |
| 5289 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5290 | /* Update the compatible info with the probed one */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5291 | chip->info = info; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5292 | |
Vivien Didelot | ca070c1 | 2016-09-02 14:45:34 -0400 | [diff] [blame] | 5293 | err = mv88e6xxx_g2_require(chip); |
| 5294 | if (err) |
| 5295 | return err; |
| 5296 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5297 | dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n", |
| 5298 | chip->info->prod_num, chip->info->name, rev); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5299 | |
| 5300 | return 0; |
| 5301 | } |
| 5302 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5303 | static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5304 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5305 | struct mv88e6xxx_chip *chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5306 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5307 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
| 5308 | if (!chip) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5309 | return NULL; |
| 5310 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5311 | chip->dev = dev; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5312 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5313 | mutex_init(&chip->reg_lock); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5314 | INIT_LIST_HEAD(&chip->mdios); |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 5315 | idr_init(&chip->policies); |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5316 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5317 | return chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5318 | } |
| 5319 | |
Florian Fainelli | 5ed4e3e | 2017-11-10 15:22:52 -0800 | [diff] [blame] | 5320 | 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] | 5321 | int port, |
| 5322 | enum dsa_tag_protocol m) |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5323 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5324 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 5325 | |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5326 | return chip->info->tag_protocol; |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5327 | } |
| 5328 | |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5329 | static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 3709aad | 2017-11-30 11:23:58 -0500 | [diff] [blame] | 5330 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5331 | { |
| 5332 | /* We don't need any dynamic resource from the kernel (yet), |
| 5333 | * so skip the prepare phase. |
| 5334 | */ |
| 5335 | |
| 5336 | return 0; |
| 5337 | } |
| 5338 | |
| 5339 | static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, |
Vivien Didelot | 3709aad | 2017-11-30 11:23:58 -0500 | [diff] [blame] | 5340 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5341 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5342 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5343 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5344 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5345 | if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, |
Vivien Didelot | 27c0e60 | 2017-06-15 12:14:01 -0400 | [diff] [blame] | 5346 | MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 5347 | dev_err(ds->dev, "p%d: failed to load multicast MAC address\n", |
| 5348 | port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5349 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5350 | } |
| 5351 | |
| 5352 | static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, |
| 5353 | const struct switchdev_obj_port_mdb *mdb) |
| 5354 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5355 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5356 | int err; |
| 5357 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5358 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 5359 | 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] | 5360 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5361 | |
| 5362 | return err; |
| 5363 | } |
| 5364 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5365 | static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port, |
| 5366 | struct dsa_mall_mirror_tc_entry *mirror, |
| 5367 | bool ingress) |
| 5368 | { |
| 5369 | enum mv88e6xxx_egress_direction direction = ingress ? |
| 5370 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5371 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5372 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5373 | bool other_mirrors = false; |
| 5374 | int i; |
| 5375 | int err; |
| 5376 | |
| 5377 | if (!chip->info->ops->set_egress_port) |
| 5378 | return -EOPNOTSUPP; |
| 5379 | |
| 5380 | mutex_lock(&chip->reg_lock); |
| 5381 | if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) != |
| 5382 | mirror->to_local_port) { |
| 5383 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5384 | other_mirrors |= ingress ? |
| 5385 | chip->ports[i].mirror_ingress : |
| 5386 | chip->ports[i].mirror_egress; |
| 5387 | |
| 5388 | /* Can't change egress port when other mirror is active */ |
| 5389 | if (other_mirrors) { |
| 5390 | err = -EBUSY; |
| 5391 | goto out; |
| 5392 | } |
| 5393 | |
| 5394 | err = chip->info->ops->set_egress_port(chip, |
| 5395 | direction, |
| 5396 | mirror->to_local_port); |
| 5397 | if (err) |
| 5398 | goto out; |
| 5399 | } |
| 5400 | |
| 5401 | err = mv88e6xxx_port_set_mirror(chip, port, direction, true); |
| 5402 | out: |
| 5403 | mutex_unlock(&chip->reg_lock); |
| 5404 | |
| 5405 | return err; |
| 5406 | } |
| 5407 | |
| 5408 | static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port, |
| 5409 | struct dsa_mall_mirror_tc_entry *mirror) |
| 5410 | { |
| 5411 | enum mv88e6xxx_egress_direction direction = mirror->ingress ? |
| 5412 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5413 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5414 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5415 | bool other_mirrors = false; |
| 5416 | int i; |
| 5417 | |
| 5418 | mutex_lock(&chip->reg_lock); |
| 5419 | if (mv88e6xxx_port_set_mirror(chip, port, direction, false)) |
| 5420 | dev_err(ds->dev, "p%d: failed to disable mirroring\n", port); |
| 5421 | |
| 5422 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5423 | other_mirrors |= mirror->ingress ? |
| 5424 | chip->ports[i].mirror_ingress : |
| 5425 | chip->ports[i].mirror_egress; |
| 5426 | |
| 5427 | /* Reset egress port when no other mirror is active */ |
| 5428 | if (!other_mirrors) { |
| 5429 | if (chip->info->ops->set_egress_port(chip, |
| 5430 | direction, |
| 5431 | dsa_upstream_port(ds, |
Colin Ian King | 4e4637b | 2019-11-12 13:05:23 +0000 | [diff] [blame] | 5432 | port))) |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5433 | dev_err(ds->dev, "failed to set egress port\n"); |
| 5434 | } |
| 5435 | |
| 5436 | mutex_unlock(&chip->reg_lock); |
| 5437 | } |
| 5438 | |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5439 | static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port, |
| 5440 | bool unicast, bool multicast) |
| 5441 | { |
| 5442 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5443 | int err = -EOPNOTSUPP; |
| 5444 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5445 | mv88e6xxx_reg_lock(chip); |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5446 | if (chip->info->ops->port_set_egress_floods) |
| 5447 | err = chip->info->ops->port_set_egress_floods(chip, port, |
| 5448 | unicast, |
| 5449 | multicast); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5450 | mv88e6xxx_reg_unlock(chip); |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5451 | |
| 5452 | return err; |
| 5453 | } |
| 5454 | |
Florian Fainelli | a82f67a | 2017-01-08 14:52:08 -0800 | [diff] [blame] | 5455 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5456 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5457 | .setup = mv88e6xxx_setup, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 5458 | .teardown = mv88e6xxx_teardown, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 5459 | .phylink_validate = mv88e6xxx_validate, |
| 5460 | .phylink_mac_link_state = mv88e6xxx_link_state, |
| 5461 | .phylink_mac_config = mv88e6xxx_mac_config, |
| 5462 | .phylink_mac_link_down = mv88e6xxx_mac_link_down, |
| 5463 | .phylink_mac_link_up = mv88e6xxx_mac_link_up, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5464 | .get_strings = mv88e6xxx_get_strings, |
| 5465 | .get_ethtool_stats = mv88e6xxx_get_ethtool_stats, |
| 5466 | .get_sset_count = mv88e6xxx_get_sset_count, |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 5467 | .port_enable = mv88e6xxx_port_enable, |
| 5468 | .port_disable = mv88e6xxx_port_disable, |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 5469 | .get_mac_eee = mv88e6xxx_get_mac_eee, |
| 5470 | .set_mac_eee = mv88e6xxx_set_mac_eee, |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 5471 | .get_eeprom_len = mv88e6xxx_get_eeprom_len, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5472 | .get_eeprom = mv88e6xxx_get_eeprom, |
| 5473 | .set_eeprom = mv88e6xxx_set_eeprom, |
| 5474 | .get_regs_len = mv88e6xxx_get_regs_len, |
| 5475 | .get_regs = mv88e6xxx_get_regs, |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 5476 | .get_rxnfc = mv88e6xxx_get_rxnfc, |
| 5477 | .set_rxnfc = mv88e6xxx_set_rxnfc, |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 5478 | .set_ageing_time = mv88e6xxx_set_ageing_time, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5479 | .port_bridge_join = mv88e6xxx_port_bridge_join, |
| 5480 | .port_bridge_leave = mv88e6xxx_port_bridge_leave, |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5481 | .port_egress_floods = mv88e6xxx_port_egress_floods, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5482 | .port_stp_state_set = mv88e6xxx_port_stp_state_set, |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 5483 | .port_fast_age = mv88e6xxx_port_fast_age, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5484 | .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, |
| 5485 | .port_vlan_prepare = mv88e6xxx_port_vlan_prepare, |
| 5486 | .port_vlan_add = mv88e6xxx_port_vlan_add, |
| 5487 | .port_vlan_del = mv88e6xxx_port_vlan_del, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5488 | .port_fdb_add = mv88e6xxx_port_fdb_add, |
| 5489 | .port_fdb_del = mv88e6xxx_port_fdb_del, |
| 5490 | .port_fdb_dump = mv88e6xxx_port_fdb_dump, |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5491 | .port_mdb_prepare = mv88e6xxx_port_mdb_prepare, |
| 5492 | .port_mdb_add = mv88e6xxx_port_mdb_add, |
| 5493 | .port_mdb_del = mv88e6xxx_port_mdb_del, |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5494 | .port_mirror_add = mv88e6xxx_port_mirror_add, |
| 5495 | .port_mirror_del = mv88e6xxx_port_mirror_del, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 5496 | .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join, |
| 5497 | .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave, |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 5498 | .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set, |
| 5499 | .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get, |
| 5500 | .port_txtstamp = mv88e6xxx_port_txtstamp, |
| 5501 | .port_rxtstamp = mv88e6xxx_port_rxtstamp, |
| 5502 | .get_ts_info = mv88e6xxx_get_ts_info, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 5503 | .devlink_param_get = mv88e6xxx_devlink_param_get, |
| 5504 | .devlink_param_set = mv88e6xxx_devlink_param_set, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5505 | }; |
| 5506 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 5507 | static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5508 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5509 | struct device *dev = chip->dev; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5510 | struct dsa_switch *ds; |
| 5511 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 5512 | ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5513 | if (!ds) |
| 5514 | return -ENOMEM; |
| 5515 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 5516 | ds->dev = dev; |
| 5517 | ds->num_ports = mv88e6xxx_num_ports(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5518 | ds->priv = chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5519 | ds->dev = dev; |
Vivien Didelot | 9d490b4 | 2016-08-23 12:38:56 -0400 | [diff] [blame] | 5520 | ds->ops = &mv88e6xxx_switch_ops; |
Vivien Didelot | 9ff74f2 | 2017-03-15 15:53:50 -0400 | [diff] [blame] | 5521 | ds->ageing_time_min = chip->info->age_time_coeff; |
| 5522 | ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5523 | |
| 5524 | dev_set_drvdata(dev, ds); |
| 5525 | |
Vivien Didelot | 23c9ee4 | 2017-05-26 18:12:51 -0400 | [diff] [blame] | 5526 | return dsa_register_switch(ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5527 | } |
| 5528 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5529 | static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5530 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5531 | dsa_unregister_switch(chip->ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5532 | } |
| 5533 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5534 | static const void *pdata_device_get_match_data(struct device *dev) |
| 5535 | { |
| 5536 | const struct of_device_id *matches = dev->driver->of_match_table; |
| 5537 | const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data; |
| 5538 | |
| 5539 | for (; matches->name[0] || matches->type[0] || matches->compatible[0]; |
| 5540 | matches++) { |
| 5541 | if (!strcmp(pdata->compatible, matches->compatible)) |
| 5542 | return matches->data; |
| 5543 | } |
| 5544 | return NULL; |
| 5545 | } |
| 5546 | |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 5547 | /* There is no suspend to RAM support at DSA level yet, the switch configuration |
| 5548 | * would be lost after a power cycle so prevent it to be suspended. |
| 5549 | */ |
| 5550 | static int __maybe_unused mv88e6xxx_suspend(struct device *dev) |
| 5551 | { |
| 5552 | return -EOPNOTSUPP; |
| 5553 | } |
| 5554 | |
| 5555 | static int __maybe_unused mv88e6xxx_resume(struct device *dev) |
| 5556 | { |
| 5557 | return 0; |
| 5558 | } |
| 5559 | |
| 5560 | static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume); |
| 5561 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 5562 | static int mv88e6xxx_probe(struct mdio_device *mdiodev) |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5563 | { |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5564 | struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data; |
David S. Miller | 7ddae24 | 2018-05-20 19:04:24 -0400 | [diff] [blame] | 5565 | const struct mv88e6xxx_info *compat_info = NULL; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5566 | struct device *dev = &mdiodev->dev; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 5567 | struct device_node *np = dev->of_node; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5568 | struct mv88e6xxx_chip *chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5569 | int port; |
Andrew Lunn | 52638f7 | 2016-05-10 23:27:22 +0200 | [diff] [blame] | 5570 | int err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5571 | |
Andrew Lunn | 7bb8c99 | 2018-05-31 00:15:42 +0200 | [diff] [blame] | 5572 | if (!np && !pdata) |
| 5573 | return -EINVAL; |
| 5574 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5575 | if (np) |
| 5576 | compat_info = of_device_get_match_data(dev); |
| 5577 | |
| 5578 | if (pdata) { |
| 5579 | compat_info = pdata_device_get_match_data(dev); |
| 5580 | |
| 5581 | if (!pdata->netdev) |
| 5582 | return -EINVAL; |
| 5583 | |
| 5584 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
| 5585 | if (!(pdata->enabled_ports & (1 << port))) |
| 5586 | continue; |
| 5587 | if (strcmp(pdata->cd.port_names[port], "cpu")) |
| 5588 | continue; |
| 5589 | pdata->cd.netdev[port] = &pdata->netdev->dev; |
| 5590 | break; |
| 5591 | } |
| 5592 | } |
| 5593 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5594 | if (!compat_info) |
| 5595 | return -EINVAL; |
| 5596 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5597 | chip = mv88e6xxx_alloc_chip(dev); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5598 | if (!chip) { |
| 5599 | err = -ENOMEM; |
| 5600 | goto out; |
| 5601 | } |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5602 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5603 | chip->info = compat_info; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5604 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5605 | err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr); |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 5606 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5607 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5608 | |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 5609 | chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5610 | if (IS_ERR(chip->reset)) { |
| 5611 | err = PTR_ERR(chip->reset); |
| 5612 | goto out; |
| 5613 | } |
Baruch Siach | 7b75e49 | 2019-06-27 21:17:39 +0300 | [diff] [blame] | 5614 | if (chip->reset) |
| 5615 | usleep_range(1000, 2000); |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 5616 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5617 | err = mv88e6xxx_detect(chip); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5618 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5619 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5620 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 5621 | mv88e6xxx_phy_init(chip); |
| 5622 | |
Andrew Lunn | 00baabe | 2018-05-19 22:31:35 +0200 | [diff] [blame] | 5623 | if (chip->info->ops->get_eeprom) { |
| 5624 | if (np) |
| 5625 | of_property_read_u32(np, "eeprom-length", |
| 5626 | &chip->eeprom_len); |
| 5627 | else |
| 5628 | chip->eeprom_len = pdata->eeprom_len; |
| 5629 | } |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 5630 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5631 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5632 | err = mv88e6xxx_switch_reset(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5633 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 5634 | if (err) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5635 | goto out; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 5636 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 5637 | if (np) { |
| 5638 | chip->irq = of_irq_get(np, 0); |
| 5639 | if (chip->irq == -EPROBE_DEFER) { |
| 5640 | err = chip->irq; |
| 5641 | goto out; |
| 5642 | } |
Andrew Lunn | 83c0afa | 2016-06-04 21:17:07 +0200 | [diff] [blame] | 5643 | } |
| 5644 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 5645 | if (pdata) |
| 5646 | chip->irq = pdata->irq; |
| 5647 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5648 | /* 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] | 5649 | * the PHYs will link their interrupts to these interrupt |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5650 | * controllers |
| 5651 | */ |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5652 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5653 | if (chip->irq > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5654 | err = mv88e6xxx_g1_irq_setup(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5655 | else |
| 5656 | err = mv88e6xxx_irq_poll_setup(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5657 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5658 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5659 | if (err) |
| 5660 | goto out; |
| 5661 | |
| 5662 | if (chip->info->g2_irqs > 0) { |
| 5663 | err = mv88e6xxx_g2_irq_setup(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5664 | if (err) |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5665 | goto out_g1_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5666 | } |
| 5667 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5668 | err = mv88e6xxx_g1_atu_prob_irq_setup(chip); |
| 5669 | if (err) |
| 5670 | goto out_g2_irq; |
| 5671 | |
| 5672 | err = mv88e6xxx_g1_vtu_prob_irq_setup(chip); |
| 5673 | if (err) |
| 5674 | goto out_g1_atu_prob_irq; |
| 5675 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5676 | err = mv88e6xxx_mdios_register(chip, np); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5677 | if (err) |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 5678 | goto out_g1_vtu_prob_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5679 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 5680 | err = mv88e6xxx_register_switch(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5681 | if (err) |
| 5682 | goto out_mdio; |
| 5683 | |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5684 | return 0; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5685 | |
| 5686 | out_mdio: |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5687 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 5688 | out_g1_vtu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5689 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
Andrew Lunn | 0977644 | 2018-01-14 02:32:44 +0100 | [diff] [blame] | 5690 | out_g1_atu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5691 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5692 | out_g2_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5693 | if (chip->info->g2_irqs > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5694 | mv88e6xxx_g2_irq_free(chip); |
| 5695 | out_g1_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5696 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 5697 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5698 | else |
| 5699 | mv88e6xxx_irq_poll_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5700 | out: |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5701 | if (pdata) |
| 5702 | dev_put(pdata->netdev); |
| 5703 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5704 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5705 | } |
| 5706 | |
| 5707 | static void mv88e6xxx_remove(struct mdio_device *mdiodev) |
| 5708 | { |
| 5709 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5710 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5711 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 5712 | if (chip->info->ptp_support) { |
| 5713 | mv88e6xxx_hwtstamp_free(chip); |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5714 | mv88e6xxx_ptp_free(chip); |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 5715 | } |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5716 | |
Andrew Lunn | 930188c | 2016-08-22 16:01:03 +0200 | [diff] [blame] | 5717 | mv88e6xxx_phy_destroy(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5718 | mv88e6xxx_unregister_switch(chip); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5719 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5720 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 5721 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
| 5722 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
| 5723 | |
| 5724 | if (chip->info->g2_irqs > 0) |
| 5725 | mv88e6xxx_g2_irq_free(chip); |
| 5726 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 5727 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 5728 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 5729 | else |
| 5730 | mv88e6xxx_irq_poll_free(chip); |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5731 | } |
| 5732 | |
| 5733 | static const struct of_device_id mv88e6xxx_of_match[] = { |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5734 | { |
| 5735 | .compatible = "marvell,mv88e6085", |
| 5736 | .data = &mv88e6xxx_table[MV88E6085], |
| 5737 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5738 | { |
| 5739 | .compatible = "marvell,mv88e6190", |
| 5740 | .data = &mv88e6xxx_table[MV88E6190], |
| 5741 | }, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5742 | { |
| 5743 | .compatible = "marvell,mv88e6250", |
| 5744 | .data = &mv88e6xxx_table[MV88E6250], |
| 5745 | }, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5746 | { /* sentinel */ }, |
| 5747 | }; |
| 5748 | |
| 5749 | MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match); |
| 5750 | |
| 5751 | static struct mdio_driver mv88e6xxx_driver = { |
| 5752 | .probe = mv88e6xxx_probe, |
| 5753 | .remove = mv88e6xxx_remove, |
| 5754 | .mdiodrv.driver = { |
| 5755 | .name = "mv88e6085", |
| 5756 | .of_match_table = mv88e6xxx_of_match, |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 5757 | .pm = &mv88e6xxx_pm_ops, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5758 | }, |
| 5759 | }; |
| 5760 | |
Andrew Lunn | 7324d50 | 2019-04-27 19:19:10 +0200 | [diff] [blame] | 5761 | mdio_module_driver(mv88e6xxx_driver); |
Ben Hutchings | 3d825ed | 2011-11-25 14:37:16 +0000 | [diff] [blame] | 5762 | |
| 5763 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 5764 | MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); |
| 5765 | MODULE_LICENSE("GPL"); |