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 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 422 | static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, |
| 423 | int link, int speed, int duplex, int pause, |
| 424 | phy_interface_t mode) |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 425 | { |
| 426 | int err; |
| 427 | |
| 428 | if (!chip->info->ops->port_set_link) |
| 429 | return 0; |
| 430 | |
| 431 | /* 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] | 432 | err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 433 | if (err) |
| 434 | return err; |
| 435 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 436 | if (chip->info->ops->port_set_speed_duplex) { |
| 437 | err = chip->info->ops->port_set_speed_duplex(chip, port, |
| 438 | speed, duplex); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 439 | if (err && err != -EOPNOTSUPP) |
| 440 | goto restore_link; |
| 441 | } |
| 442 | |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 443 | if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode) |
| 444 | mode = chip->info->ops->port_max_speed_mode(port); |
| 445 | |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 446 | if (chip->info->ops->port_set_pause) { |
| 447 | err = chip->info->ops->port_set_pause(chip, port, pause); |
| 448 | if (err) |
| 449 | goto restore_link; |
| 450 | } |
| 451 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 452 | err = mv88e6xxx_port_config_interface(chip, port, mode); |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 453 | restore_link: |
| 454 | if (chip->info->ops->port_set_link(chip, port, link)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 455 | 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] | 456 | |
| 457 | return err; |
| 458 | } |
| 459 | |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 460 | static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port) |
| 461 | { |
| 462 | struct mv88e6xxx_chip *chip = ds->priv; |
| 463 | |
| 464 | return port < chip->info->num_internal_phys; |
| 465 | } |
| 466 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame^] | 467 | static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port) |
| 468 | { |
| 469 | u16 reg; |
| 470 | int err; |
| 471 | |
| 472 | err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, ®); |
| 473 | if (err) { |
| 474 | dev_err(chip->dev, |
| 475 | "p%d: %s: failed to read port status\n", |
| 476 | port, __func__); |
| 477 | return err; |
| 478 | } |
| 479 | |
| 480 | return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT); |
| 481 | } |
| 482 | |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 483 | static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port, |
| 484 | struct phylink_link_state *state) |
| 485 | { |
| 486 | struct mv88e6xxx_chip *chip = ds->priv; |
| 487 | u8 lane; |
| 488 | int err; |
| 489 | |
| 490 | mv88e6xxx_reg_lock(chip); |
| 491 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
| 492 | if (lane && chip->info->ops->serdes_pcs_get_state) |
| 493 | err = chip->info->ops->serdes_pcs_get_state(chip, port, lane, |
| 494 | state); |
| 495 | else |
| 496 | err = -EOPNOTSUPP; |
| 497 | mv88e6xxx_reg_unlock(chip); |
| 498 | |
| 499 | return err; |
| 500 | } |
| 501 | |
| 502 | static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port, |
| 503 | unsigned int mode, |
| 504 | phy_interface_t interface, |
| 505 | const unsigned long *advertise) |
| 506 | { |
| 507 | const struct mv88e6xxx_ops *ops = chip->info->ops; |
| 508 | u8 lane; |
| 509 | |
| 510 | if (ops->serdes_pcs_config) { |
| 511 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
| 512 | if (lane) |
| 513 | return ops->serdes_pcs_config(chip, port, lane, mode, |
| 514 | interface, advertise); |
| 515 | } |
| 516 | |
| 517 | return 0; |
| 518 | } |
| 519 | |
| 520 | static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port) |
| 521 | { |
| 522 | struct mv88e6xxx_chip *chip = ds->priv; |
| 523 | const struct mv88e6xxx_ops *ops; |
| 524 | int err = 0; |
| 525 | u8 lane; |
| 526 | |
| 527 | ops = chip->info->ops; |
| 528 | |
| 529 | if (ops->serdes_pcs_an_restart) { |
| 530 | mv88e6xxx_reg_lock(chip); |
| 531 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
| 532 | if (lane) |
| 533 | err = ops->serdes_pcs_an_restart(chip, port, lane); |
| 534 | mv88e6xxx_reg_unlock(chip); |
| 535 | |
| 536 | if (err) |
| 537 | dev_err(ds->dev, "p%d: failed to restart AN\n", port); |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port, |
| 542 | unsigned int mode, |
| 543 | int speed, int duplex) |
| 544 | { |
| 545 | const struct mv88e6xxx_ops *ops = chip->info->ops; |
| 546 | u8 lane; |
| 547 | |
| 548 | if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) { |
| 549 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
| 550 | if (lane) |
| 551 | return ops->serdes_pcs_link_up(chip, port, lane, |
| 552 | speed, duplex); |
| 553 | } |
| 554 | |
| 555 | return 0; |
| 556 | } |
| 557 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 558 | static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 559 | unsigned long *mask, |
| 560 | struct phylink_link_state *state) |
| 561 | { |
| 562 | if (!phy_interface_mode_is_8023z(state->interface)) { |
| 563 | /* 10M and 100M are only supported in non-802.3z mode */ |
| 564 | phylink_set(mask, 10baseT_Half); |
| 565 | phylink_set(mask, 10baseT_Full); |
| 566 | phylink_set(mask, 100baseT_Half); |
| 567 | phylink_set(mask, 100baseT_Full); |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 572 | unsigned long *mask, |
| 573 | struct phylink_link_state *state) |
| 574 | { |
| 575 | /* FIXME: if the port is in 1000Base-X mode, then it only supports |
| 576 | * 1000M FD speeds. In this case, CMODE will indicate 5. |
| 577 | */ |
| 578 | phylink_set(mask, 1000baseT_Full); |
| 579 | phylink_set(mask, 1000baseX_Full); |
| 580 | |
| 581 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 582 | } |
| 583 | |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 584 | static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 585 | unsigned long *mask, |
| 586 | struct phylink_link_state *state) |
| 587 | { |
| 588 | if (port >= 5) |
| 589 | phylink_set(mask, 2500baseX_Full); |
| 590 | |
| 591 | /* No ethtool bits for 200Mbps */ |
| 592 | phylink_set(mask, 1000baseT_Full); |
| 593 | phylink_set(mask, 1000baseX_Full); |
| 594 | |
| 595 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 596 | } |
| 597 | |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 598 | static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 599 | unsigned long *mask, |
| 600 | struct phylink_link_state *state) |
| 601 | { |
| 602 | /* No ethtool bits for 200Mbps */ |
| 603 | phylink_set(mask, 1000baseT_Full); |
| 604 | phylink_set(mask, 1000baseX_Full); |
| 605 | |
| 606 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 607 | } |
| 608 | |
| 609 | static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 610 | unsigned long *mask, |
| 611 | struct phylink_link_state *state) |
| 612 | { |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 613 | if (port >= 9) { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 614 | phylink_set(mask, 2500baseX_Full); |
Andrew Lunn | ec26016 | 2019-02-08 22:25:44 +0100 | [diff] [blame] | 615 | phylink_set(mask, 2500baseT_Full); |
| 616 | } |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 617 | |
| 618 | /* No ethtool bits for 200Mbps */ |
| 619 | phylink_set(mask, 1000baseT_Full); |
| 620 | phylink_set(mask, 1000baseX_Full); |
| 621 | |
| 622 | mv88e6065_phylink_validate(chip, port, mask, state); |
| 623 | } |
| 624 | |
| 625 | static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port, |
| 626 | unsigned long *mask, |
| 627 | struct phylink_link_state *state) |
| 628 | { |
| 629 | if (port >= 9) { |
| 630 | phylink_set(mask, 10000baseT_Full); |
| 631 | phylink_set(mask, 10000baseKR_Full); |
| 632 | } |
| 633 | |
| 634 | mv88e6390_phylink_validate(chip, port, mask, state); |
| 635 | } |
| 636 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 637 | static void mv88e6xxx_validate(struct dsa_switch *ds, int port, |
| 638 | unsigned long *supported, |
| 639 | struct phylink_link_state *state) |
| 640 | { |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 641 | __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; |
| 642 | struct mv88e6xxx_chip *chip = ds->priv; |
| 643 | |
| 644 | /* Allow all the expected bits */ |
| 645 | phylink_set(mask, Autoneg); |
| 646 | phylink_set(mask, Pause); |
| 647 | phylink_set_port_modes(mask); |
| 648 | |
| 649 | if (chip->info->ops->phylink_validate) |
| 650 | chip->info->ops->phylink_validate(chip, port, mask, state); |
| 651 | |
| 652 | bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 653 | bitmap_and(state->advertising, state->advertising, mask, |
| 654 | __ETHTOOL_LINK_MODE_MASK_NBITS); |
| 655 | |
| 656 | /* We can only operate at 2500BaseX or 1000BaseX. If requested |
| 657 | * to advertise both, only report advertising at 2500BaseX. |
| 658 | */ |
| 659 | phylink_helper_basex_speed(state); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 660 | } |
| 661 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 662 | static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, |
| 663 | unsigned int mode, |
| 664 | const struct phylink_link_state *state) |
| 665 | { |
| 666 | struct mv88e6xxx_chip *chip = ds->priv; |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 667 | int err; |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 668 | |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 669 | /* FIXME: is this the correct test? If we're in fixed mode on an |
| 670 | * internal port, why should we process this any different from |
| 671 | * PHY mode? On the other hand, the port may be automedia between |
| 672 | * an internal PHY and the serdes... |
| 673 | */ |
Marek Vasut | d700ec4 | 2018-09-12 00:15:24 +0200 | [diff] [blame] | 674 | if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port)) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 675 | return; |
| 676 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 677 | mv88e6xxx_reg_lock(chip); |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 678 | /* FIXME: should we force the link down here - but if we do, how |
| 679 | * do we restore the link force/unforce state? The driver layering |
| 680 | * gets in the way. |
| 681 | */ |
| 682 | err = mv88e6xxx_port_config_interface(chip, port, state->interface); |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 683 | if (err && err != -EOPNOTSUPP) |
| 684 | goto err_unlock; |
| 685 | |
| 686 | err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface, |
| 687 | state->advertising); |
| 688 | /* FIXME: we should restart negotiation if something changed - which |
| 689 | * is something we get if we convert to using phylinks PCS operations. |
| 690 | */ |
| 691 | if (err > 0) |
| 692 | err = 0; |
| 693 | |
| 694 | err_unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 695 | mv88e6xxx_reg_unlock(chip); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 696 | |
| 697 | if (err && err != -EOPNOTSUPP) |
Russell King | 64d47d5 | 2020-03-14 10:15:38 +0000 | [diff] [blame] | 698 | 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] | 699 | } |
| 700 | |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 701 | static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port, |
| 702 | unsigned int mode, |
| 703 | phy_interface_t interface) |
| 704 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 705 | struct mv88e6xxx_chip *chip = ds->priv; |
| 706 | const struct mv88e6xxx_ops *ops; |
| 707 | int err = 0; |
| 708 | |
| 709 | ops = chip->info->ops; |
| 710 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame^] | 711 | mv88e6xxx_reg_lock(chip); |
| 712 | if (!mv88e6xxx_port_ppu_updates(chip, port) && ops->port_set_link) |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 713 | err = ops->port_set_link(chip, port, LINK_FORCED_DOWN); |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame^] | 714 | mv88e6xxx_reg_unlock(chip); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 715 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame^] | 716 | if (err) |
| 717 | dev_err(chip->dev, |
| 718 | "p%d: failed to force MAC link down\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port, |
| 722 | unsigned int mode, phy_interface_t interface, |
Russell King | 5b502a7 | 2020-02-26 10:23:46 +0000 | [diff] [blame] | 723 | struct phy_device *phydev, |
| 724 | int speed, int duplex, |
| 725 | bool tx_pause, bool rx_pause) |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 726 | { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 727 | struct mv88e6xxx_chip *chip = ds->priv; |
| 728 | const struct mv88e6xxx_ops *ops; |
| 729 | int err = 0; |
| 730 | |
| 731 | ops = chip->info->ops; |
| 732 | |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame^] | 733 | mv88e6xxx_reg_lock(chip); |
| 734 | if (!mv88e6xxx_port_ppu_updates(chip, port)) { |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 735 | /* FIXME: for an automedia port, should we force the link |
| 736 | * down here - what if the link comes up due to "other" media |
| 737 | * while we're bringing the port up, how is the exclusivity |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 738 | * handled in the Marvell hardware? E.g. port 2 on 88E6390 |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 739 | * shared between internal PHY and Serdes. |
| 740 | */ |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 741 | err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed, |
| 742 | duplex); |
| 743 | if (err) |
| 744 | goto error; |
| 745 | |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 746 | if (ops->port_set_speed_duplex) { |
| 747 | err = ops->port_set_speed_duplex(chip, port, |
| 748 | speed, duplex); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 749 | if (err && err != -EOPNOTSUPP) |
| 750 | goto error; |
| 751 | } |
| 752 | |
| 753 | if (ops->port_set_link) |
| 754 | err = ops->port_set_link(chip, port, LINK_FORCED_UP); |
Russell King | 30c4a5b | 2020-02-26 10:23:51 +0000 | [diff] [blame] | 755 | } |
Russell King | 5d5b231 | 2020-03-14 10:16:03 +0000 | [diff] [blame^] | 756 | error: |
| 757 | mv88e6xxx_reg_unlock(chip); |
| 758 | |
| 759 | if (err && err != -EOPNOTSUPP) |
| 760 | dev_err(ds->dev, |
| 761 | "p%d: failed to configure MAC link up\n", port); |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 762 | } |
| 763 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 764 | static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 765 | { |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 766 | if (!chip->info->ops->stats_snapshot) |
| 767 | return -EOPNOTSUPP; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 768 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 769 | return chip->info->ops->stats_snapshot(chip, port); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 770 | } |
| 771 | |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 772 | static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 773 | { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, }, |
| 774 | { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, }, |
| 775 | { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, }, |
| 776 | { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, }, |
| 777 | { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, }, |
| 778 | { "in_pause", 4, 0x16, STATS_TYPE_BANK0, }, |
| 779 | { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, }, |
| 780 | { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, }, |
| 781 | { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, }, |
| 782 | { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, }, |
| 783 | { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, }, |
| 784 | { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, }, |
| 785 | { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, }, |
| 786 | { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, }, |
| 787 | { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, }, |
| 788 | { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, }, |
| 789 | { "out_pause", 4, 0x15, STATS_TYPE_BANK0, }, |
| 790 | { "excessive", 4, 0x11, STATS_TYPE_BANK0, }, |
| 791 | { "collisions", 4, 0x1e, STATS_TYPE_BANK0, }, |
| 792 | { "deferred", 4, 0x05, STATS_TYPE_BANK0, }, |
| 793 | { "single", 4, 0x14, STATS_TYPE_BANK0, }, |
| 794 | { "multiple", 4, 0x17, STATS_TYPE_BANK0, }, |
| 795 | { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, }, |
| 796 | { "late", 4, 0x1f, STATS_TYPE_BANK0, }, |
| 797 | { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, }, |
| 798 | { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, }, |
| 799 | { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, }, |
| 800 | { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, }, |
| 801 | { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, }, |
| 802 | { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, }, |
| 803 | { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, }, |
| 804 | { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, }, |
| 805 | { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, }, |
| 806 | { "in_discards", 4, 0x00, STATS_TYPE_BANK1, }, |
| 807 | { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, }, |
| 808 | { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, }, |
| 809 | { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, }, |
| 810 | { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, }, |
| 811 | { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, }, |
| 812 | { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, }, |
| 813 | { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, }, |
| 814 | { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, }, |
| 815 | { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, }, |
| 816 | { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, }, |
| 817 | { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, }, |
| 818 | { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, }, |
| 819 | { "in_management", 4, 0x0f, STATS_TYPE_BANK1, }, |
| 820 | { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, }, |
| 821 | { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, }, |
| 822 | { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, }, |
| 823 | { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, }, |
| 824 | { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, }, |
| 825 | { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, }, |
| 826 | { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, }, |
| 827 | { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, }, |
| 828 | { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, }, |
| 829 | { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, }, |
| 830 | { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, }, |
| 831 | { "out_management", 4, 0x1f, STATS_TYPE_BANK1, }, |
Andrew Lunn | e413e7e | 2015-04-02 04:06:38 +0200 | [diff] [blame] | 832 | }; |
| 833 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 834 | static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip, |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 835 | struct mv88e6xxx_hw_stat *s, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 836 | int port, u16 bank1_select, |
| 837 | u16 histogram) |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 838 | { |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 839 | u32 low; |
| 840 | u32 high = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 841 | u16 reg = 0; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 842 | int err; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 843 | u64 value; |
| 844 | |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 845 | switch (s->type) { |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 846 | case STATS_TYPE_PORT: |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 847 | err = mv88e6xxx_port_read(chip, port, s->reg, ®); |
| 848 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 849 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 850 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 851 | low = reg; |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 852 | if (s->size == 4) { |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 853 | err = mv88e6xxx_port_read(chip, port, s->reg + 1, ®); |
| 854 | if (err) |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 855 | return U64_MAX; |
Rasmus Villemoes | 84b3fd1 | 2019-05-29 07:02:11 +0000 | [diff] [blame] | 856 | low |= ((u32)reg) << 16; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 857 | } |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 858 | break; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 859 | case STATS_TYPE_BANK1: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 860 | reg = bank1_select; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 861 | /* fall through */ |
| 862 | case STATS_TYPE_BANK0: |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 863 | reg |= s->reg | histogram; |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 864 | mv88e6xxx_g1_stats_read(chip, reg, &low); |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 865 | if (s->size == 8) |
Andrew Lunn | 7f9ef3a | 2016-11-21 23:27:05 +0100 | [diff] [blame] | 866 | mv88e6xxx_g1_stats_read(chip, reg + 1, &high); |
Gustavo A. R. Silva | 9fc3e4d | 2017-05-11 22:11:29 -0500 | [diff] [blame] | 867 | break; |
| 868 | default: |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 869 | return U64_MAX; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 870 | } |
Andrew Lunn | 6e46e2d | 2019-02-28 18:14:03 +0100 | [diff] [blame] | 871 | value = (((u64)high) << 32) | low; |
Andrew Lunn | 80c4627 | 2015-06-20 18:42:30 +0200 | [diff] [blame] | 872 | return value; |
| 873 | } |
| 874 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 875 | static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 876 | uint8_t *data, int types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 877 | { |
| 878 | struct mv88e6xxx_hw_stat *stat; |
| 879 | int i, j; |
| 880 | |
| 881 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 882 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 883 | if (stat->type & types) { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 884 | memcpy(data + j * ETH_GSTRING_LEN, stat->string, |
| 885 | ETH_GSTRING_LEN); |
| 886 | j++; |
| 887 | } |
| 888 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 889 | |
| 890 | return j; |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 891 | } |
| 892 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 893 | static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 894 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 895 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 896 | return mv88e6xxx_stats_get_strings(chip, data, |
| 897 | STATS_TYPE_BANK0 | STATS_TYPE_PORT); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 898 | } |
| 899 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 900 | static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 901 | uint8_t *data) |
| 902 | { |
| 903 | return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0); |
| 904 | } |
| 905 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 906 | static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip, |
| 907 | uint8_t *data) |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 908 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 909 | return mv88e6xxx_stats_get_strings(chip, data, |
| 910 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 911 | } |
| 912 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 913 | static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = { |
| 914 | "atu_member_violation", |
| 915 | "atu_miss_violation", |
| 916 | "atu_full_violation", |
| 917 | "vtu_member_violation", |
| 918 | "vtu_miss_violation", |
| 919 | }; |
| 920 | |
| 921 | static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data) |
| 922 | { |
| 923 | unsigned int i; |
| 924 | |
| 925 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++) |
| 926 | strlcpy(data + i * ETH_GSTRING_LEN, |
| 927 | mv88e6xxx_atu_vtu_stats_strings[i], |
| 928 | ETH_GSTRING_LEN); |
| 929 | } |
| 930 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 931 | static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port, |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 932 | u32 stringset, uint8_t *data) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 933 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 934 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 935 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 936 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 937 | if (stringset != ETH_SS_STATS) |
| 938 | return; |
| 939 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 940 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 941 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 942 | if (chip->info->ops->stats_get_strings) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 943 | count = chip->info->ops->stats_get_strings(chip, data); |
| 944 | |
| 945 | if (chip->info->ops->serdes_get_strings) { |
| 946 | data += count * ETH_GSTRING_LEN; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 947 | count = chip->info->ops->serdes_get_strings(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 948 | } |
Andrew Lunn | c6c8cd5 | 2018-03-01 02:02:28 +0100 | [diff] [blame] | 949 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 950 | data += count * ETH_GSTRING_LEN; |
| 951 | mv88e6xxx_atu_vtu_get_strings(data); |
| 952 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 953 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 954 | } |
| 955 | |
| 956 | static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip, |
| 957 | int types) |
| 958 | { |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 959 | struct mv88e6xxx_hw_stat *stat; |
| 960 | int i, j; |
| 961 | |
| 962 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 963 | stat = &mv88e6xxx_hw_stats[i]; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 964 | if (stat->type & types) |
Andrew Lunn | f5e2ed0 | 2015-12-23 13:23:17 +0100 | [diff] [blame] | 965 | j++; |
| 966 | } |
| 967 | return j; |
| 968 | } |
| 969 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 970 | static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 971 | { |
| 972 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 973 | STATS_TYPE_PORT); |
| 974 | } |
| 975 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 976 | static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 977 | { |
| 978 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0); |
| 979 | } |
| 980 | |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 981 | static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip) |
| 982 | { |
| 983 | return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 | |
| 984 | STATS_TYPE_BANK1); |
| 985 | } |
| 986 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 987 | 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] | 988 | { |
| 989 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 990 | int serdes_count = 0; |
| 991 | int count = 0; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 992 | |
Florian Fainelli | 89f0904 | 2018-04-25 12:12:50 -0700 | [diff] [blame] | 993 | if (sset != ETH_SS_STATS) |
| 994 | return 0; |
| 995 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 996 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 997 | if (chip->info->ops->stats_get_sset_count) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 998 | count = chip->info->ops->stats_get_sset_count(chip); |
| 999 | if (count < 0) |
| 1000 | goto out; |
| 1001 | |
| 1002 | if (chip->info->ops->serdes_get_sset_count) |
| 1003 | serdes_count = chip->info->ops->serdes_get_sset_count(chip, |
| 1004 | port); |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1005 | if (serdes_count < 0) { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1006 | count = serdes_count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1007 | goto out; |
| 1008 | } |
| 1009 | count += serdes_count; |
| 1010 | count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); |
| 1011 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1012 | out: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1013 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1014 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1015 | return count; |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 1016 | } |
| 1017 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1018 | static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1019 | uint64_t *data, int types, |
| 1020 | u16 bank1_select, u16 histogram) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1021 | { |
| 1022 | struct mv88e6xxx_hw_stat *stat; |
| 1023 | int i, j; |
| 1024 | |
| 1025 | for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { |
| 1026 | stat = &mv88e6xxx_hw_stats[i]; |
| 1027 | if (stat->type & types) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1028 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1029 | data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, |
| 1030 | bank1_select, |
| 1031 | histogram); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1032 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1033 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1034 | j++; |
| 1035 | } |
| 1036 | } |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1037 | return j; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1038 | } |
| 1039 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1040 | static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1041 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1042 | { |
| 1043 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1044 | STATS_TYPE_BANK0 | STATS_TYPE_PORT, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1045 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1046 | } |
| 1047 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 1048 | static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1049 | uint64_t *data) |
| 1050 | { |
| 1051 | return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0, |
| 1052 | 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
| 1053 | } |
| 1054 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1055 | static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1056 | uint64_t *data) |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1057 | { |
| 1058 | return mv88e6xxx_stats_get_stats(chip, port, data, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1059 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1060 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9, |
| 1061 | MV88E6XXX_G1_STATS_OP_HIST_RX_TX); |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1062 | } |
| 1063 | |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1064 | static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1065 | uint64_t *data) |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 1066 | { |
| 1067 | return mv88e6xxx_stats_get_stats(chip, port, data, |
| 1068 | STATS_TYPE_BANK0 | STATS_TYPE_BANK1, |
Vivien Didelot | 57d1ef3 | 2017-06-15 12:14:05 -0400 | [diff] [blame] | 1069 | MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10, |
| 1070 | 0); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1071 | } |
| 1072 | |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1073 | static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1074 | uint64_t *data) |
| 1075 | { |
| 1076 | *data++ = chip->ports[port].atu_member_violation; |
| 1077 | *data++ = chip->ports[port].atu_miss_violation; |
| 1078 | *data++ = chip->ports[port].atu_full_violation; |
| 1079 | *data++ = chip->ports[port].vtu_member_violation; |
| 1080 | *data++ = chip->ports[port].vtu_miss_violation; |
| 1081 | } |
| 1082 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1083 | static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port, |
| 1084 | uint64_t *data) |
| 1085 | { |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1086 | int count = 0; |
| 1087 | |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1088 | if (chip->info->ops->stats_get_stats) |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1089 | count = chip->info->ops->stats_get_stats(chip, port, data); |
| 1090 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1091 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1092 | if (chip->info->ops->serdes_get_stats) { |
| 1093 | data += count; |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1094 | count = chip->info->ops->serdes_get_stats(chip, port, data); |
Andrew Lunn | 436fe17 | 2018-03-01 02:02:29 +0100 | [diff] [blame] | 1095 | } |
Andrew Lunn | 65f60e4 | 2018-03-28 23:50:28 +0200 | [diff] [blame] | 1096 | data += count; |
| 1097 | mv88e6xxx_atu_vtu_get_stats(chip, port, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1098 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1099 | } |
| 1100 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1101 | static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, |
| 1102 | uint64_t *data) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1103 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1104 | struct mv88e6xxx_chip *chip = ds->priv; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1105 | int ret; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1106 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1107 | mv88e6xxx_reg_lock(chip); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1108 | |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 1109 | ret = mv88e6xxx_stats_snapshot(chip, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1110 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 377cda1 | 2018-02-15 14:38:34 +0100 | [diff] [blame] | 1111 | |
| 1112 | if (ret < 0) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1113 | return; |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 1114 | |
| 1115 | mv88e6xxx_get_stats(chip, port, data); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1116 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1117 | } |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 1118 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1119 | static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1120 | { |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1121 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1122 | int len; |
| 1123 | |
| 1124 | len = 32 * sizeof(u16); |
| 1125 | if (chip->info->ops->serdes_get_regs_len) |
| 1126 | len += chip->info->ops->serdes_get_regs_len(chip, port); |
| 1127 | |
| 1128 | return len; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1129 | } |
| 1130 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1131 | static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, |
| 1132 | struct ethtool_regs *regs, void *_p) |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1133 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1134 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1135 | int err; |
| 1136 | u16 reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1137 | u16 *p = _p; |
| 1138 | int i; |
| 1139 | |
Vivien Didelot | a5f3932 | 2018-12-17 16:05:21 -0500 | [diff] [blame] | 1140 | regs->version = chip->info->prod_num; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1141 | |
| 1142 | memset(p, 0xff, 32 * sizeof(u16)); |
| 1143 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1144 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1145 | |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1146 | for (i = 0; i < 32; i++) { |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1147 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1148 | err = mv88e6xxx_port_read(chip, port, i, ®); |
| 1149 | if (!err) |
| 1150 | p[i] = reg; |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1151 | } |
Vivien Didelot | 2306251 | 2016-05-09 13:22:45 -0400 | [diff] [blame] | 1152 | |
Andrew Lunn | 0d30bbd | 2020-02-16 18:54:13 +0100 | [diff] [blame] | 1153 | if (chip->info->ops->serdes_get_regs) |
| 1154 | chip->info->ops->serdes_get_regs(chip, port, &p[i]); |
| 1155 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1156 | mv88e6xxx_reg_unlock(chip); |
Guenter Roeck | a1ab91f | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 1157 | } |
| 1158 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1159 | static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port, |
| 1160 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1161 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1162 | /* Nothing to do on the port's MAC */ |
| 1163 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1164 | } |
| 1165 | |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 1166 | static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port, |
| 1167 | struct ethtool_eee *e) |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1168 | { |
Vivien Didelot | 5480db6 | 2017-08-01 16:32:40 -0400 | [diff] [blame] | 1169 | /* Nothing to do on the port's MAC */ |
| 1170 | return 0; |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 1171 | } |
| 1172 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1173 | /* 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] | 1174 | 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] | 1175 | { |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1176 | struct dsa_switch *ds = chip->ds; |
| 1177 | struct dsa_switch_tree *dst = ds->dst; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1178 | struct net_device *br; |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1179 | struct dsa_port *dp; |
| 1180 | bool found = false; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1181 | u16 pvlan; |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1182 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1183 | list_for_each_entry(dp, &dst->ports, list) { |
| 1184 | if (dp->ds->index == dev && dp->index == port) { |
| 1185 | found = true; |
| 1186 | break; |
| 1187 | } |
| 1188 | } |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1189 | |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1190 | /* Prevent frames from unknown switch or port */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1191 | if (!found) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1192 | return 0; |
| 1193 | |
| 1194 | /* Frames from DSA links and CPU ports can egress any local port */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1195 | 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] | 1196 | return mv88e6xxx_port_mask(chip); |
| 1197 | |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1198 | br = dp->bridge_dev; |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1199 | pvlan = 0; |
| 1200 | |
| 1201 | /* Frames from user ports can egress any local DSA links and CPU ports, |
| 1202 | * as well as any local member of their bridge group. |
| 1203 | */ |
Vivien Didelot | 9dc8b13 | 2019-10-21 16:51:26 -0400 | [diff] [blame] | 1204 | list_for_each_entry(dp, &dst->ports, list) |
| 1205 | if (dp->ds == ds && |
| 1206 | (dp->type == DSA_PORT_TYPE_CPU || |
| 1207 | dp->type == DSA_PORT_TYPE_DSA || |
| 1208 | (br && dp->bridge_dev == br))) |
| 1209 | pvlan |= BIT(dp->index); |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1210 | |
| 1211 | return pvlan; |
| 1212 | } |
| 1213 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 1214 | static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port) |
Vivien Didelot | e5887a2 | 2017-03-30 17:37:11 -0400 | [diff] [blame] | 1215 | { |
| 1216 | u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port); |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 1217 | |
| 1218 | /* prevent frames from going back out of the port they came in on */ |
| 1219 | output_ports &= ~BIT(port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1220 | |
Vivien Didelot | 5a7921f | 2016-11-04 03:23:28 +0100 | [diff] [blame] | 1221 | return mv88e6xxx_port_set_vlan_map(chip, port, output_ports); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1222 | } |
| 1223 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1224 | static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port, |
| 1225 | u8 state) |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1226 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1227 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1228 | int err; |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1229 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1230 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 1231 | err = mv88e6xxx_port_set_state(chip, port, state); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1232 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 553eb54 | 2016-05-13 20:38:23 -0400 | [diff] [blame] | 1233 | |
| 1234 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1235 | dev_err(ds->dev, "p%d: failed to update state\n", port); |
Guenter Roeck | facd95b | 2015-03-26 18:36:35 -0700 | [diff] [blame] | 1236 | } |
| 1237 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 1238 | static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip) |
| 1239 | { |
| 1240 | int err; |
| 1241 | |
| 1242 | if (chip->info->ops->ieee_pri_map) { |
| 1243 | err = chip->info->ops->ieee_pri_map(chip); |
| 1244 | if (err) |
| 1245 | return err; |
| 1246 | } |
| 1247 | |
| 1248 | if (chip->info->ops->ip_pri_map) { |
| 1249 | err = chip->info->ops->ip_pri_map(chip); |
| 1250 | if (err) |
| 1251 | return err; |
| 1252 | } |
| 1253 | |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1257 | static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip) |
| 1258 | { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1259 | struct dsa_switch *ds = chip->ds; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1260 | int target, port; |
| 1261 | int err; |
| 1262 | |
| 1263 | if (!chip->info->global2_addr) |
| 1264 | return 0; |
| 1265 | |
| 1266 | /* Initialize the routing port to the 32 possible target devices */ |
| 1267 | for (target = 0; target < 32; target++) { |
Vivien Didelot | c5f5176 | 2019-10-30 22:09:13 -0400 | [diff] [blame] | 1268 | port = dsa_routing_port(ds, target); |
| 1269 | if (port == ds->num_ports) |
| 1270 | port = 0x1f; |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1271 | |
| 1272 | err = mv88e6xxx_g2_device_mapping_write(chip, target, port); |
| 1273 | if (err) |
| 1274 | return err; |
| 1275 | } |
| 1276 | |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 1277 | if (chip->info->ops->set_cascade_port) { |
| 1278 | port = MV88E6XXX_CASCADE_PORT_MULTIPLE; |
| 1279 | err = chip->info->ops->set_cascade_port(chip, port); |
| 1280 | if (err) |
| 1281 | return err; |
| 1282 | } |
| 1283 | |
Vivien Didelot | 23c9891 | 2018-05-09 11:38:50 -0400 | [diff] [blame] | 1284 | err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index); |
| 1285 | if (err) |
| 1286 | return err; |
| 1287 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 1288 | return 0; |
| 1289 | } |
| 1290 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 1291 | static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip) |
| 1292 | { |
| 1293 | /* Clear all trunk masks and mapping */ |
| 1294 | if (chip->info->global2_addr) |
| 1295 | return mv88e6xxx_g2_trunk_clear(chip); |
| 1296 | |
| 1297 | return 0; |
| 1298 | } |
| 1299 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 1300 | static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip) |
| 1301 | { |
| 1302 | if (chip->info->ops->rmu_disable) |
| 1303 | return chip->info->ops->rmu_disable(chip); |
| 1304 | |
| 1305 | return 0; |
| 1306 | } |
| 1307 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 1308 | static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip) |
| 1309 | { |
| 1310 | if (chip->info->ops->pot_clear) |
| 1311 | return chip->info->ops->pot_clear(chip); |
| 1312 | |
| 1313 | return 0; |
| 1314 | } |
| 1315 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 1316 | static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip) |
| 1317 | { |
| 1318 | if (chip->info->ops->mgmt_rsvd2cpu) |
| 1319 | return chip->info->ops->mgmt_rsvd2cpu(chip); |
| 1320 | |
| 1321 | return 0; |
| 1322 | } |
| 1323 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1324 | static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip) |
| 1325 | { |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1326 | int err; |
| 1327 | |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1328 | err = mv88e6xxx_g1_atu_flush(chip, 0, true); |
| 1329 | if (err) |
| 1330 | return err; |
| 1331 | |
Vivien Didelot | c3a7d4a | 2017-03-11 16:12:51 -0500 | [diff] [blame] | 1332 | err = mv88e6xxx_g1_atu_set_learn2all(chip, true); |
| 1333 | if (err) |
| 1334 | return err; |
| 1335 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 1336 | return mv88e6xxx_g1_atu_set_age_time(chip, 300000); |
| 1337 | } |
| 1338 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 1339 | static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip) |
| 1340 | { |
| 1341 | int port; |
| 1342 | int err; |
| 1343 | |
| 1344 | if (!chip->info->ops->irl_init_all) |
| 1345 | return 0; |
| 1346 | |
| 1347 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1348 | /* Disable ingress rate limiting by resetting all per port |
| 1349 | * ingress rate limit resources to their initial state. |
| 1350 | */ |
| 1351 | err = chip->info->ops->irl_init_all(chip, port); |
| 1352 | if (err) |
| 1353 | return err; |
| 1354 | } |
| 1355 | |
| 1356 | return 0; |
| 1357 | } |
| 1358 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 1359 | static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip) |
| 1360 | { |
| 1361 | if (chip->info->ops->set_switch_mac) { |
| 1362 | u8 addr[ETH_ALEN]; |
| 1363 | |
| 1364 | eth_random_addr(addr); |
| 1365 | |
| 1366 | return chip->info->ops->set_switch_mac(chip, addr); |
| 1367 | } |
| 1368 | |
| 1369 | return 0; |
| 1370 | } |
| 1371 | |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1372 | static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port) |
| 1373 | { |
| 1374 | u16 pvlan = 0; |
| 1375 | |
| 1376 | if (!mv88e6xxx_has_pvt(chip)) |
Vivien Didelot | d14939b | 2019-10-21 16:51:25 -0400 | [diff] [blame] | 1377 | return 0; |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1378 | |
| 1379 | /* Skip the local source device, which uses in-chip port VLAN */ |
| 1380 | if (dev != chip->ds->index) |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 1381 | pvlan = mv88e6xxx_port_vlan(chip, dev, port); |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1382 | |
| 1383 | return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan); |
| 1384 | } |
| 1385 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1386 | static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip) |
| 1387 | { |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1388 | int dev, port; |
| 1389 | int err; |
| 1390 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1391 | if (!mv88e6xxx_has_pvt(chip)) |
| 1392 | return 0; |
| 1393 | |
| 1394 | /* Clear 5 Bit Port for usage with Marvell Link Street devices: |
| 1395 | * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev. |
| 1396 | */ |
Vivien Didelot | 17a1594 | 2017-03-30 17:37:09 -0400 | [diff] [blame] | 1397 | err = mv88e6xxx_g2_misc_4_bit_port(chip); |
| 1398 | if (err) |
| 1399 | return err; |
| 1400 | |
| 1401 | for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) { |
| 1402 | for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) { |
| 1403 | err = mv88e6xxx_pvt_map(chip, dev, port); |
| 1404 | if (err) |
| 1405 | return err; |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | return 0; |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 1410 | } |
| 1411 | |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1412 | static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port) |
| 1413 | { |
| 1414 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1415 | int err; |
| 1416 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1417 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 1418 | err = mv88e6xxx_g1_atu_remove(chip, 0, port, false); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1419 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1420 | |
| 1421 | if (err) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1422 | dev_err(ds->dev, "p%d: failed to flush ATU\n", port); |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 1423 | } |
| 1424 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 1425 | static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip) |
| 1426 | { |
| 1427 | if (!chip->info->max_vid) |
| 1428 | return 0; |
| 1429 | |
| 1430 | return mv88e6xxx_g1_vtu_flush(chip); |
| 1431 | } |
| 1432 | |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1433 | static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip, |
| 1434 | struct mv88e6xxx_vtu_entry *entry) |
| 1435 | { |
| 1436 | if (!chip->info->ops->vtu_getnext) |
| 1437 | return -EOPNOTSUPP; |
| 1438 | |
| 1439 | return chip->info->ops->vtu_getnext(chip, entry); |
| 1440 | } |
| 1441 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 1442 | static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, |
| 1443 | struct mv88e6xxx_vtu_entry *entry) |
| 1444 | { |
| 1445 | if (!chip->info->ops->vtu_loadpurge) |
| 1446 | return -EOPNOTSUPP; |
| 1447 | |
| 1448 | return chip->info->ops->vtu_loadpurge(chip, entry); |
| 1449 | } |
| 1450 | |
Vivien Didelot | d7f435f | 2017-03-11 16:12:56 -0500 | [diff] [blame] | 1451 | static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1452 | { |
| 1453 | DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID); |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1454 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1455 | int i, err; |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1456 | |
| 1457 | bitmap_zero(fid_bitmap, MV88E6XXX_N_FID); |
| 1458 | |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1459 | /* Set every FID bit used by the (un)bridged ports */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1460 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 1461 | err = mv88e6xxx_port_get_fid(chip, i, fid); |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 1462 | if (err) |
| 1463 | return err; |
| 1464 | |
| 1465 | set_bit(*fid, fid_bitmap); |
| 1466 | } |
| 1467 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1468 | /* Set every FID bit used by the VLAN entries */ |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1469 | vlan.vid = chip->info->max_vid; |
| 1470 | vlan.valid = false; |
| 1471 | |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1472 | do { |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1473 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1474 | if (err) |
| 1475 | return err; |
| 1476 | |
| 1477 | if (!vlan.valid) |
| 1478 | break; |
| 1479 | |
| 1480 | set_bit(vlan.fid, fid_bitmap); |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1481 | } while (vlan.vid < chip->info->max_vid); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1482 | |
| 1483 | /* The reset value 0x000 is used to indicate that multiple address |
| 1484 | * databases are not needed. Return the next positive available. |
| 1485 | */ |
| 1486 | *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 1487 | if (unlikely(*fid >= mv88e6xxx_num_databases(chip))) |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1488 | return -ENOSPC; |
| 1489 | |
| 1490 | /* Clear the database */ |
Vivien Didelot | daefc94 | 2017-03-11 16:12:54 -0500 | [diff] [blame] | 1491 | return mv88e6xxx_g1_atu_flush(chip, *fid, true); |
Vivien Didelot | 3285f9e | 2016-02-26 13:16:03 -0500 | [diff] [blame] | 1492 | } |
| 1493 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 1494 | static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash) |
| 1495 | { |
| 1496 | if (chip->info->ops->atu_get_hash) |
| 1497 | return chip->info->ops->atu_get_hash(chip, hash); |
| 1498 | |
| 1499 | return -EOPNOTSUPP; |
| 1500 | } |
| 1501 | |
| 1502 | static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash) |
| 1503 | { |
| 1504 | if (chip->info->ops->atu_set_hash) |
| 1505 | return chip->info->ops->atu_set_hash(chip, hash); |
| 1506 | |
| 1507 | return -EOPNOTSUPP; |
| 1508 | } |
| 1509 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1510 | static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, |
| 1511 | u16 vid_begin, u16 vid_end) |
| 1512 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1513 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1514 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1515 | int i, err; |
| 1516 | |
Andrew Lunn | db06ae41 | 2017-09-25 23:32:20 +0200 | [diff] [blame] | 1517 | /* DSA and CPU ports have to be members of multiple vlans */ |
| 1518 | if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) |
| 1519 | return 0; |
| 1520 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1521 | if (!vid_begin) |
| 1522 | return -EOPNOTSUPP; |
| 1523 | |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 1524 | vlan.vid = vid_begin - 1; |
| 1525 | vlan.valid = false; |
| 1526 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1527 | do { |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 1528 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1529 | if (err) |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1530 | return err; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1531 | |
| 1532 | if (!vlan.valid) |
| 1533 | break; |
| 1534 | |
| 1535 | if (vlan.vid > vid_end) |
| 1536 | break; |
| 1537 | |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 1538 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1539 | if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) |
| 1540 | continue; |
| 1541 | |
Vivien Didelot | 68bb8ea | 2019-10-21 16:51:15 -0400 | [diff] [blame] | 1542 | if (!dsa_to_port(ds, i)->slave) |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1543 | continue; |
| 1544 | |
Vivien Didelot | bd00e05 | 2017-05-01 14:05:11 -0400 | [diff] [blame] | 1545 | if (vlan.member[i] == |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1546 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1547 | continue; |
| 1548 | |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1549 | if (dsa_to_port(ds, i)->bridge_dev == |
Vivien Didelot | 68bb8ea | 2019-10-21 16:51:15 -0400 | [diff] [blame] | 1550 | dsa_to_port(ds, port)->bridge_dev) |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1551 | break; /* same bridge, check next VLAN */ |
| 1552 | |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1553 | if (!dsa_to_port(ds, i)->bridge_dev) |
Andrew Lunn | 66e2809 | 2016-12-11 21:07:19 +0100 | [diff] [blame] | 1554 | continue; |
| 1555 | |
Andrew Lunn | 743fcc2 | 2017-11-09 22:29:54 +0100 | [diff] [blame] | 1556 | dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n", |
| 1557 | port, vlan.vid, i, |
Vivien Didelot | c8652c8 | 2017-10-16 11:12:19 -0400 | [diff] [blame] | 1558 | netdev_name(dsa_to_port(ds, i)->bridge_dev)); |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1559 | return -EOPNOTSUPP; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1560 | } |
| 1561 | } while (vlan.vid < vid_end); |
| 1562 | |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1563 | return 0; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1564 | } |
| 1565 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1566 | static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, |
| 1567 | bool vlan_filtering) |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1568 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1569 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 1570 | u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE : |
| 1571 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1572 | int err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1573 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1574 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1575 | return -EOPNOTSUPP; |
| 1576 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1577 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 385a099 | 2016-11-04 03:23:31 +0100 | [diff] [blame] | 1578 | err = mv88e6xxx_port_set_8021q_mode(chip, port, mode); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1579 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1580 | |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 1581 | return err; |
Vivien Didelot | 214cdb9 | 2016-02-26 13:16:08 -0500 | [diff] [blame] | 1582 | } |
| 1583 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 1584 | static int |
| 1585 | mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1586 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1587 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1588 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1589 | int err; |
| 1590 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1591 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1592 | return -EOPNOTSUPP; |
| 1593 | |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1594 | /* If the requested port doesn't belong to the same bridge as the VLAN |
| 1595 | * members, do not support it (yet) and fallback to software VLAN. |
| 1596 | */ |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1597 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1598 | err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin, |
| 1599 | vlan->vid_end); |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1600 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | da9c359 | 2016-02-12 12:09:40 -0500 | [diff] [blame] | 1601 | |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1602 | /* We don't need any dynamic resource from the kernel (yet), |
| 1603 | * so skip the prepare phase. |
| 1604 | */ |
Vivien Didelot | 7095a4c | 2019-08-01 14:36:33 -0400 | [diff] [blame] | 1605 | return err; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1606 | } |
| 1607 | |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1608 | static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, |
| 1609 | const unsigned char *addr, u16 vid, |
| 1610 | u8 state) |
| 1611 | { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1612 | struct mv88e6xxx_atu_entry entry; |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1613 | struct mv88e6xxx_vtu_entry vlan; |
| 1614 | u16 fid; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1615 | int err; |
| 1616 | |
| 1617 | /* Null VLAN ID corresponds to the port private database */ |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1618 | if (vid == 0) { |
| 1619 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
| 1620 | if (err) |
| 1621 | return err; |
| 1622 | } else { |
| 1623 | vlan.vid = vid - 1; |
| 1624 | vlan.valid = false; |
| 1625 | |
| 1626 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
| 1627 | if (err) |
| 1628 | return err; |
| 1629 | |
| 1630 | /* switchdev expects -EOPNOTSUPP to honor software VLANs */ |
| 1631 | if (vlan.vid != vid || !vlan.valid) |
| 1632 | return -EOPNOTSUPP; |
| 1633 | |
| 1634 | fid = vlan.fid; |
| 1635 | } |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1636 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1637 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1638 | ether_addr_copy(entry.mac, addr); |
| 1639 | eth_addr_dec(entry.mac); |
| 1640 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1641 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1642 | if (err) |
| 1643 | return err; |
| 1644 | |
| 1645 | /* Initialize a fresh ATU entry if it isn't found */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1646 | if (!entry.state || !ether_addr_equal(entry.mac, addr)) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1647 | memset(&entry, 0, sizeof(entry)); |
| 1648 | ether_addr_copy(entry.mac, addr); |
| 1649 | } |
| 1650 | |
| 1651 | /* Purge the ATU entry only if no port is using it anymore */ |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1652 | if (!state) { |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1653 | entry.portvec &= ~BIT(port); |
| 1654 | if (!entry.portvec) |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 1655 | entry.state = 0; |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1656 | } else { |
| 1657 | entry.portvec |= BIT(port); |
| 1658 | entry.state = state; |
| 1659 | } |
| 1660 | |
Vivien Didelot | 5ef8d24 | 2019-08-01 14:36:35 -0400 | [diff] [blame] | 1661 | return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry); |
Andrew Lunn | a4c93ae | 2017-11-09 22:29:55 +0100 | [diff] [blame] | 1662 | } |
| 1663 | |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 1664 | static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port, |
| 1665 | const struct mv88e6xxx_policy *policy) |
| 1666 | { |
| 1667 | enum mv88e6xxx_policy_mapping mapping = policy->mapping; |
| 1668 | enum mv88e6xxx_policy_action action = policy->action; |
| 1669 | const u8 *addr = policy->addr; |
| 1670 | u16 vid = policy->vid; |
| 1671 | u8 state; |
| 1672 | int err; |
| 1673 | int id; |
| 1674 | |
| 1675 | if (!chip->info->ops->port_set_policy) |
| 1676 | return -EOPNOTSUPP; |
| 1677 | |
| 1678 | switch (mapping) { |
| 1679 | case MV88E6XXX_POLICY_MAPPING_DA: |
| 1680 | case MV88E6XXX_POLICY_MAPPING_SA: |
| 1681 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1682 | state = 0; /* Dissociate the port and address */ |
| 1683 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1684 | is_multicast_ether_addr(addr)) |
| 1685 | state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY; |
| 1686 | else if (action == MV88E6XXX_POLICY_ACTION_DISCARD && |
| 1687 | is_unicast_ether_addr(addr)) |
| 1688 | state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY; |
| 1689 | else |
| 1690 | return -EOPNOTSUPP; |
| 1691 | |
| 1692 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 1693 | state); |
| 1694 | if (err) |
| 1695 | return err; |
| 1696 | break; |
| 1697 | default: |
| 1698 | return -EOPNOTSUPP; |
| 1699 | } |
| 1700 | |
| 1701 | /* Skip the port's policy clearing if the mapping is still in use */ |
| 1702 | if (action == MV88E6XXX_POLICY_ACTION_NORMAL) |
| 1703 | idr_for_each_entry(&chip->policies, policy, id) |
| 1704 | if (policy->port == port && |
| 1705 | policy->mapping == mapping && |
| 1706 | policy->action != action) |
| 1707 | return 0; |
| 1708 | |
| 1709 | return chip->info->ops->port_set_policy(chip, port, mapping, action); |
| 1710 | } |
| 1711 | |
| 1712 | static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port, |
| 1713 | struct ethtool_rx_flow_spec *fs) |
| 1714 | { |
| 1715 | struct ethhdr *mac_entry = &fs->h_u.ether_spec; |
| 1716 | struct ethhdr *mac_mask = &fs->m_u.ether_spec; |
| 1717 | enum mv88e6xxx_policy_mapping mapping; |
| 1718 | enum mv88e6xxx_policy_action action; |
| 1719 | struct mv88e6xxx_policy *policy; |
| 1720 | u16 vid = 0; |
| 1721 | u8 *addr; |
| 1722 | int err; |
| 1723 | int id; |
| 1724 | |
| 1725 | if (fs->location != RX_CLS_LOC_ANY) |
| 1726 | return -EINVAL; |
| 1727 | |
| 1728 | if (fs->ring_cookie == RX_CLS_FLOW_DISC) |
| 1729 | action = MV88E6XXX_POLICY_ACTION_DISCARD; |
| 1730 | else |
| 1731 | return -EOPNOTSUPP; |
| 1732 | |
| 1733 | switch (fs->flow_type & ~FLOW_EXT) { |
| 1734 | case ETHER_FLOW: |
| 1735 | if (!is_zero_ether_addr(mac_mask->h_dest) && |
| 1736 | is_zero_ether_addr(mac_mask->h_source)) { |
| 1737 | mapping = MV88E6XXX_POLICY_MAPPING_DA; |
| 1738 | addr = mac_entry->h_dest; |
| 1739 | } else if (is_zero_ether_addr(mac_mask->h_dest) && |
| 1740 | !is_zero_ether_addr(mac_mask->h_source)) { |
| 1741 | mapping = MV88E6XXX_POLICY_MAPPING_SA; |
| 1742 | addr = mac_entry->h_source; |
| 1743 | } else { |
| 1744 | /* Cannot support DA and SA mapping in the same rule */ |
| 1745 | return -EOPNOTSUPP; |
| 1746 | } |
| 1747 | break; |
| 1748 | default: |
| 1749 | return -EOPNOTSUPP; |
| 1750 | } |
| 1751 | |
| 1752 | if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) { |
| 1753 | if (fs->m_ext.vlan_tci != 0xffff) |
| 1754 | return -EOPNOTSUPP; |
| 1755 | vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK; |
| 1756 | } |
| 1757 | |
| 1758 | idr_for_each_entry(&chip->policies, policy, id) { |
| 1759 | if (policy->port == port && policy->mapping == mapping && |
| 1760 | policy->action == action && policy->vid == vid && |
| 1761 | ether_addr_equal(policy->addr, addr)) |
| 1762 | return -EEXIST; |
| 1763 | } |
| 1764 | |
| 1765 | policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL); |
| 1766 | if (!policy) |
| 1767 | return -ENOMEM; |
| 1768 | |
| 1769 | fs->location = 0; |
| 1770 | err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff, |
| 1771 | GFP_KERNEL); |
| 1772 | if (err) { |
| 1773 | devm_kfree(chip->dev, policy); |
| 1774 | return err; |
| 1775 | } |
| 1776 | |
| 1777 | memcpy(&policy->fs, fs, sizeof(*fs)); |
| 1778 | ether_addr_copy(policy->addr, addr); |
| 1779 | policy->mapping = mapping; |
| 1780 | policy->action = action; |
| 1781 | policy->port = port; |
| 1782 | policy->vid = vid; |
| 1783 | |
| 1784 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1785 | if (err) { |
| 1786 | idr_remove(&chip->policies, fs->location); |
| 1787 | devm_kfree(chip->dev, policy); |
| 1788 | return err; |
| 1789 | } |
| 1790 | |
| 1791 | return 0; |
| 1792 | } |
| 1793 | |
| 1794 | static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port, |
| 1795 | struct ethtool_rxnfc *rxnfc, u32 *rule_locs) |
| 1796 | { |
| 1797 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1798 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1799 | struct mv88e6xxx_policy *policy; |
| 1800 | int err; |
| 1801 | int id; |
| 1802 | |
| 1803 | mv88e6xxx_reg_lock(chip); |
| 1804 | |
| 1805 | switch (rxnfc->cmd) { |
| 1806 | case ETHTOOL_GRXCLSRLCNT: |
| 1807 | rxnfc->data = 0; |
| 1808 | rxnfc->data |= RX_CLS_LOC_SPECIAL; |
| 1809 | rxnfc->rule_cnt = 0; |
| 1810 | idr_for_each_entry(&chip->policies, policy, id) |
| 1811 | if (policy->port == port) |
| 1812 | rxnfc->rule_cnt++; |
| 1813 | err = 0; |
| 1814 | break; |
| 1815 | case ETHTOOL_GRXCLSRULE: |
| 1816 | err = -ENOENT; |
| 1817 | policy = idr_find(&chip->policies, fs->location); |
| 1818 | if (policy) { |
| 1819 | memcpy(fs, &policy->fs, sizeof(*fs)); |
| 1820 | err = 0; |
| 1821 | } |
| 1822 | break; |
| 1823 | case ETHTOOL_GRXCLSRLALL: |
| 1824 | rxnfc->data = 0; |
| 1825 | rxnfc->rule_cnt = 0; |
| 1826 | idr_for_each_entry(&chip->policies, policy, id) |
| 1827 | if (policy->port == port) |
| 1828 | rule_locs[rxnfc->rule_cnt++] = id; |
| 1829 | err = 0; |
| 1830 | break; |
| 1831 | default: |
| 1832 | err = -EOPNOTSUPP; |
| 1833 | break; |
| 1834 | } |
| 1835 | |
| 1836 | mv88e6xxx_reg_unlock(chip); |
| 1837 | |
| 1838 | return err; |
| 1839 | } |
| 1840 | |
| 1841 | static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port, |
| 1842 | struct ethtool_rxnfc *rxnfc) |
| 1843 | { |
| 1844 | struct ethtool_rx_flow_spec *fs = &rxnfc->fs; |
| 1845 | struct mv88e6xxx_chip *chip = ds->priv; |
| 1846 | struct mv88e6xxx_policy *policy; |
| 1847 | int err; |
| 1848 | |
| 1849 | mv88e6xxx_reg_lock(chip); |
| 1850 | |
| 1851 | switch (rxnfc->cmd) { |
| 1852 | case ETHTOOL_SRXCLSRLINS: |
| 1853 | err = mv88e6xxx_policy_insert(chip, port, fs); |
| 1854 | break; |
| 1855 | case ETHTOOL_SRXCLSRLDEL: |
| 1856 | err = -ENOENT; |
| 1857 | policy = idr_remove(&chip->policies, fs->location); |
| 1858 | if (policy) { |
| 1859 | policy->action = MV88E6XXX_POLICY_ACTION_NORMAL; |
| 1860 | err = mv88e6xxx_policy_apply(chip, port, policy); |
| 1861 | devm_kfree(chip->dev, policy); |
| 1862 | } |
| 1863 | break; |
| 1864 | default: |
| 1865 | err = -EOPNOTSUPP; |
| 1866 | break; |
| 1867 | } |
| 1868 | |
| 1869 | mv88e6xxx_reg_unlock(chip); |
| 1870 | |
| 1871 | return err; |
| 1872 | } |
| 1873 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1874 | static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port, |
| 1875 | u16 vid) |
| 1876 | { |
| 1877 | const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 1878 | u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; |
| 1879 | |
| 1880 | return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state); |
| 1881 | } |
| 1882 | |
| 1883 | static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) |
| 1884 | { |
| 1885 | int port; |
| 1886 | int err; |
| 1887 | |
| 1888 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 1889 | err = mv88e6xxx_port_add_broadcast(chip, port, vid); |
| 1890 | if (err) |
| 1891 | return err; |
| 1892 | } |
| 1893 | |
| 1894 | return 0; |
| 1895 | } |
| 1896 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1897 | static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port, |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1898 | u16 vid, u8 member, bool warn) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1899 | { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1900 | const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 1901 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1902 | int i, err; |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1903 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1904 | if (!vid) |
| 1905 | return -EOPNOTSUPP; |
| 1906 | |
| 1907 | vlan.vid = vid - 1; |
| 1908 | vlan.valid = false; |
| 1909 | |
| 1910 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1911 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1912 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 1913 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1914 | if (vlan.vid != vid || !vlan.valid) { |
| 1915 | memset(&vlan, 0, sizeof(vlan)); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1916 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1917 | err = mv88e6xxx_atu_new(chip, &vlan.fid); |
| 1918 | if (err) |
| 1919 | return err; |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 1920 | |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1921 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) |
| 1922 | if (i == port) |
| 1923 | vlan.member[i] = member; |
| 1924 | else |
| 1925 | vlan.member[i] = non_member; |
| 1926 | |
| 1927 | vlan.vid = vid; |
| 1928 | vlan.valid = true; |
| 1929 | |
| 1930 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 1931 | if (err) |
| 1932 | return err; |
| 1933 | |
| 1934 | err = mv88e6xxx_broadcast_setup(chip, vlan.vid); |
| 1935 | if (err) |
| 1936 | return err; |
| 1937 | } else if (vlan.member[port] != member) { |
| 1938 | vlan.member[port] = member; |
| 1939 | |
| 1940 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
| 1941 | if (err) |
| 1942 | return err; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1943 | } else if (warn) { |
Vivien Didelot | b1ac6fb | 2019-08-01 14:36:37 -0400 | [diff] [blame] | 1944 | dev_info(chip->dev, "p%d: already a member of VLAN %d\n", |
| 1945 | port, vid); |
| 1946 | } |
| 1947 | |
| 1948 | return 0; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1949 | } |
| 1950 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 1951 | static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, |
Vivien Didelot | 80e0236 | 2017-11-30 11:23:57 -0500 | [diff] [blame] | 1952 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1953 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 1954 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1955 | bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; |
| 1956 | bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1957 | bool warn; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1958 | u8 member; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1959 | u16 vid; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1960 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 1961 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 1962 | return; |
| 1963 | |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1964 | 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] | 1965 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1966 | else if (untagged) |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1967 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1968 | else |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 1969 | member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED; |
Vivien Didelot | c91498e | 2017-06-07 18:12:13 -0400 | [diff] [blame] | 1970 | |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1971 | /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port |
| 1972 | * and then the CPU port. Do not warn for duplicates for the CPU port. |
| 1973 | */ |
| 1974 | warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port); |
| 1975 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1976 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1977 | |
Vivien Didelot | 4d5770b | 2016-04-06 11:55:05 -0400 | [diff] [blame] | 1978 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) |
Russell King | 933b442 | 2020-02-26 17:14:26 +0000 | [diff] [blame] | 1979 | if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1980 | dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port, |
| 1981 | vid, untagged ? 'u' : 't'); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 1982 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 1983 | if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 1984 | dev_err(ds->dev, "p%d: failed to set PVID %d\n", port, |
| 1985 | vlan->vid_end); |
Vivien Didelot | 4d5770b | 2016-04-06 11:55:05 -0400 | [diff] [blame] | 1986 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 1987 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 0d3b33e | 2015-08-13 12:52:22 -0400 | [diff] [blame] | 1988 | } |
| 1989 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 1990 | static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip, |
| 1991 | int port, u16 vid) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1992 | { |
Vivien Didelot | b4e47c0 | 2016-09-29 12:21:58 -0400 | [diff] [blame] | 1993 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 1994 | int i, err; |
| 1995 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 1996 | if (!vid) |
| 1997 | return -EOPNOTSUPP; |
| 1998 | |
| 1999 | vlan.vid = vid - 1; |
| 2000 | vlan.valid = false; |
| 2001 | |
| 2002 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2003 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2004 | return err; |
Vivien Didelot | 36d04ba | 2015-10-22 09:34:39 -0400 | [diff] [blame] | 2005 | |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2006 | /* If the VLAN doesn't exist in hardware or the port isn't a member, |
| 2007 | * tell switchdev that this VLAN is likely handled in software. |
| 2008 | */ |
| 2009 | if (vlan.vid != vid || !vlan.valid || |
| 2010 | vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) |
Vivien Didelot | 3c06f08 | 2016-02-05 14:04:39 -0500 | [diff] [blame] | 2011 | return -EOPNOTSUPP; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2012 | |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2013 | vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2014 | |
| 2015 | /* keep the VLAN unless all ports are excluded */ |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2016 | vlan.valid = false; |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 2017 | for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { |
Vivien Didelot | 7ec60d6e | 2017-06-15 12:14:02 -0400 | [diff] [blame] | 2018 | if (vlan.member[i] != |
| 2019 | MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) { |
Vivien Didelot | f02bdff | 2015-10-11 18:08:36 -0400 | [diff] [blame] | 2020 | vlan.valid = true; |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2021 | break; |
| 2022 | } |
| 2023 | } |
| 2024 | |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 2025 | err = mv88e6xxx_vtu_loadpurge(chip, &vlan); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2026 | if (err) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2027 | return err; |
| 2028 | |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 2029 | return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2030 | } |
| 2031 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2032 | static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, |
| 2033 | const struct switchdev_obj_port_vlan *vlan) |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2034 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2035 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2036 | u16 pvid, vid; |
| 2037 | int err = 0; |
| 2038 | |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 2039 | if (!chip->info->max_vid) |
Vivien Didelot | 54d77b5 | 2016-05-09 13:22:47 -0400 | [diff] [blame] | 2040 | return -EOPNOTSUPP; |
| 2041 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2042 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2043 | |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 2044 | err = mv88e6xxx_port_get_pvid(chip, port, &pvid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2045 | if (err) |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2046 | goto unlock; |
| 2047 | |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2048 | for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) { |
Vivien Didelot | 52109892 | 2019-08-01 14:36:36 -0400 | [diff] [blame] | 2049 | err = mv88e6xxx_port_vlan_leave(chip, port, vid); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2050 | if (err) |
| 2051 | goto unlock; |
| 2052 | |
| 2053 | if (vid == pvid) { |
Vivien Didelot | 77064f3 | 2016-11-04 03:23:30 +0100 | [diff] [blame] | 2054 | err = mv88e6xxx_port_set_pvid(chip, port, 0); |
Vivien Didelot | 76e398a | 2015-11-01 12:33:55 -0500 | [diff] [blame] | 2055 | if (err) |
| 2056 | goto unlock; |
| 2057 | } |
| 2058 | } |
| 2059 | |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2060 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2061 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7dad08d | 2015-08-13 12:52:21 -0400 | [diff] [blame] | 2062 | |
| 2063 | return err; |
| 2064 | } |
| 2065 | |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2066 | static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port, |
| 2067 | const unsigned char *addr, u16 vid) |
Guenter Roeck | defb05b | 2015-03-26 18:36:38 -0700 | [diff] [blame] | 2068 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2069 | struct mv88e6xxx_chip *chip = ds->priv; |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2070 | int err; |
Vivien Didelot | 6630e23 | 2015-08-06 01:44:07 -0400 | [diff] [blame] | 2071 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2072 | mv88e6xxx_reg_lock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2073 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, |
| 2074 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2075 | mv88e6xxx_reg_unlock(chip); |
Arkadi Sharshevsky | 1b6dd55 | 2017-08-06 16:15:40 +0300 | [diff] [blame] | 2076 | |
| 2077 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2078 | } |
| 2079 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2080 | static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 6c2c1dc | 2017-08-06 16:15:39 +0300 | [diff] [blame] | 2081 | const unsigned char *addr, u16 vid) |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2082 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2083 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2084 | int err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2085 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2086 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2087 | err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2088 | mv88e6xxx_reg_unlock(chip); |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2089 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2090 | return err; |
David S. Miller | cdf0969 | 2015-08-11 12:00:37 -0700 | [diff] [blame] | 2091 | } |
| 2092 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2093 | static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, |
| 2094 | u16 fid, u16 vid, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2095 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2096 | { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2097 | struct mv88e6xxx_atu_entry addr; |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2098 | bool is_static; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2099 | int err; |
| 2100 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2101 | addr.state = 0; |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2102 | eth_broadcast_addr(addr.mac); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2103 | |
| 2104 | do { |
Vivien Didelot | dabc1a9 | 2017-03-11 16:12:53 -0500 | [diff] [blame] | 2105 | err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr); |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2106 | if (err) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2107 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2108 | |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 2109 | if (!addr.state) |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2110 | break; |
| 2111 | |
Vivien Didelot | 01bd96c | 2017-03-11 16:12:57 -0500 | [diff] [blame] | 2112 | if (addr.trunk || (addr.portvec & BIT(port)) == 0) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2113 | continue; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2114 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2115 | if (!is_unicast_ether_addr(addr.mac)) |
| 2116 | continue; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2117 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2118 | is_static = (addr.state == |
| 2119 | MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC); |
| 2120 | err = cb(addr.mac, vid, is_static, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2121 | if (err) |
| 2122 | return err; |
Vivien Didelot | 74b6ba0 | 2016-02-26 13:16:02 -0500 | [diff] [blame] | 2123 | } while (!is_broadcast_ether_addr(addr.mac)); |
| 2124 | |
| 2125 | return err; |
| 2126 | } |
| 2127 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2128 | static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2129 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2130 | { |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 2131 | struct mv88e6xxx_vtu_entry vlan; |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2132 | u16 fid; |
| 2133 | int err; |
| 2134 | |
| 2135 | /* Dump port's default Filtering Information Database (VLAN ID 0) */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2136 | err = mv88e6xxx_port_get_fid(chip, port, &fid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2137 | if (err) |
| 2138 | return err; |
| 2139 | |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2140 | err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2141 | if (err) |
| 2142 | return err; |
| 2143 | |
| 2144 | /* Dump VLANs' Filtering Information Databases */ |
Vivien Didelot | 425d2d3 | 2019-08-01 14:36:34 -0400 | [diff] [blame] | 2145 | vlan.vid = chip->info->max_vid; |
| 2146 | vlan.valid = false; |
| 2147 | |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2148 | do { |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 2149 | err = mv88e6xxx_vtu_getnext(chip, &vlan); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2150 | if (err) |
| 2151 | return err; |
| 2152 | |
| 2153 | if (!vlan.valid) |
| 2154 | break; |
| 2155 | |
| 2156 | err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2157 | cb, data); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2158 | if (err) |
| 2159 | return err; |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 2160 | } while (vlan.vid < chip->info->max_vid); |
Vivien Didelot | 83dabd1 | 2016-08-31 11:50:04 -0400 | [diff] [blame] | 2161 | |
| 2162 | return err; |
| 2163 | } |
| 2164 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2165 | static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, |
Arkadi Sharshevsky | 2bedde1 | 2017-08-06 16:15:49 +0300 | [diff] [blame] | 2166 | dsa_fdb_dump_cb_t *cb, void *data) |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2167 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2168 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2169 | int err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2170 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2171 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2172 | err = mv88e6xxx_port_db_dump(chip, port, cb, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2173 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | fcf1536 | 2019-06-12 12:42:47 -0400 | [diff] [blame] | 2174 | |
| 2175 | return err; |
Vivien Didelot | f33475b | 2015-10-22 09:34:41 -0400 | [diff] [blame] | 2176 | } |
| 2177 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2178 | static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, |
| 2179 | struct net_device *br) |
| 2180 | { |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2181 | struct dsa_switch *ds = chip->ds; |
| 2182 | struct dsa_switch_tree *dst = ds->dst; |
| 2183 | struct dsa_port *dp; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2184 | int err; |
| 2185 | |
Vivien Didelot | ef2025e | 2019-10-21 16:51:27 -0400 | [diff] [blame] | 2186 | list_for_each_entry(dp, &dst->ports, list) { |
| 2187 | if (dp->bridge_dev == br) { |
| 2188 | if (dp->ds == ds) { |
| 2189 | /* This is a local bridge group member, |
| 2190 | * remap its Port VLAN Map. |
| 2191 | */ |
| 2192 | err = mv88e6xxx_port_vlan_map(chip, dp->index); |
| 2193 | if (err) |
| 2194 | return err; |
| 2195 | } else { |
| 2196 | /* This is an external bridge group member, |
| 2197 | * remap its cross-chip Port VLAN Table entry. |
| 2198 | */ |
| 2199 | err = mv88e6xxx_pvt_map(chip, dp->ds->index, |
| 2200 | dp->index); |
Vivien Didelot | e96a6e0 | 2017-03-30 17:37:13 -0400 | [diff] [blame] | 2201 | if (err) |
| 2202 | return err; |
| 2203 | } |
| 2204 | } |
| 2205 | } |
| 2206 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2207 | return 0; |
| 2208 | } |
| 2209 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 2210 | static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, |
Vivien Didelot | fae8a25 | 2017-01-27 15:29:42 -0500 | [diff] [blame] | 2211 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2212 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2213 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2214 | int err; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2215 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2216 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2217 | err = mv88e6xxx_bridge_map(chip, br); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2218 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | a669275 | 2016-02-12 12:09:39 -0500 | [diff] [blame] | 2219 | |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2220 | return err; |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2221 | } |
| 2222 | |
Vivien Didelot | f123f2f | 2017-01-27 15:29:41 -0500 | [diff] [blame] | 2223 | static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, |
| 2224 | struct net_device *br) |
Vivien Didelot | e79a8bc | 2015-11-04 17:23:40 -0500 | [diff] [blame] | 2225 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2226 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 466dfa0 | 2016-02-26 13:16:05 -0500 | [diff] [blame] | 2227 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2228 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2229 | if (mv88e6xxx_bridge_map(chip, br) || |
| 2230 | mv88e6xxx_port_vlan_map(chip, port)) |
| 2231 | dev_err(ds->dev, "failed to remap in-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2232 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 66d9cd0 | 2016-02-05 14:07:14 -0500 | [diff] [blame] | 2233 | } |
| 2234 | |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2235 | static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev, |
| 2236 | int port, struct net_device *br) |
| 2237 | { |
| 2238 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2239 | int err; |
| 2240 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2241 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2242 | err = mv88e6xxx_pvt_map(chip, dev, port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2243 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2244 | |
| 2245 | return err; |
| 2246 | } |
| 2247 | |
| 2248 | static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev, |
| 2249 | int port, struct net_device *br) |
| 2250 | { |
| 2251 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2252 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2253 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2254 | if (mv88e6xxx_pvt_map(chip, dev, port)) |
| 2255 | dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2256 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 2257 | } |
| 2258 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2259 | static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip) |
| 2260 | { |
| 2261 | if (chip->info->ops->reset) |
| 2262 | return chip->info->ops->reset(chip); |
| 2263 | |
| 2264 | return 0; |
| 2265 | } |
| 2266 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2267 | static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip) |
| 2268 | { |
| 2269 | struct gpio_desc *gpiod = chip->reset; |
| 2270 | |
| 2271 | /* If there is a GPIO connected to the reset pin, toggle it */ |
| 2272 | if (gpiod) { |
| 2273 | gpiod_set_value_cansleep(gpiod, 1); |
| 2274 | usleep_range(10000, 20000); |
| 2275 | gpiod_set_value_cansleep(gpiod, 0); |
| 2276 | usleep_range(10000, 20000); |
| 2277 | } |
| 2278 | } |
| 2279 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2280 | static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip) |
| 2281 | { |
| 2282 | int i, err; |
| 2283 | |
| 2284 | /* Set all ports to the Disabled state */ |
| 2285 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | f894c29 | 2017-06-08 18:34:10 -0400 | [diff] [blame] | 2286 | err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED); |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2287 | if (err) |
| 2288 | return err; |
| 2289 | } |
| 2290 | |
| 2291 | /* Wait for transmit queues to drain, |
| 2292 | * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps. |
| 2293 | */ |
| 2294 | usleep_range(2000, 4000); |
| 2295 | |
| 2296 | return 0; |
| 2297 | } |
| 2298 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2299 | static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2300 | { |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 2301 | int err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2302 | |
Vivien Didelot | 4ac4b5a | 2016-12-05 17:30:25 -0500 | [diff] [blame] | 2303 | err = mv88e6xxx_disable_ports(chip); |
| 2304 | if (err) |
| 2305 | return err; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2306 | |
Vivien Didelot | 309eca6 | 2016-12-05 17:30:26 -0500 | [diff] [blame] | 2307 | mv88e6xxx_hardware_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2308 | |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 2309 | return mv88e6xxx_software_reset(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 2310 | } |
| 2311 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2312 | static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2313 | enum mv88e6xxx_frame_mode frame, |
| 2314 | enum mv88e6xxx_egress_mode egress, u16 etype) |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2315 | { |
| 2316 | int err; |
| 2317 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2318 | if (!chip->info->ops->port_set_frame_mode) |
| 2319 | return -EOPNOTSUPP; |
| 2320 | |
| 2321 | err = mv88e6xxx_port_set_egress_mode(chip, port, egress); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2322 | if (err) |
| 2323 | return err; |
| 2324 | |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2325 | err = chip->info->ops->port_set_frame_mode(chip, port, frame); |
| 2326 | if (err) |
| 2327 | return err; |
| 2328 | |
| 2329 | if (chip->info->ops->port_set_ether_type) |
| 2330 | return chip->info->ops->port_set_ether_type(chip, port, etype); |
| 2331 | |
| 2332 | return 0; |
| 2333 | } |
| 2334 | |
| 2335 | static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port) |
| 2336 | { |
| 2337 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2338 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2339 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2340 | } |
| 2341 | |
| 2342 | static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port) |
| 2343 | { |
| 2344 | return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2345 | MV88E6XXX_EGRESS_MODE_UNMODIFIED, |
Vivien Didelot | b810959 | 2017-06-12 12:37:45 -0400 | [diff] [blame] | 2346 | MV88E6XXX_PORT_ETH_TYPE_DEFAULT); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2347 | } |
| 2348 | |
| 2349 | static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port) |
| 2350 | { |
| 2351 | return mv88e6xxx_set_port_mode(chip, port, |
| 2352 | MV88E6XXX_FRAME_MODE_ETHERTYPE, |
Vivien Didelot | 31bef4e | 2017-06-08 18:34:09 -0400 | [diff] [blame] | 2353 | MV88E6XXX_EGRESS_MODE_ETHERTYPE, |
| 2354 | ETH_P_EDSA); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2355 | } |
| 2356 | |
| 2357 | static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port) |
| 2358 | { |
| 2359 | if (dsa_is_dsa_port(chip->ds, port)) |
| 2360 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2361 | |
Vivien Didelot | 2b3e989 | 2017-10-26 11:22:54 -0400 | [diff] [blame] | 2362 | if (dsa_is_user_port(chip->ds, port)) |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2363 | return mv88e6xxx_set_port_mode_normal(chip, port); |
| 2364 | |
| 2365 | /* Setup CPU port mode depending on its supported tag format */ |
| 2366 | if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA) |
| 2367 | return mv88e6xxx_set_port_mode_dsa(chip, port); |
| 2368 | |
| 2369 | if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA) |
| 2370 | return mv88e6xxx_set_port_mode_edsa(chip, port); |
| 2371 | |
| 2372 | return -EINVAL; |
| 2373 | } |
| 2374 | |
Vivien Didelot | ea698f4 | 2017-03-11 16:12:50 -0500 | [diff] [blame] | 2375 | static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port) |
| 2376 | { |
| 2377 | bool message = dsa_is_dsa_port(chip->ds, port); |
| 2378 | |
| 2379 | return mv88e6xxx_port_set_message_port(chip, port, message); |
| 2380 | } |
| 2381 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2382 | static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) |
| 2383 | { |
Vivien Didelot | 3ee50cb | 2017-12-05 15:34:09 -0500 | [diff] [blame] | 2384 | struct dsa_switch *ds = chip->ds; |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2385 | bool flood; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2386 | |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2387 | /* Upstream ports flood frames with unknown unicast or multicast DA */ |
| 2388 | flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port); |
| 2389 | if (chip->info->ops->port_set_egress_floods) |
| 2390 | return chip->info->ops->port_set_egress_floods(chip, port, |
| 2391 | flood, flood); |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2392 | |
David S. Miller | 407308f | 2019-06-15 13:35:29 -0700 | [diff] [blame] | 2393 | return 0; |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2394 | } |
| 2395 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2396 | static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id) |
| 2397 | { |
| 2398 | struct mv88e6xxx_port *mvp = dev_id; |
| 2399 | struct mv88e6xxx_chip *chip = mvp->chip; |
| 2400 | irqreturn_t ret = IRQ_NONE; |
| 2401 | int port = mvp->port; |
| 2402 | u8 lane; |
| 2403 | |
| 2404 | mv88e6xxx_reg_lock(chip); |
| 2405 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
| 2406 | if (lane) |
| 2407 | ret = mv88e6xxx_serdes_irq_status(chip, port, lane); |
| 2408 | mv88e6xxx_reg_unlock(chip); |
| 2409 | |
| 2410 | return ret; |
| 2411 | } |
| 2412 | |
| 2413 | static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port, |
| 2414 | u8 lane) |
| 2415 | { |
| 2416 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2417 | unsigned int irq; |
| 2418 | int err; |
| 2419 | |
| 2420 | /* Nothing to request if this SERDES port has no IRQ */ |
| 2421 | irq = mv88e6xxx_serdes_irq_mapping(chip, port); |
| 2422 | if (!irq) |
| 2423 | return 0; |
| 2424 | |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2425 | snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name), |
| 2426 | "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port); |
| 2427 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2428 | /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2429 | mv88e6xxx_reg_unlock(chip); |
| 2430 | err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn, |
Andrew Lunn | e6f2f6b | 2020-01-06 17:13:49 +0100 | [diff] [blame] | 2431 | IRQF_ONESHOT, dev_id->serdes_irq_name, |
| 2432 | dev_id); |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2433 | mv88e6xxx_reg_lock(chip); |
| 2434 | if (err) |
| 2435 | return err; |
| 2436 | |
| 2437 | dev_id->serdes_irq = irq; |
| 2438 | |
| 2439 | return mv88e6xxx_serdes_irq_enable(chip, port, lane); |
| 2440 | } |
| 2441 | |
| 2442 | static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port, |
| 2443 | u8 lane) |
| 2444 | { |
| 2445 | struct mv88e6xxx_port *dev_id = &chip->ports[port]; |
| 2446 | unsigned int irq = dev_id->serdes_irq; |
| 2447 | int err; |
| 2448 | |
| 2449 | /* Nothing to free if no IRQ has been requested */ |
| 2450 | if (!irq) |
| 2451 | return 0; |
| 2452 | |
| 2453 | err = mv88e6xxx_serdes_irq_disable(chip, port, lane); |
| 2454 | |
| 2455 | /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */ |
| 2456 | mv88e6xxx_reg_unlock(chip); |
| 2457 | free_irq(irq, dev_id); |
| 2458 | mv88e6xxx_reg_lock(chip); |
| 2459 | |
| 2460 | dev_id->serdes_irq = 0; |
| 2461 | |
| 2462 | return err; |
| 2463 | } |
| 2464 | |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2465 | static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port, |
| 2466 | bool on) |
| 2467 | { |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2468 | u8 lane; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2469 | int err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2470 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2471 | lane = mv88e6xxx_serdes_get_lane(chip, port); |
| 2472 | if (!lane) |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2473 | return 0; |
| 2474 | |
| 2475 | if (on) { |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2476 | err = mv88e6xxx_serdes_power_up(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2477 | if (err) |
| 2478 | return err; |
| 2479 | |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2480 | err = mv88e6xxx_serdes_irq_request(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2481 | } else { |
Vivien Didelot | 45de77f | 2019-08-31 16:18:36 -0400 | [diff] [blame] | 2482 | err = mv88e6xxx_serdes_irq_free(chip, port, lane); |
| 2483 | if (err) |
| 2484 | return err; |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2485 | |
Vivien Didelot | dc272f6 | 2019-08-31 16:18:33 -0400 | [diff] [blame] | 2486 | err = mv88e6xxx_serdes_power_down(chip, port, lane); |
Vivien Didelot | fc0bc01 | 2019-08-19 16:00:53 -0400 | [diff] [blame] | 2487 | } |
| 2488 | |
| 2489 | return err; |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 2490 | } |
| 2491 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2492 | static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port) |
| 2493 | { |
| 2494 | struct dsa_switch *ds = chip->ds; |
| 2495 | int upstream_port; |
| 2496 | int err; |
| 2497 | |
Vivien Didelot | 07073c7 | 2017-12-05 15:34:13 -0500 | [diff] [blame] | 2498 | upstream_port = dsa_upstream_port(ds, port); |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2499 | if (chip->info->ops->port_set_upstream_port) { |
| 2500 | err = chip->info->ops->port_set_upstream_port(chip, port, |
| 2501 | upstream_port); |
| 2502 | if (err) |
| 2503 | return err; |
| 2504 | } |
| 2505 | |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2506 | if (port == upstream_port) { |
| 2507 | if (chip->info->ops->set_cpu_port) { |
| 2508 | err = chip->info->ops->set_cpu_port(chip, |
| 2509 | upstream_port); |
| 2510 | if (err) |
| 2511 | return err; |
| 2512 | } |
| 2513 | |
| 2514 | if (chip->info->ops->set_egress_port) { |
| 2515 | err = chip->info->ops->set_egress_port(chip, |
Iwan R Timmer | 5c74c54 | 2019-11-07 22:11:13 +0100 | [diff] [blame] | 2516 | MV88E6XXX_EGRESS_DIR_INGRESS, |
| 2517 | upstream_port); |
| 2518 | if (err) |
| 2519 | return err; |
| 2520 | |
| 2521 | err = chip->info->ops->set_egress_port(chip, |
| 2522 | MV88E6XXX_EGRESS_DIR_EGRESS, |
| 2523 | upstream_port); |
Vivien Didelot | 0ea54dd | 2017-12-05 15:34:11 -0500 | [diff] [blame] | 2524 | if (err) |
| 2525 | return err; |
| 2526 | } |
| 2527 | } |
| 2528 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2529 | return 0; |
| 2530 | } |
| 2531 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2532 | static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2533 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 2534 | struct dsa_switch *ds = chip->ds; |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2535 | int err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2536 | u16 reg; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2537 | |
Andrew Lunn | 7b89846 | 2018-08-09 15:38:47 +0200 | [diff] [blame] | 2538 | chip->ports[port].chip = chip; |
| 2539 | chip->ports[port].port = port; |
| 2540 | |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2541 | /* MAC Forcing register: don't force link, speed, duplex or flow control |
| 2542 | * state to any particular values on physical ports, but force the CPU |
| 2543 | * port and all DSA ports to their maximum bandwidth and full duplex. |
| 2544 | */ |
| 2545 | if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) |
| 2546 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, |
| 2547 | SPEED_MAX, DUPLEX_FULL, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2548 | PAUSE_OFF, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2549 | PHY_INTERFACE_MODE_NA); |
| 2550 | else |
| 2551 | err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, |
| 2552 | SPEED_UNFORCED, DUPLEX_UNFORCED, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 2553 | PAUSE_ON, |
Vivien Didelot | d78343d | 2016-11-04 03:23:36 +0100 | [diff] [blame] | 2554 | PHY_INTERFACE_MODE_NA); |
| 2555 | if (err) |
| 2556 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2557 | |
| 2558 | /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock, |
| 2559 | * disable Header mode, enable IGMP/MLD snooping, disable VLAN |
| 2560 | * tunneling, determine priority by looking at 802.1p and IP |
| 2561 | * priority fields (IP prio has precedence), and set STP state |
| 2562 | * to Forwarding. |
| 2563 | * |
| 2564 | * If this is the CPU link, use DSA or EDSA tagging depending |
| 2565 | * on which tagging mode was configured. |
| 2566 | * |
| 2567 | * If this is a link to another switch, use DSA tagging mode. |
| 2568 | * |
| 2569 | * If this is the upstream port for this switch, enable |
| 2570 | * forwarding of unknown unicasts and multicasts. |
| 2571 | */ |
Vivien Didelot | a89b433be | 2017-06-12 12:37:37 -0400 | [diff] [blame] | 2572 | reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP | |
| 2573 | MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP | |
| 2574 | MV88E6XXX_PORT_CTL0_STATE_FORWARDING; |
| 2575 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2576 | if (err) |
| 2577 | return err; |
Andrew Lunn | 6083ce7 | 2015-08-17 23:52:52 +0200 | [diff] [blame] | 2578 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2579 | err = mv88e6xxx_setup_port_mode(chip, port); |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 2580 | if (err) |
| 2581 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2582 | |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 2583 | err = mv88e6xxx_setup_egress_floods(chip, port); |
Vivien Didelot | 4314557 | 2017-03-11 16:12:59 -0500 | [diff] [blame] | 2584 | if (err) |
| 2585 | return err; |
| 2586 | |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2587 | /* 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] | 2588 | * 10240 bytes, disable 802.1q tags checking, don't discard tagged or |
Vivien Didelot | 8efdda4 | 2015-08-13 12:52:23 -0400 | [diff] [blame] | 2589 | * untagged frames on this port, do a destination address lookup on all |
| 2590 | * received packets as usual, disable ARP mirroring and don't send a |
| 2591 | * copy of all transmitted/received frames on this port to the CPU. |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2592 | */ |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2593 | err = mv88e6xxx_port_set_map_da(chip, port); |
| 2594 | if (err) |
| 2595 | return err; |
| 2596 | |
Vivien Didelot | fa371c8 | 2017-12-05 15:34:10 -0500 | [diff] [blame] | 2597 | err = mv88e6xxx_setup_upstream_port(chip, port); |
| 2598 | if (err) |
| 2599 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2600 | |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2601 | err = mv88e6xxx_port_set_8021q_mode(chip, port, |
Vivien Didelot | 81c6edb | 2017-06-12 12:37:41 -0400 | [diff] [blame] | 2602 | MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED); |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 2603 | if (err) |
| 2604 | return err; |
| 2605 | |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 2606 | if (chip->info->ops->port_set_jumbo_size) { |
| 2607 | err = chip->info->ops->port_set_jumbo_size(chip, port, 10240); |
Andrew Lunn | 5f43666 | 2016-12-03 04:45:17 +0100 | [diff] [blame] | 2608 | if (err) |
| 2609 | return err; |
| 2610 | } |
| 2611 | |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2612 | /* Port Association Vector: when learning source addresses |
| 2613 | * of packets, add the address to the address database using |
| 2614 | * a port bitmap that has only the bit for this port set and |
| 2615 | * the other bits clear. |
| 2616 | */ |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2617 | reg = 1 << port; |
Vivien Didelot | 996ecb8 | 2016-04-14 14:42:08 -0400 | [diff] [blame] | 2618 | /* Disable learning for CPU port */ |
| 2619 | if (dsa_is_cpu_port(ds, port)) |
Vivien Didelot | 65fa402 | 2016-04-14 14:42:07 -0400 | [diff] [blame] | 2620 | reg = 0; |
Andrew Lunn | 4c7ea3c | 2015-11-03 10:52:36 -0500 | [diff] [blame] | 2621 | |
Vivien Didelot | 2a4614e | 2017-06-12 12:37:43 -0400 | [diff] [blame] | 2622 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, |
| 2623 | reg); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2624 | if (err) |
| 2625 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2626 | |
| 2627 | /* Egress rate control 2: disable egress rate control. */ |
Vivien Didelot | 2cb8cb1 | 2017-06-12 12:37:42 -0400 | [diff] [blame] | 2628 | err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2, |
| 2629 | 0x0000); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2630 | if (err) |
| 2631 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2632 | |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 2633 | if (chip->info->ops->port_pause_limit) { |
| 2634 | err = chip->info->ops->port_pause_limit(chip, port, 0, 0); |
Andrew Lunn | b35d322a | 2016-12-03 04:45:19 +0100 | [diff] [blame] | 2635 | if (err) |
| 2636 | return err; |
| 2637 | } |
| 2638 | |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 2639 | if (chip->info->ops->port_disable_learn_limit) { |
| 2640 | err = chip->info->ops->port_disable_learn_limit(chip, port); |
| 2641 | if (err) |
| 2642 | return err; |
| 2643 | } |
| 2644 | |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 2645 | if (chip->info->ops->port_disable_pri_override) { |
| 2646 | err = chip->info->ops->port_disable_pri_override(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2647 | if (err) |
| 2648 | return err; |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2649 | } |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 2650 | |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 2651 | if (chip->info->ops->port_tag_remap) { |
| 2652 | err = chip->info->ops->port_tag_remap(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2653 | if (err) |
| 2654 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2655 | } |
| 2656 | |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 2657 | if (chip->info->ops->port_egress_rate_limiting) { |
| 2658 | err = chip->info->ops->port_egress_rate_limiting(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2659 | if (err) |
| 2660 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 2661 | } |
| 2662 | |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 2663 | if (chip->info->ops->port_setup_message_port) { |
| 2664 | err = chip->info->ops->port_setup_message_port(chip, port); |
| 2665 | if (err) |
| 2666 | return err; |
| 2667 | } |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2668 | |
Vivien Didelot | 207afda | 2016-04-14 14:42:09 -0400 | [diff] [blame] | 2669 | /* Port based VLAN map: give each port the same default address |
Vivien Didelot | b7666ef | 2016-02-26 13:16:06 -0500 | [diff] [blame] | 2670 | * database, and allow bidirectional communication between the |
| 2671 | * CPU and DSA port(s), and the other ports. |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2672 | */ |
Vivien Didelot | b4e48c5 | 2016-11-04 03:23:29 +0100 | [diff] [blame] | 2673 | err = mv88e6xxx_port_set_fid(chip, port, 0); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2674 | if (err) |
| 2675 | return err; |
Vivien Didelot | 2db9ce1 | 2016-02-26 13:16:04 -0500 | [diff] [blame] | 2676 | |
Vivien Didelot | 240ea3e | 2017-03-30 17:37:12 -0400 | [diff] [blame] | 2677 | err = mv88e6xxx_port_vlan_map(chip, port); |
Andrew Lunn | 0e7b992 | 2016-09-21 01:40:31 +0200 | [diff] [blame] | 2678 | if (err) |
| 2679 | return err; |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 2680 | |
| 2681 | /* Default VLAN ID and priority: don't set a default VLAN |
| 2682 | * ID, and set the default packet priority to zero. |
| 2683 | */ |
Vivien Didelot | b7929fb | 2017-06-12 12:37:40 -0400 | [diff] [blame] | 2684 | return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0); |
Andrew Lunn | dbde9e6 | 2015-05-06 01:09:48 +0200 | [diff] [blame] | 2685 | } |
| 2686 | |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2687 | static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port, |
| 2688 | struct phy_device *phydev) |
| 2689 | { |
| 2690 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2691 | int err; |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2692 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2693 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2694 | err = mv88e6xxx_serdes_power(chip, port, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2695 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2696 | |
| 2697 | return err; |
| 2698 | } |
| 2699 | |
Andrew Lunn | 75104db | 2019-02-24 20:44:43 +0100 | [diff] [blame] | 2700 | static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port) |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2701 | { |
| 2702 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2703 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2704 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 523a890 | 2017-05-26 18:02:42 -0400 | [diff] [blame] | 2705 | if (mv88e6xxx_serdes_power(chip, port, false)) |
| 2706 | dev_err(chip->dev, "failed to power off SERDES\n"); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2707 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 2708 | } |
| 2709 | |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2710 | static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds, |
| 2711 | unsigned int ageing_time) |
| 2712 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 2713 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2714 | int err; |
| 2715 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2716 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 720c634 | 2017-03-11 16:12:48 -0500 | [diff] [blame] | 2717 | err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 2718 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 2719 | |
| 2720 | return err; |
| 2721 | } |
| 2722 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 2723 | static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip) |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2724 | { |
| 2725 | int err; |
Vivien Didelot | 08a0126 | 2016-05-09 13:22:50 -0400 | [diff] [blame] | 2726 | |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 2727 | /* Initialize the statistics unit */ |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 2728 | if (chip->info->ops->stats_set_histogram) { |
| 2729 | err = chip->info->ops->stats_set_histogram(chip); |
| 2730 | if (err) |
| 2731 | return err; |
| 2732 | } |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 2733 | |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 2734 | return mv88e6xxx_g1_stats_clear(chip); |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 2735 | } |
| 2736 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 2737 | /* Check if the errata has already been applied. */ |
| 2738 | static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip) |
| 2739 | { |
| 2740 | int port; |
| 2741 | int err; |
| 2742 | u16 val; |
| 2743 | |
| 2744 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 2745 | err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 2746 | if (err) { |
| 2747 | dev_err(chip->dev, |
| 2748 | "Error reading hidden register: %d\n", err); |
| 2749 | return false; |
| 2750 | } |
| 2751 | if (val != 0x01c0) |
| 2752 | return false; |
| 2753 | } |
| 2754 | |
| 2755 | return true; |
| 2756 | } |
| 2757 | |
| 2758 | /* The 6390 copper ports have an errata which require poking magic |
| 2759 | * values into undocumented hidden registers and then performing a |
| 2760 | * software reset. |
| 2761 | */ |
| 2762 | static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip) |
| 2763 | { |
| 2764 | int port; |
| 2765 | int err; |
| 2766 | |
| 2767 | if (mv88e6390_setup_errata_applied(chip)) |
| 2768 | return 0; |
| 2769 | |
| 2770 | /* Set the ports into blocking mode */ |
| 2771 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
| 2772 | err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED); |
| 2773 | if (err) |
| 2774 | return err; |
| 2775 | } |
| 2776 | |
| 2777 | for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { |
Marek Behún | 6090701 | 2019-08-26 23:31:51 +0200 | [diff] [blame] | 2778 | err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0); |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 2779 | if (err) |
| 2780 | return err; |
| 2781 | } |
| 2782 | |
| 2783 | return mv88e6xxx_software_reset(chip); |
| 2784 | } |
| 2785 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 2786 | enum mv88e6xxx_devlink_param_id { |
| 2787 | MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, |
| 2788 | MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH, |
| 2789 | }; |
| 2790 | |
| 2791 | static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id, |
| 2792 | struct devlink_param_gset_ctx *ctx) |
| 2793 | { |
| 2794 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2795 | int err; |
| 2796 | |
| 2797 | mv88e6xxx_reg_lock(chip); |
| 2798 | |
| 2799 | switch (id) { |
| 2800 | case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH: |
| 2801 | err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8); |
| 2802 | break; |
| 2803 | default: |
| 2804 | err = -EOPNOTSUPP; |
| 2805 | break; |
| 2806 | } |
| 2807 | |
| 2808 | mv88e6xxx_reg_unlock(chip); |
| 2809 | |
| 2810 | return err; |
| 2811 | } |
| 2812 | |
| 2813 | static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id, |
| 2814 | struct devlink_param_gset_ctx *ctx) |
| 2815 | { |
| 2816 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2817 | int err; |
| 2818 | |
| 2819 | mv88e6xxx_reg_lock(chip); |
| 2820 | |
| 2821 | switch (id) { |
| 2822 | case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH: |
| 2823 | err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8); |
| 2824 | break; |
| 2825 | default: |
| 2826 | err = -EOPNOTSUPP; |
| 2827 | break; |
| 2828 | } |
| 2829 | |
| 2830 | mv88e6xxx_reg_unlock(chip); |
| 2831 | |
| 2832 | return err; |
| 2833 | } |
| 2834 | |
| 2835 | static const struct devlink_param mv88e6xxx_devlink_params[] = { |
| 2836 | DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH, |
| 2837 | "ATU_hash", DEVLINK_PARAM_TYPE_U8, |
| 2838 | BIT(DEVLINK_PARAM_CMODE_RUNTIME)), |
| 2839 | }; |
| 2840 | |
| 2841 | static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds) |
| 2842 | { |
| 2843 | return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params, |
| 2844 | ARRAY_SIZE(mv88e6xxx_devlink_params)); |
| 2845 | } |
| 2846 | |
| 2847 | static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds) |
| 2848 | { |
| 2849 | dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params, |
| 2850 | ARRAY_SIZE(mv88e6xxx_devlink_params)); |
| 2851 | } |
| 2852 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 2853 | enum mv88e6xxx_devlink_resource_id { |
| 2854 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2855 | MV88E6XXX_RESOURCE_ID_ATU_BIN_0, |
| 2856 | MV88E6XXX_RESOURCE_ID_ATU_BIN_1, |
| 2857 | MV88E6XXX_RESOURCE_ID_ATU_BIN_2, |
| 2858 | MV88E6XXX_RESOURCE_ID_ATU_BIN_3, |
| 2859 | }; |
| 2860 | |
| 2861 | static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip, |
| 2862 | u16 bin) |
| 2863 | { |
| 2864 | u16 occupancy = 0; |
| 2865 | int err; |
| 2866 | |
| 2867 | mv88e6xxx_reg_lock(chip); |
| 2868 | |
| 2869 | err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL, |
| 2870 | bin); |
| 2871 | if (err) { |
| 2872 | dev_err(chip->dev, "failed to set ATU stats kind/bin\n"); |
| 2873 | goto unlock; |
| 2874 | } |
| 2875 | |
| 2876 | err = mv88e6xxx_g1_atu_get_next(chip, 0); |
| 2877 | if (err) { |
| 2878 | dev_err(chip->dev, "failed to perform ATU get next\n"); |
| 2879 | goto unlock; |
| 2880 | } |
| 2881 | |
| 2882 | err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy); |
| 2883 | if (err) { |
| 2884 | dev_err(chip->dev, "failed to get ATU stats\n"); |
| 2885 | goto unlock; |
| 2886 | } |
| 2887 | |
Andrew Lunn | 012fc74 | 2020-03-11 21:02:31 +0100 | [diff] [blame] | 2888 | occupancy &= MV88E6XXX_G2_ATU_STATS_MASK; |
| 2889 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 2890 | unlock: |
| 2891 | mv88e6xxx_reg_unlock(chip); |
| 2892 | |
| 2893 | return occupancy; |
| 2894 | } |
| 2895 | |
| 2896 | static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv) |
| 2897 | { |
| 2898 | struct mv88e6xxx_chip *chip = priv; |
| 2899 | |
| 2900 | return mv88e6xxx_devlink_atu_bin_get(chip, |
| 2901 | MV88E6XXX_G2_ATU_STATS_BIN_0); |
| 2902 | } |
| 2903 | |
| 2904 | static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv) |
| 2905 | { |
| 2906 | struct mv88e6xxx_chip *chip = priv; |
| 2907 | |
| 2908 | return mv88e6xxx_devlink_atu_bin_get(chip, |
| 2909 | MV88E6XXX_G2_ATU_STATS_BIN_1); |
| 2910 | } |
| 2911 | |
| 2912 | static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv) |
| 2913 | { |
| 2914 | struct mv88e6xxx_chip *chip = priv; |
| 2915 | |
| 2916 | return mv88e6xxx_devlink_atu_bin_get(chip, |
| 2917 | MV88E6XXX_G2_ATU_STATS_BIN_2); |
| 2918 | } |
| 2919 | |
| 2920 | static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv) |
| 2921 | { |
| 2922 | struct mv88e6xxx_chip *chip = priv; |
| 2923 | |
| 2924 | return mv88e6xxx_devlink_atu_bin_get(chip, |
| 2925 | MV88E6XXX_G2_ATU_STATS_BIN_3); |
| 2926 | } |
| 2927 | |
| 2928 | static u64 mv88e6xxx_devlink_atu_get(void *priv) |
| 2929 | { |
| 2930 | return mv88e6xxx_devlink_atu_bin_0_get(priv) + |
| 2931 | mv88e6xxx_devlink_atu_bin_1_get(priv) + |
| 2932 | mv88e6xxx_devlink_atu_bin_2_get(priv) + |
| 2933 | mv88e6xxx_devlink_atu_bin_3_get(priv); |
| 2934 | } |
| 2935 | |
| 2936 | static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds) |
| 2937 | { |
| 2938 | struct devlink_resource_size_params size_params; |
| 2939 | struct mv88e6xxx_chip *chip = ds->priv; |
| 2940 | int err; |
| 2941 | |
| 2942 | devlink_resource_size_params_init(&size_params, |
| 2943 | mv88e6xxx_num_macs(chip), |
| 2944 | mv88e6xxx_num_macs(chip), |
| 2945 | 1, DEVLINK_RESOURCE_UNIT_ENTRY); |
| 2946 | |
| 2947 | err = dsa_devlink_resource_register(ds, "ATU", |
| 2948 | mv88e6xxx_num_macs(chip), |
| 2949 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2950 | DEVLINK_RESOURCE_ID_PARENT_TOP, |
| 2951 | &size_params); |
| 2952 | if (err) |
| 2953 | goto out; |
| 2954 | |
| 2955 | devlink_resource_size_params_init(&size_params, |
| 2956 | mv88e6xxx_num_macs(chip) / 4, |
| 2957 | mv88e6xxx_num_macs(chip) / 4, |
| 2958 | 1, DEVLINK_RESOURCE_UNIT_ENTRY); |
| 2959 | |
| 2960 | err = dsa_devlink_resource_register(ds, "ATU_bin_0", |
| 2961 | mv88e6xxx_num_macs(chip) / 4, |
| 2962 | MV88E6XXX_RESOURCE_ID_ATU_BIN_0, |
| 2963 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2964 | &size_params); |
| 2965 | if (err) |
| 2966 | goto out; |
| 2967 | |
| 2968 | err = dsa_devlink_resource_register(ds, "ATU_bin_1", |
| 2969 | mv88e6xxx_num_macs(chip) / 4, |
| 2970 | MV88E6XXX_RESOURCE_ID_ATU_BIN_1, |
| 2971 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2972 | &size_params); |
| 2973 | if (err) |
| 2974 | goto out; |
| 2975 | |
| 2976 | err = dsa_devlink_resource_register(ds, "ATU_bin_2", |
| 2977 | mv88e6xxx_num_macs(chip) / 4, |
| 2978 | MV88E6XXX_RESOURCE_ID_ATU_BIN_2, |
| 2979 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2980 | &size_params); |
| 2981 | if (err) |
| 2982 | goto out; |
| 2983 | |
| 2984 | err = dsa_devlink_resource_register(ds, "ATU_bin_3", |
| 2985 | mv88e6xxx_num_macs(chip) / 4, |
| 2986 | MV88E6XXX_RESOURCE_ID_ATU_BIN_3, |
| 2987 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2988 | &size_params); |
| 2989 | if (err) |
| 2990 | goto out; |
| 2991 | |
| 2992 | dsa_devlink_resource_occ_get_register(ds, |
| 2993 | MV88E6XXX_RESOURCE_ID_ATU, |
| 2994 | mv88e6xxx_devlink_atu_get, |
| 2995 | chip); |
| 2996 | |
| 2997 | dsa_devlink_resource_occ_get_register(ds, |
| 2998 | MV88E6XXX_RESOURCE_ID_ATU_BIN_0, |
| 2999 | mv88e6xxx_devlink_atu_bin_0_get, |
| 3000 | chip); |
| 3001 | |
| 3002 | dsa_devlink_resource_occ_get_register(ds, |
| 3003 | MV88E6XXX_RESOURCE_ID_ATU_BIN_1, |
| 3004 | mv88e6xxx_devlink_atu_bin_1_get, |
| 3005 | chip); |
| 3006 | |
| 3007 | dsa_devlink_resource_occ_get_register(ds, |
| 3008 | MV88E6XXX_RESOURCE_ID_ATU_BIN_2, |
| 3009 | mv88e6xxx_devlink_atu_bin_2_get, |
| 3010 | chip); |
| 3011 | |
| 3012 | dsa_devlink_resource_occ_get_register(ds, |
| 3013 | MV88E6XXX_RESOURCE_ID_ATU_BIN_3, |
| 3014 | mv88e6xxx_devlink_atu_bin_3_get, |
| 3015 | chip); |
| 3016 | |
| 3017 | return 0; |
| 3018 | |
| 3019 | out: |
| 3020 | dsa_devlink_resources_unregister(ds); |
| 3021 | return err; |
| 3022 | } |
| 3023 | |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3024 | static void mv88e6xxx_teardown(struct dsa_switch *ds) |
| 3025 | { |
| 3026 | mv88e6xxx_teardown_devlink_params(ds); |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3027 | dsa_devlink_resources_unregister(ds); |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3028 | } |
| 3029 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 3030 | static int mv88e6xxx_setup(struct dsa_switch *ds) |
Guenter Roeck | acdaffc | 2015-03-26 18:36:28 -0700 | [diff] [blame] | 3031 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3032 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3033 | u8 cmode; |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3034 | int err; |
Vivien Didelot | a1a6a4d | 2016-05-09 13:22:56 -0400 | [diff] [blame] | 3035 | int i; |
| 3036 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3037 | chip->ds = ds; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3038 | ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3039 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3040 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 552238b | 2016-05-09 13:22:49 -0400 | [diff] [blame] | 3041 | |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3042 | if (chip->info->ops->setup_errata) { |
| 3043 | err = chip->info->ops->setup_errata(chip); |
| 3044 | if (err) |
| 3045 | goto unlock; |
| 3046 | } |
| 3047 | |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3048 | /* Cache the cmode of each port. */ |
| 3049 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
| 3050 | if (chip->info->ops->port_get_cmode) { |
| 3051 | err = chip->info->ops->port_get_cmode(chip, i, &cmode); |
| 3052 | if (err) |
Dan Carpenter | e29129f | 2018-08-14 12:09:05 +0300 | [diff] [blame] | 3053 | goto unlock; |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3054 | |
| 3055 | chip->ports[i].cmode = cmode; |
| 3056 | } |
| 3057 | } |
| 3058 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3059 | /* Setup Switch Port Registers */ |
Vivien Didelot | 370b4ff | 2016-09-29 12:21:57 -0400 | [diff] [blame] | 3060 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) { |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3061 | if (dsa_is_unused_port(ds, i)) |
| 3062 | continue; |
| 3063 | |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3064 | /* Prevent the use of an invalid port. */ |
Vivien Didelot | b759f52 | 2019-08-19 16:00:52 -0400 | [diff] [blame] | 3065 | if (mv88e6xxx_is_invalid_port(chip, i)) { |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 3066 | dev_err(chip->dev, "port %d is invalid\n", i); |
| 3067 | err = -EINVAL; |
| 3068 | goto unlock; |
| 3069 | } |
| 3070 | |
Vivien Didelot | 9729934 | 2016-07-18 20:45:30 -0400 | [diff] [blame] | 3071 | err = mv88e6xxx_setup_port(chip, i); |
| 3072 | if (err) |
| 3073 | goto unlock; |
| 3074 | } |
| 3075 | |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3076 | err = mv88e6xxx_irl_setup(chip); |
| 3077 | if (err) |
| 3078 | goto unlock; |
| 3079 | |
Vivien Didelot | 04a69a1 | 2017-10-13 14:18:05 -0400 | [diff] [blame] | 3080 | err = mv88e6xxx_mac_setup(chip); |
| 3081 | if (err) |
| 3082 | goto unlock; |
| 3083 | |
Vivien Didelot | 1b17aed | 2017-05-26 18:03:05 -0400 | [diff] [blame] | 3084 | err = mv88e6xxx_phy_setup(chip); |
| 3085 | if (err) |
| 3086 | goto unlock; |
| 3087 | |
Vivien Didelot | b486d7c | 2017-05-01 14:05:13 -0400 | [diff] [blame] | 3088 | err = mv88e6xxx_vtu_setup(chip); |
| 3089 | if (err) |
| 3090 | goto unlock; |
| 3091 | |
Vivien Didelot | 8122899 | 2017-03-30 17:37:08 -0400 | [diff] [blame] | 3092 | err = mv88e6xxx_pvt_setup(chip); |
| 3093 | if (err) |
| 3094 | goto unlock; |
| 3095 | |
Vivien Didelot | a2ac29d | 2017-03-11 16:12:49 -0500 | [diff] [blame] | 3096 | err = mv88e6xxx_atu_setup(chip); |
| 3097 | if (err) |
| 3098 | goto unlock; |
| 3099 | |
Andrew Lunn | 87fa886 | 2017-11-09 22:29:56 +0100 | [diff] [blame] | 3100 | err = mv88e6xxx_broadcast_setup(chip, 0); |
| 3101 | if (err) |
| 3102 | goto unlock; |
| 3103 | |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3104 | err = mv88e6xxx_pot_setup(chip); |
| 3105 | if (err) |
| 3106 | goto unlock; |
| 3107 | |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3108 | err = mv88e6xxx_rmu_setup(chip); |
| 3109 | if (err) |
| 3110 | goto unlock; |
| 3111 | |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3112 | err = mv88e6xxx_rsvd2cpu_setup(chip); |
| 3113 | if (err) |
| 3114 | goto unlock; |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3115 | |
Vivien Didelot | b28f872 | 2018-04-26 21:56:44 -0400 | [diff] [blame] | 3116 | err = mv88e6xxx_trunk_setup(chip); |
| 3117 | if (err) |
| 3118 | goto unlock; |
| 3119 | |
Vivien Didelot | c7f047b | 2018-04-26 21:56:45 -0400 | [diff] [blame] | 3120 | err = mv88e6xxx_devmap_setup(chip); |
| 3121 | if (err) |
| 3122 | goto unlock; |
| 3123 | |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3124 | err = mv88e6xxx_pri_setup(chip); |
| 3125 | if (err) |
| 3126 | goto unlock; |
| 3127 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3128 | /* Setup PTP Hardware Clock and timestamping */ |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3129 | if (chip->info->ptp_support) { |
| 3130 | err = mv88e6xxx_ptp_setup(chip); |
| 3131 | if (err) |
| 3132 | goto unlock; |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 3133 | |
| 3134 | err = mv88e6xxx_hwtstamp_setup(chip); |
| 3135 | if (err) |
| 3136 | goto unlock; |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 3137 | } |
| 3138 | |
Vivien Didelot | 447b1bb | 2018-05-11 17:16:36 -0400 | [diff] [blame] | 3139 | err = mv88e6xxx_stats_setup(chip); |
| 3140 | if (err) |
| 3141 | goto unlock; |
| 3142 | |
Vivien Didelot | 6b17e86 | 2015-08-13 12:52:18 -0400 | [diff] [blame] | 3143 | unlock: |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3144 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | db687a5 | 2015-06-20 21:31:29 +0200 | [diff] [blame] | 3145 | |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3146 | if (err) |
| 3147 | return err; |
| 3148 | |
| 3149 | /* Have to be called without holding the register lock, since |
| 3150 | * they take the devlink lock, and we later take the locks in |
| 3151 | * the reverse order when getting/setting parameters or |
| 3152 | * resource occupancy. |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3153 | */ |
Andrew Lunn | e0c69ca | 2019-11-05 01:13:01 +0100 | [diff] [blame] | 3154 | err = mv88e6xxx_setup_devlink_resources(ds); |
| 3155 | if (err) |
| 3156 | return err; |
| 3157 | |
| 3158 | err = mv88e6xxx_setup_devlink_params(ds); |
| 3159 | if (err) |
| 3160 | dsa_devlink_resources_unregister(ds); |
| 3161 | |
| 3162 | return err; |
Andrew Lunn | 54d792f | 2015-05-06 01:09:47 +0200 | [diff] [blame] | 3163 | } |
| 3164 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3165 | 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] | 3166 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3167 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3168 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3169 | u16 val; |
| 3170 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3171 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3172 | if (!chip->info->ops->phy_read) |
| 3173 | return -EOPNOTSUPP; |
| 3174 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3175 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3176 | err = chip->info->ops->phy_read(chip, bus, phy, reg, &val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3177 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3178 | |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 3179 | if (reg == MII_PHYSID2) { |
Andrew Lunn | ddc49ac | 2018-11-12 18:51:01 +0100 | [diff] [blame] | 3180 | /* Some internal PHYs don't have a model number. */ |
| 3181 | if (chip->info->family != MV88E6XXX_FAMILY_6165) |
| 3182 | /* Then there is the 6165 family. It gets is |
| 3183 | * PHYs correct. But it can also have two |
| 3184 | * SERDES interfaces in the PHY address |
| 3185 | * space. And these don't have a model |
| 3186 | * number. But they are not PHYs, so we don't |
| 3187 | * want to give them something a PHY driver |
| 3188 | * will recognise. |
| 3189 | * |
| 3190 | * Use the mv88e6390 family model number |
| 3191 | * instead, for anything which really could be |
| 3192 | * a PHY, |
| 3193 | */ |
| 3194 | if (!(val & 0x3f0)) |
| 3195 | val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4; |
Andrew Lunn | da9f330 | 2017-02-01 03:40:05 +0100 | [diff] [blame] | 3196 | } |
| 3197 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3198 | return err ? err : val; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3199 | } |
| 3200 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3201 | 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] | 3202 | { |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3203 | struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv; |
| 3204 | struct mv88e6xxx_chip *chip = mdio_bus->chip; |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3205 | int err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3206 | |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3207 | if (!chip->info->ops->phy_write) |
| 3208 | return -EOPNOTSUPP; |
| 3209 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3210 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | ee26a22 | 2017-01-24 14:53:48 +0100 | [diff] [blame] | 3211 | err = chip->info->ops->phy_write(chip, bus, phy, reg, val); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3212 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 3213 | |
| 3214 | return err; |
Andrew Lunn | fd3a0ee | 2015-04-02 04:06:36 +0200 | [diff] [blame] | 3215 | } |
| 3216 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3217 | static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip, |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3218 | struct device_node *np, |
| 3219 | bool external) |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3220 | { |
| 3221 | static int index; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3222 | struct mv88e6xxx_mdio_bus *mdio_bus; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3223 | struct mii_bus *bus; |
| 3224 | int err; |
| 3225 | |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3226 | if (external) { |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3227 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3228 | err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3229 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | 2510bab | 2018-02-22 01:51:49 +0100 | [diff] [blame] | 3230 | |
| 3231 | if (err) |
| 3232 | return err; |
| 3233 | } |
| 3234 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3235 | bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus)); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3236 | if (!bus) |
| 3237 | return -ENOMEM; |
| 3238 | |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3239 | mdio_bus = bus->priv; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3240 | mdio_bus->bus = bus; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3241 | mdio_bus->chip = chip; |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3242 | INIT_LIST_HEAD(&mdio_bus->list); |
| 3243 | mdio_bus->external = external; |
Andrew Lunn | 0dd12d5 | 2017-01-24 14:53:49 +0100 | [diff] [blame] | 3244 | |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3245 | if (np) { |
| 3246 | bus->name = np->full_name; |
Rob Herring | f7ce910 | 2017-07-18 16:43:19 -0500 | [diff] [blame] | 3247 | snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3248 | } else { |
| 3249 | bus->name = "mv88e6xxx SMI"; |
| 3250 | snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++); |
| 3251 | } |
| 3252 | |
| 3253 | bus->read = mv88e6xxx_mdio_read; |
| 3254 | bus->write = mv88e6xxx_mdio_write; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3255 | bus->parent = chip->dev; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3256 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3257 | if (!external) { |
| 3258 | err = mv88e6xxx_g2_irq_mdio_setup(chip, bus); |
| 3259 | if (err) |
| 3260 | return err; |
| 3261 | } |
| 3262 | |
Florian Fainelli | 00e798c | 2018-05-15 16:56:19 -0700 | [diff] [blame] | 3263 | err = of_mdiobus_register(bus, np); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3264 | if (err) { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 3265 | dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err); |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3266 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3267 | return err; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3268 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3269 | |
| 3270 | if (external) |
| 3271 | list_add_tail(&mdio_bus->list, &chip->mdios); |
| 3272 | else |
| 3273 | list_add(&mdio_bus->list, &chip->mdios); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3274 | |
| 3275 | return 0; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 3276 | } |
| 3277 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3278 | static const struct of_device_id mv88e6xxx_mdio_external_match[] = { |
| 3279 | { .compatible = "marvell,mv88e6xxx-mdio-external", |
| 3280 | .data = (void *)true }, |
| 3281 | { }, |
| 3282 | }; |
| 3283 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3284 | static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) |
| 3285 | |
| 3286 | { |
| 3287 | struct mv88e6xxx_mdio_bus *mdio_bus; |
| 3288 | struct mii_bus *bus; |
| 3289 | |
| 3290 | list_for_each_entry(mdio_bus, &chip->mdios, list) { |
| 3291 | bus = mdio_bus->bus; |
| 3292 | |
Andrew Lunn | 6f88284 | 2018-03-17 20:32:05 +0100 | [diff] [blame] | 3293 | if (!mdio_bus->external) |
| 3294 | mv88e6xxx_g2_irq_mdio_free(chip, bus); |
| 3295 | |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3296 | mdiobus_unregister(bus); |
| 3297 | } |
| 3298 | } |
| 3299 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3300 | static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, |
| 3301 | struct device_node *np) |
| 3302 | { |
| 3303 | const struct of_device_id *match; |
| 3304 | struct device_node *child; |
| 3305 | int err; |
| 3306 | |
| 3307 | /* Always register one mdio bus for the internal/default mdio |
| 3308 | * bus. This maybe represented in the device tree, but is |
| 3309 | * optional. |
| 3310 | */ |
| 3311 | child = of_get_child_by_name(np, "mdio"); |
| 3312 | err = mv88e6xxx_mdio_register(chip, child, false); |
| 3313 | if (err) |
| 3314 | return err; |
| 3315 | |
| 3316 | /* Walk the device tree, and see if there are any other nodes |
| 3317 | * which say they are compatible with the external mdio |
| 3318 | * bus. |
| 3319 | */ |
| 3320 | for_each_available_child_of_node(np, child) { |
| 3321 | match = of_match_node(mv88e6xxx_mdio_external_match, child); |
| 3322 | if (match) { |
| 3323 | err = mv88e6xxx_mdio_register(chip, child, true); |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3324 | if (err) { |
| 3325 | mv88e6xxx_mdios_unregister(chip); |
Nishka Dasgupta | 78e4204 | 2019-07-23 16:13:07 +0530 | [diff] [blame] | 3326 | of_node_put(child); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3327 | return err; |
Andrew Lunn | 3126aee | 2017-12-07 01:05:57 +0100 | [diff] [blame] | 3328 | } |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 3329 | } |
| 3330 | } |
| 3331 | |
| 3332 | return 0; |
| 3333 | } |
| 3334 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3335 | static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) |
| 3336 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3337 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3338 | |
| 3339 | return chip->eeprom_len; |
| 3340 | } |
| 3341 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3342 | static int mv88e6xxx_get_eeprom(struct dsa_switch *ds, |
| 3343 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3344 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3345 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3346 | int err; |
| 3347 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3348 | if (!chip->info->ops->get_eeprom) |
| 3349 | return -EOPNOTSUPP; |
| 3350 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3351 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3352 | err = chip->info->ops->get_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3353 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3354 | |
| 3355 | if (err) |
| 3356 | return err; |
| 3357 | |
| 3358 | eeprom->magic = 0xc3ec4951; |
| 3359 | |
| 3360 | return 0; |
| 3361 | } |
| 3362 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3363 | static int mv88e6xxx_set_eeprom(struct dsa_switch *ds, |
| 3364 | struct ethtool_eeprom *eeprom, u8 *data) |
| 3365 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 3366 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3367 | int err; |
| 3368 | |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3369 | if (!chip->info->ops->set_eeprom) |
| 3370 | return -EOPNOTSUPP; |
| 3371 | |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3372 | if (eeprom->magic != 0xc3ec4951) |
| 3373 | return -EINVAL; |
| 3374 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3375 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3376 | err = chip->info->ops->set_eeprom(chip, eeprom, data); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 3377 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 855b193 | 2016-07-20 18:18:35 -0400 | [diff] [blame] | 3378 | |
| 3379 | return err; |
| 3380 | } |
| 3381 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3382 | static const struct mv88e6xxx_ops mv88e6085_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3383 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3384 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3385 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3386 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3387 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3388 | .phy_read = mv88e6185_phy_ppu_read, |
| 3389 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3390 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3391 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3392 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3393 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3394 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3395 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3396 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3397 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3398 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3399 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3400 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3401 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3402 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3403 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3404 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3405 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3406 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3407 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3408 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3409 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3410 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3411 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3412 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3413 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3414 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3415 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3416 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3417 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3418 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3419 | }; |
| 3420 | |
| 3421 | static const struct mv88e6xxx_ops mv88e6095_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3422 | /* MV88E6XXX_FAMILY_6095 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3423 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3424 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3425 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3426 | .phy_read = mv88e6185_phy_ppu_read, |
| 3427 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3428 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3429 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3430 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3431 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3432 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3433 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3434 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3435 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3436 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3437 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3438 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3439 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3440 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3441 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3442 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3443 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3444 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3445 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3446 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3447 | }; |
| 3448 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3449 | static const struct mv88e6xxx_ops mv88e6097_ops = { |
Stefan Eichenberger | 15da3cc | 2016-11-25 09:41:30 +0100 | [diff] [blame] | 3450 | /* MV88E6XXX_FAMILY_6097 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3451 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3452 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3453 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3454 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3455 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3456 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3457 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3458 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3459 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3460 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3461 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3462 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3463 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3464 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3465 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3466 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3467 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3468 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3469 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3470 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3471 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3472 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3473 | .stats_get_strings = mv88e6095_stats_get_strings, |
| 3474 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3475 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3476 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Volodymyr Bendiuga | 91eaa47 | 2017-02-14 11:29:30 +0100 | [diff] [blame] | 3477 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3478 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3479 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3480 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3481 | .rmu_disable = mv88e6085_g1_rmu_disable, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3482 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3483 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3484 | .phylink_validate = mv88e6185_phylink_validate, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 3485 | }; |
| 3486 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3487 | static const struct mv88e6xxx_ops mv88e6123_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3488 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3489 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3490 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3491 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3492 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3493 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3494 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3495 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3496 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3497 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3498 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3499 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3500 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3501 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3502 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 0ac64c3 | 2017-06-02 23:22:46 +0200 | [diff] [blame] | 3503 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3504 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3505 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3506 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3507 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3508 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3509 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3510 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3511 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3512 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3513 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3514 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3515 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3516 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3517 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3518 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3519 | }; |
| 3520 | |
| 3521 | static const struct mv88e6xxx_ops mv88e6131_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3522 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3523 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3524 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3525 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3526 | .phy_read = mv88e6185_phy_ppu_read, |
| 3527 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3528 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3529 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3530 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3531 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3532 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3533 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3534 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3535 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3536 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3537 | .port_pause_limit = mv88e6097_port_pause_limit, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 3538 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3539 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3540 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3541 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3542 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3543 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3544 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3545 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3546 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3547 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3548 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3549 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3550 | .ppu_enable = mv88e6185_g1_ppu_enable, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 3551 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3552 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3553 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3554 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3555 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3556 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3557 | }; |
| 3558 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3559 | static const struct mv88e6xxx_ops mv88e6141_ops = { |
| 3560 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3561 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3562 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3563 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3564 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3565 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 3566 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3567 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3568 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3569 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3570 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3571 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3572 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3573 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 3574 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 3575 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
| 3576 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3577 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3578 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3579 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3580 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 3581 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3582 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 3583 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3584 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3585 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3586 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3587 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3588 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 3589 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3590 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3591 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3592 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 3593 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3594 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3595 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3596 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3597 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 3598 | .serdes_power = mv88e6390_serdes_power, |
| 3599 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3600 | /* Check status register pause & lpa register */ |
| 3601 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 3602 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 3603 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 3604 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3605 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3606 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3607 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3608 | .gpio_ops = &mv88e6352_gpio_ops, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 3609 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 3610 | }; |
| 3611 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3612 | static const struct mv88e6xxx_ops mv88e6161_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3613 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3614 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3615 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3616 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3617 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | ec8378b | 2017-06-02 23:22:45 +0200 | [diff] [blame] | 3618 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3619 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3620 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3621 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3622 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3623 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3624 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3625 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3626 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3627 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3628 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3629 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3630 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3631 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3632 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a6da21b | 2019-03-01 23:43:39 +0100 | [diff] [blame] | 3633 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3634 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3635 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3636 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3637 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3638 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3639 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3640 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3641 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3642 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3643 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3644 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3645 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3646 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3647 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3648 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3649 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3650 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3651 | }; |
| 3652 | |
| 3653 | static const struct mv88e6xxx_ops mv88e6165_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3654 | /* MV88E6XXX_FAMILY_6165 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3655 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3656 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3657 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3658 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Andrew Lunn | efb3e74 | 2017-01-24 14:53:47 +0100 | [diff] [blame] | 3659 | .phy_read = mv88e6165_phy_read, |
| 3660 | .phy_write = mv88e6165_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3661 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3662 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3663 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3664 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3665 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3666 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3667 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3668 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3669 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3670 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3671 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3672 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3673 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3674 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3675 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3676 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3677 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3678 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3679 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3680 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3681 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Andrew Lunn | a469a61 | 2018-07-18 22:38:21 +0200 | [diff] [blame] | 3682 | .avb_ops = &mv88e6165_avb_ops, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 3683 | .ptp_ops = &mv88e6165_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3684 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3685 | }; |
| 3686 | |
| 3687 | static const struct mv88e6xxx_ops mv88e6171_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3688 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3689 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3690 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3691 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3692 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3693 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3694 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3695 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3696 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3697 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3698 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3699 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3700 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3701 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3702 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3703 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3704 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3705 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3706 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3707 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3708 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3709 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3710 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3711 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3712 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3713 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3714 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3715 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3716 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3717 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3718 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3719 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3720 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3721 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3722 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3723 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3724 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3725 | }; |
| 3726 | |
| 3727 | static const struct mv88e6xxx_ops mv88e6172_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3728 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3729 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3730 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3731 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3732 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3733 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3734 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3735 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3736 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3737 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3738 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3739 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3740 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3741 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3742 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3743 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3744 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3745 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3746 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3747 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3748 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3749 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3750 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3751 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3752 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3753 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3754 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3755 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3756 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3757 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3758 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3759 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3760 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3761 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3762 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3763 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3764 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3765 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3766 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3767 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3768 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3769 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 3770 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 3771 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 3772 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3773 | .serdes_power = mv88e6352_serdes_power, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3774 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3775 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3776 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3777 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3778 | }; |
| 3779 | |
| 3780 | static const struct mv88e6xxx_ops mv88e6175_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3781 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3782 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3783 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3784 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3785 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3786 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3787 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3788 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 3789 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3790 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3791 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3792 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3793 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3794 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3795 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3796 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3797 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3798 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3799 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3800 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3801 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3802 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3803 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3804 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3805 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3806 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3807 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3808 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3809 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3810 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3811 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3812 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3813 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3814 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3815 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3816 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3817 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3818 | }; |
| 3819 | |
| 3820 | static const struct mv88e6xxx_ops mv88e6176_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3821 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3822 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3823 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3824 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 3825 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 3826 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3827 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3828 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3829 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3830 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 3831 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3832 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3833 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3834 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3835 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3836 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3837 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 3838 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3839 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3840 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3841 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3842 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3843 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3844 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3845 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3846 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3847 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3848 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3849 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3850 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3851 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3852 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3853 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3854 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3855 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3856 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3857 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3858 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3859 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3860 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 3861 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3862 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 3863 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 3864 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 3865 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 3866 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3867 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3868 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3869 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 3870 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 3871 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3872 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3873 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3874 | }; |
| 3875 | |
| 3876 | static const struct mv88e6xxx_ops mv88e6185_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3877 | /* MV88E6XXX_FAMILY_6185 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 3878 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 3879 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 3880 | .set_switch_mac = mv88e6xxx_g1_set_switch_mac, |
Vivien Didelot | 7e20cfb | 2017-05-26 18:03:06 -0400 | [diff] [blame] | 3881 | .phy_read = mv88e6185_phy_ppu_read, |
| 3882 | .phy_write = mv88e6185_phy_ppu_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 3883 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3884 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3885 | .port_set_frame_mode = mv88e6085_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3886 | .port_set_egress_floods = mv88e6185_port_set_egress_floods, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 3887 | .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting, |
Andrew Lunn | a23b296 | 2017-02-04 20:15:28 +0100 | [diff] [blame] | 3888 | .port_set_upstream_port = mv88e6095_port_set_upstream_port, |
Andrew Lunn | 54186b9 | 2018-08-09 15:38:37 +0200 | [diff] [blame] | 3889 | .port_set_pause = mv88e6185_port_set_pause, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3890 | .port_get_cmode = mv88e6185_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3891 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 3892 | .stats_snapshot = mv88e6xxx_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 3893 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3894 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 3895 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 3896 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3897 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 3898 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 3899 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 3900 | .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 02317e6 | 2018-05-09 11:38:49 -0400 | [diff] [blame] | 3901 | .set_cascade_port = mv88e6185_g1_set_cascade_port, |
Vivien Didelot | a199d8b | 2016-12-05 17:30:28 -0500 | [diff] [blame] | 3902 | .ppu_enable = mv88e6185_g1_ppu_enable, |
| 3903 | .ppu_disable = mv88e6185_g1_ppu_disable, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3904 | .reset = mv88e6185_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 3905 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 3906 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3907 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 3908 | }; |
| 3909 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3910 | static const struct mv88e6xxx_ops mv88e6190_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3911 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3912 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3913 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 3914 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3915 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3916 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3917 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3918 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3919 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3920 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3921 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3922 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3923 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3924 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3925 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3926 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3927 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3928 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3929 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3930 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3931 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 3932 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3933 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 3934 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3935 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3936 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3937 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 3938 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3939 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3940 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 3941 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 3942 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 3943 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 3944 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 3945 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 3946 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 3947 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 3948 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 3949 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 3950 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 3951 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 3952 | /* Check status register pause & lpa register */ |
| 3953 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 3954 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 3955 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 3956 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 3957 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 3958 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 3959 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 3960 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 3961 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 3962 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 3963 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 3964 | .phylink_validate = mv88e6390_phylink_validate, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 3965 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 3966 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3967 | }; |
| 3968 | |
| 3969 | static const struct mv88e6xxx_ops mv88e6190x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 3970 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 3971 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 3972 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 3973 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 3974 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3975 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 3976 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 3977 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 3978 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 3979 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 3980 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 3981 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 3982 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 3983 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3984 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 3985 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 3986 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 3987 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 3988 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 3989 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 3990 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 3991 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 3992 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 3993 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 3994 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 3995 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 3996 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 3997 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 3998 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 3999 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4000 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4001 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4002 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4003 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4004 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4005 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4006 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4007 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4008 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4009 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4010 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4011 | /* Check status register pause & lpa register */ |
| 4012 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4013 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4014 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4015 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4016 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4017 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4018 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4019 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4020 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4021 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4022 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4023 | .phylink_validate = mv88e6390_phylink_validate, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4024 | .gpio_ops = &mv88e6352_gpio_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4025 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4026 | }; |
| 4027 | |
| 4028 | static const struct mv88e6xxx_ops mv88e6191_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4029 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4030 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4031 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4032 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4033 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4034 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4035 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4036 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4037 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4038 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4039 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4040 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4041 | .port_tag_remap = mv88e6390_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4042 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4043 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4044 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4045 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4046 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4047 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4048 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4049 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4050 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4051 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4052 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4053 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4054 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4055 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4056 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4057 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4058 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4059 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4060 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4061 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4062 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4063 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4064 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4065 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4066 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4067 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4068 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4069 | /* Check status register pause & lpa register */ |
| 4070 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4071 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4072 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4073 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4074 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4075 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4076 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4077 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4078 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4079 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4080 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4081 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4082 | .avb_ops = &mv88e6390_avb_ops, |
| 4083 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4084 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4085 | }; |
| 4086 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4087 | static const struct mv88e6xxx_ops mv88e6240_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4088 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4089 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4090 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4091 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4092 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4093 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4094 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4095 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4096 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4097 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4098 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4099 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4100 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4101 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4102 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4103 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4104 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4105 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4106 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4107 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4108 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4109 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4110 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4111 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4112 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4113 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4114 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4115 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4116 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4117 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4118 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4119 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4120 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4121 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4122 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4123 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4124 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4125 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4126 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4127 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4128 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4129 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4130 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4131 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4132 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4133 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4134 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4135 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4136 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4137 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4138 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4139 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4140 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4141 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4142 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4143 | }; |
| 4144 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4145 | static const struct mv88e6xxx_ops mv88e6250_ops = { |
| 4146 | /* MV88E6XXX_FAMILY_6250 */ |
| 4147 | .ieee_pri_map = mv88e6250_g1_ieee_pri_map, |
| 4148 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
| 4149 | .irl_init_all = mv88e6352_g2_irl_init_all, |
| 4150 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4151 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
| 4152 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4153 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4154 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4155 | .port_set_link = mv88e6xxx_port_set_link, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4156 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4157 | .port_set_speed_duplex = mv88e6250_port_set_speed_duplex, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4158 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 4159 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 4160 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
| 4161 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
| 4162 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
| 4163 | .port_pause_limit = mv88e6097_port_pause_limit, |
| 4164 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4165 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
| 4166 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
| 4167 | .stats_get_sset_count = mv88e6250_stats_get_sset_count, |
| 4168 | .stats_get_strings = mv88e6250_stats_get_strings, |
| 4169 | .stats_get_stats = mv88e6250_stats_get_stats, |
| 4170 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4171 | .set_egress_port = mv88e6095_g1_set_egress_port, |
| 4172 | .watchdog_ops = &mv88e6250_watchdog_ops, |
| 4173 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
| 4174 | .pot_clear = mv88e6xxx_g2_pot_clear, |
| 4175 | .reset = mv88e6250_g1_reset, |
| 4176 | .vtu_getnext = mv88e6250_g1_vtu_getnext, |
| 4177 | .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 4178 | .avb_ops = &mv88e6352_avb_ops, |
| 4179 | .ptp_ops = &mv88e6250_ptp_ops, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 4180 | .phylink_validate = mv88e6065_phylink_validate, |
| 4181 | }; |
| 4182 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4183 | static const struct mv88e6xxx_ops mv88e6290_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4184 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4185 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4186 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4187 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4188 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4189 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4190 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4191 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4192 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4193 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4194 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4195 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4196 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4197 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4198 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4199 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4200 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4201 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4202 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4203 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4204 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4205 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4206 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4207 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4208 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4209 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4210 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4211 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4212 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4213 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4214 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4215 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4216 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4217 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4218 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4219 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4220 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4221 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4222 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4223 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4224 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4225 | /* Check status register pause & lpa register */ |
| 4226 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4227 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4228 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4229 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4230 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4231 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4232 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4233 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4234 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4235 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4236 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4237 | .phylink_validate = mv88e6390_phylink_validate, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4238 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4239 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4240 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4241 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4242 | }; |
| 4243 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4244 | static const struct mv88e6xxx_ops mv88e6320_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4245 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4246 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4247 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4248 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4249 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4250 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4251 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4252 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4253 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4254 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4255 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4256 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4257 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4258 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4259 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4260 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4261 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4262 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4263 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4264 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4265 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4266 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4267 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4268 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4269 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4270 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4271 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4272 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4273 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4274 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4275 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4276 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4277 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4278 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4279 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4280 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4281 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4282 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4283 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4284 | }; |
| 4285 | |
| 4286 | static const struct mv88e6xxx_ops mv88e6321_ops = { |
Vivien Didelot | bd80720 | 2017-07-17 13:03:37 -0400 | [diff] [blame] | 4287 | /* MV88E6XXX_FAMILY_6320 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4288 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4289 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4290 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4291 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4292 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4293 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4294 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4295 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4296 | .port_set_link = mv88e6xxx_port_set_link, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4297 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4298 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4299 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4300 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4301 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4302 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4303 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4304 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4305 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4306 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4307 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4308 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4309 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4310 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4311 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4312 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4313 | .stats_get_stats = mv88e6320_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4314 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4315 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | 9c7f37e | 2018-12-19 18:28:54 +0100 | [diff] [blame] | 4316 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4317 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4318 | .vtu_getnext = mv88e6185_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4319 | .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4320 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4321 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4322 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4323 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4324 | }; |
| 4325 | |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4326 | static const struct mv88e6xxx_ops mv88e6341_ops = { |
| 4327 | /* MV88E6XXX_FAMILY_6341 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4328 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4329 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4330 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4331 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4332 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
| 4333 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4334 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4335 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4336 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4337 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4338 | .port_set_speed_duplex = mv88e6341_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4339 | .port_max_speed_mode = mv88e6341_port_max_speed_mode, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4340 | .port_tag_remap = mv88e6095_port_tag_remap, |
| 4341 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
| 4342 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
| 4343 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4344 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4345 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4346 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4347 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
| 4348 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4349 | .port_get_cmode = mv88e6352_port_get_cmode, |
Marek Behún | 7a3007d | 2019-08-26 23:31:55 +0200 | [diff] [blame] | 4350 | .port_set_cmode = mv88e6341_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4351 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4352 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4353 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4354 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4355 | .stats_get_strings = mv88e6320_stats_get_strings, |
| 4356 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4357 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4358 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4359 | .watchdog_ops = &mv88e6390_watchdog_ops, |
| 4360 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4361 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4362 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4363 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4364 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4365 | .serdes_power = mv88e6390_serdes_power, |
| 4366 | .serdes_get_lane = mv88e6341_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4367 | /* Check status register pause & lpa register */ |
| 4368 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4369 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4370 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4371 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4372 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4373 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4374 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4375 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4376 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4377 | .ptp_ops = &mv88e6352_ptp_ops, |
Marek Behún | e3af71a | 2019-02-25 12:39:55 +0100 | [diff] [blame] | 4378 | .phylink_validate = mv88e6341_phylink_validate, |
Vivien Didelot | 16e329a | 2017-03-28 13:50:33 -0400 | [diff] [blame] | 4379 | }; |
| 4380 | |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4381 | static const struct mv88e6xxx_ops mv88e6350_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4382 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4383 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4384 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4385 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4386 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4387 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4388 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4389 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4390 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4391 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4392 | .port_tag_remap = mv88e6095_port_tag_remap, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4393 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4394 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4395 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4396 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4397 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4398 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4399 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4400 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4401 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4402 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4403 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4404 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4405 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4406 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4407 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4408 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4409 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4410 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4411 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4412 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4413 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4414 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4415 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4416 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4417 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4418 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4419 | }; |
| 4420 | |
| 4421 | static const struct mv88e6xxx_ops mv88e6351_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4422 | /* MV88E6XXX_FAMILY_6351 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4423 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4424 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4425 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4426 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4427 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4428 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4429 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 94d66ae | 2016-11-10 15:44:01 +0100 | [diff] [blame] | 4430 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4431 | .port_set_speed_duplex = mv88e6185_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4432 | .port_tag_remap = mv88e6095_port_tag_remap, |
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, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4441 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4442 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4443 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4444 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4445 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4446 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4447 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4448 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4449 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4450 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4451 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4452 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4453 | .reset = mv88e6352_g1_reset, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4454 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4455 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4456 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4457 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4458 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4459 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4460 | .phylink_validate = mv88e6185_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4461 | }; |
| 4462 | |
| 4463 | static const struct mv88e6xxx_ops mv88e6352_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4464 | /* MV88E6XXX_FAMILY_6352 */ |
Vivien Didelot | 93e18d6 | 2018-05-11 17:16:35 -0400 | [diff] [blame] | 4465 | .ieee_pri_map = mv88e6085_g1_ieee_pri_map, |
| 4466 | .ip_pri_map = mv88e6085_g1_ip_pri_map, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4467 | .irl_init_all = mv88e6352_g2_irl_init_all, |
Vivien Didelot | ee4dc2e7 | 2016-09-29 12:22:02 -0400 | [diff] [blame] | 4468 | .get_eeprom = mv88e6xxx_g2_get_eeprom16, |
| 4469 | .set_eeprom = mv88e6xxx_g2_set_eeprom16, |
Vivien Didelot | b073d4e | 2016-09-29 12:22:01 -0400 | [diff] [blame] | 4470 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4471 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4472 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
Vivien Didelot | 08ef7f1 | 2016-11-04 03:23:32 +0100 | [diff] [blame] | 4473 | .port_set_link = mv88e6xxx_port_set_link, |
Vivien Didelot | a0a0f62 | 2016-11-04 03:23:34 +0100 | [diff] [blame] | 4474 | .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4475 | .port_set_speed_duplex = mv88e6352_port_set_speed_duplex, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4476 | .port_tag_remap = mv88e6095_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4477 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4478 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4479 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4480 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4481 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4482 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4483 | .port_pause_limit = mv88e6097_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4484 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4485 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4486 | .port_get_cmode = mv88e6352_port_get_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4487 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | a605a0f | 2016-11-21 23:26:58 +0100 | [diff] [blame] | 4488 | .stats_snapshot = mv88e6320_g1_stats_snapshot, |
Andrew Lunn | 40cff8f | 2017-11-10 00:36:41 +0100 | [diff] [blame] | 4489 | .stats_set_histogram = mv88e6095_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4490 | .stats_get_sset_count = mv88e6095_stats_get_sset_count, |
| 4491 | .stats_get_strings = mv88e6095_stats_get_strings, |
Andrew Lunn | 052f947 | 2016-11-21 23:27:03 +0100 | [diff] [blame] | 4492 | .stats_get_stats = mv88e6095_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4493 | .set_cpu_port = mv88e6095_g1_set_cpu_port, |
| 4494 | .set_egress_port = mv88e6095_g1_set_egress_port, |
Andrew Lunn | fcd2516 | 2017-02-09 00:03:42 +0100 | [diff] [blame] | 4495 | .watchdog_ops = &mv88e6097_watchdog_ops, |
Vivien Didelot | 51c901a | 2017-07-17 13:03:41 -0400 | [diff] [blame] | 4496 | .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4497 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4498 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4499 | .rmu_disable = mv88e6352_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4500 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4501 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | f1394b78 | 2017-05-01 14:05:22 -0400 | [diff] [blame] | 4502 | .vtu_getnext = mv88e6352_g1_vtu_getnext, |
Vivien Didelot | 0ad5daf | 2017-05-01 14:05:23 -0400 | [diff] [blame] | 4503 | .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge, |
Vivien Didelot | 9db4a72 | 2019-08-31 16:18:31 -0400 | [diff] [blame] | 4504 | .serdes_get_lane = mv88e6352_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4505 | .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state, |
| 4506 | .serdes_pcs_config = mv88e6352_serdes_pcs_config, |
| 4507 | .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart, |
| 4508 | .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up, |
Andrew Lunn | 6d91782 | 2017-05-26 01:03:21 +0200 | [diff] [blame] | 4509 | .serdes_power = mv88e6352_serdes_power, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4510 | .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4511 | .serdes_irq_enable = mv88e6352_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4512 | .serdes_irq_status = mv88e6352_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4513 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4514 | .avb_ops = &mv88e6352_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4515 | .ptp_ops = &mv88e6352_ptp_ops, |
Andrew Lunn | cda9f4a | 2018-03-01 02:02:31 +0100 | [diff] [blame] | 4516 | .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, |
| 4517 | .serdes_get_strings = mv88e6352_serdes_get_strings, |
| 4518 | .serdes_get_stats = mv88e6352_serdes_get_stats, |
Andrew Lunn | d3f88a2 | 2020-02-16 18:54:14 +0100 | [diff] [blame] | 4519 | .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, |
| 4520 | .serdes_get_regs = mv88e6352_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4521 | .phylink_validate = mv88e6352_phylink_validate, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4522 | }; |
| 4523 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4524 | static const struct mv88e6xxx_ops mv88e6390_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4525 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4526 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4527 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4528 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4529 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4530 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4531 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4532 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4533 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4534 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4535 | .port_set_speed_duplex = mv88e6390_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4536 | .port_max_speed_mode = mv88e6390_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4537 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4538 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4539 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4540 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4541 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4542 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4543 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4544 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4545 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4546 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4547 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | fdc71ee | 2018-11-11 00:32:15 +0100 | [diff] [blame] | 4548 | .port_set_cmode = mv88e6390_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4549 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4550 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4551 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4552 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4553 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4554 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4555 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4556 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4557 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4558 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4559 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4560 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4561 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4562 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4563 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4564 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4565 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Andrew Lunn | 6335e9f | 2017-05-26 01:03:23 +0200 | [diff] [blame] | 4566 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4567 | .serdes_get_lane = mv88e6390_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4568 | /* Check status register pause & lpa register */ |
| 4569 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4570 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4571 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4572 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4573 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4574 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4575 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4576 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4577 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4578 | .ptp_ops = &mv88e6352_ptp_ops, |
Nikita Yushchenko | 0df9528 | 2019-12-25 08:22:38 +0300 | [diff] [blame] | 4579 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4580 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4581 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4582 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4583 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4584 | .phylink_validate = mv88e6390_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4585 | }; |
| 4586 | |
| 4587 | static const struct mv88e6xxx_ops mv88e6390x_ops = { |
Andrew Lunn | 4b325d8 | 2016-11-21 23:26:59 +0100 | [diff] [blame] | 4588 | /* MV88E6XXX_FAMILY_6390 */ |
Andrew Lunn | ea89098 | 2019-01-09 00:24:03 +0100 | [diff] [blame] | 4589 | .setup_errata = mv88e6390_setup_errata, |
Vivien Didelot | cd8da8b | 2017-06-19 10:55:36 -0400 | [diff] [blame] | 4590 | .irl_init_all = mv88e6390_g2_irl_init_all, |
Vivien Didelot | 98fc3c6 | 2017-01-12 18:07:16 -0500 | [diff] [blame] | 4591 | .get_eeprom = mv88e6xxx_g2_get_eeprom8, |
| 4592 | .set_eeprom = mv88e6xxx_g2_set_eeprom8, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4593 | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, |
| 4594 | .phy_read = mv88e6xxx_g2_smi_phy_read, |
| 4595 | .phy_write = mv88e6xxx_g2_smi_phy_write, |
| 4596 | .port_set_link = mv88e6xxx_port_set_link, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4597 | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, |
Russell King | f365c6f | 2020-03-14 10:15:53 +0000 | [diff] [blame] | 4598 | .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex, |
Andrew Lunn | 7cbbee0 | 2019-03-08 01:21:27 +0100 | [diff] [blame] | 4599 | .port_max_speed_mode = mv88e6390x_port_max_speed_mode, |
Andrew Lunn | ef0a731 | 2016-12-03 04:35:16 +0100 | [diff] [blame] | 4600 | .port_tag_remap = mv88e6390_port_tag_remap, |
Vivien Didelot | f3a2cd3 | 2019-09-07 16:00:48 -0400 | [diff] [blame] | 4601 | .port_set_policy = mv88e6352_port_set_policy, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4602 | .port_set_frame_mode = mv88e6351_port_set_frame_mode, |
Vivien Didelot | 601aeed | 2017-03-11 16:13:00 -0500 | [diff] [blame] | 4603 | .port_set_egress_floods = mv88e6352_port_set_egress_floods, |
Andrew Lunn | 56995cb | 2016-12-03 04:35:19 +0100 | [diff] [blame] | 4604 | .port_set_ether_type = mv88e6351_port_set_ether_type, |
Vivien Didelot | cd78265 | 2017-06-08 18:34:13 -0400 | [diff] [blame] | 4605 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
Andrew Lunn | ef70b11 | 2016-12-03 04:45:18 +0100 | [diff] [blame] | 4606 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
Vivien Didelot | 0898432 | 2017-06-08 18:34:12 -0400 | [diff] [blame] | 4607 | .port_pause_limit = mv88e6390_port_pause_limit, |
Vivien Didelot | c8c9489 | 2017-03-11 16:13:01 -0500 | [diff] [blame] | 4608 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
Vivien Didelot | 9dbfb4e | 2017-03-11 16:13:02 -0500 | [diff] [blame] | 4609 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
Andrew Lunn | 2d2e1dd | 2018-08-09 15:38:45 +0200 | [diff] [blame] | 4610 | .port_get_cmode = mv88e6352_port_get_cmode, |
Andrew Lunn | b3dce4d | 2018-11-11 00:32:14 +0100 | [diff] [blame] | 4611 | .port_set_cmode = mv88e6390x_port_set_cmode, |
Hubert Feurstein | 121b8fe | 2019-07-31 10:23:49 +0200 | [diff] [blame] | 4612 | .port_setup_message_port = mv88e6xxx_setup_message_port, |
Andrew Lunn | 7952347 | 2016-11-21 23:27:00 +0100 | [diff] [blame] | 4613 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
Andrew Lunn | de227387 | 2016-11-21 23:27:01 +0100 | [diff] [blame] | 4614 | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, |
Andrew Lunn | dfafe44 | 2016-11-21 23:27:02 +0100 | [diff] [blame] | 4615 | .stats_get_sset_count = mv88e6320_stats_get_sset_count, |
| 4616 | .stats_get_strings = mv88e6320_stats_get_strings, |
Andrew Lunn | e0d8b61 | 2016-11-21 23:27:04 +0100 | [diff] [blame] | 4617 | .stats_get_stats = mv88e6390_stats_get_stats, |
Vivien Didelot | fa8d117 | 2017-06-08 18:34:11 -0400 | [diff] [blame] | 4618 | .set_cpu_port = mv88e6390_g1_set_cpu_port, |
| 4619 | .set_egress_port = mv88e6390_g1_set_egress_port, |
Andrew Lunn | 6130373 | 2017-02-09 00:03:43 +0100 | [diff] [blame] | 4620 | .watchdog_ops = &mv88e6390_watchdog_ops, |
Andrew Lunn | 6e55f69 | 2016-12-03 04:45:16 +0100 | [diff] [blame] | 4621 | .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu, |
Vivien Didelot | 9e907d7 | 2017-07-17 13:03:43 -0400 | [diff] [blame] | 4622 | .pot_clear = mv88e6xxx_g2_pot_clear, |
Vivien Didelot | 17e708b | 2016-12-05 17:30:27 -0500 | [diff] [blame] | 4623 | .reset = mv88e6352_g1_reset, |
Vivien Didelot | 9e5baf9 | 2018-05-09 11:38:51 -0400 | [diff] [blame] | 4624 | .rmu_disable = mv88e6390_g1_rmu_disable, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 4625 | .atu_get_hash = mv88e6165_g1_atu_get_hash, |
| 4626 | .atu_set_hash = mv88e6165_g1_atu_set_hash, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4627 | .vtu_getnext = mv88e6390_g1_vtu_getnext, |
| 4628 | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, |
Marek Behún | d3cf7d8 | 2019-08-26 23:31:53 +0200 | [diff] [blame] | 4629 | .serdes_power = mv88e6390_serdes_power, |
Marek Behún | 17deaf5 | 2019-08-26 23:31:52 +0200 | [diff] [blame] | 4630 | .serdes_get_lane = mv88e6390x_serdes_get_lane, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 4631 | .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state, |
| 4632 | .serdes_pcs_config = mv88e6390_serdes_pcs_config, |
| 4633 | .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart, |
| 4634 | .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up, |
Vivien Didelot | 4241ef5 | 2019-08-31 16:18:29 -0400 | [diff] [blame] | 4635 | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, |
Vivien Didelot | 61a46b4 | 2019-08-31 16:18:34 -0400 | [diff] [blame] | 4636 | .serdes_irq_enable = mv88e6390_serdes_irq_enable, |
Vivien Didelot | 907b9b9 | 2019-08-31 16:18:35 -0400 | [diff] [blame] | 4637 | .serdes_irq_status = mv88e6390_serdes_irq_status, |
Andrew Lunn | 4262c38 | 2020-01-18 19:40:56 +0100 | [diff] [blame] | 4638 | .serdes_get_sset_count = mv88e6390_serdes_get_sset_count, |
| 4639 | .serdes_get_strings = mv88e6390_serdes_get_strings, |
| 4640 | .serdes_get_stats = mv88e6390_serdes_get_stats, |
Andrew Lunn | bf3504c | 2020-02-16 18:54:15 +0100 | [diff] [blame] | 4641 | .serdes_get_regs_len = mv88e6390_serdes_get_regs_len, |
| 4642 | .serdes_get_regs = mv88e6390_serdes_get_regs, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4643 | .gpio_ops = &mv88e6352_gpio_ops, |
Brandon Streiff | 0d632c3 | 2018-02-14 01:07:44 +0100 | [diff] [blame] | 4644 | .avb_ops = &mv88e6390_avb_ops, |
Andrew Lunn | 6d2ac8e | 2018-07-18 22:38:20 +0200 | [diff] [blame] | 4645 | .ptp_ops = &mv88e6352_ptp_ops, |
Russell King | 6c422e3 | 2018-08-09 15:38:39 +0200 | [diff] [blame] | 4646 | .phylink_validate = mv88e6390x_phylink_validate, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4647 | }; |
| 4648 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4649 | static const struct mv88e6xxx_info mv88e6xxx_table[] = { |
| 4650 | [MV88E6085] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4651 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4652 | .family = MV88E6XXX_FAMILY_6097, |
| 4653 | .name = "Marvell 88E6085", |
| 4654 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4655 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4656 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4657 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4658 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4659 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4660 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4661 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4662 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4663 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4664 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4665 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4666 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4667 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4668 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4669 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4670 | .ops = &mv88e6085_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4671 | }, |
| 4672 | |
| 4673 | [MV88E6095] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4674 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4675 | .family = MV88E6XXX_FAMILY_6095, |
| 4676 | .name = "Marvell 88E6095/88E6095F", |
| 4677 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4678 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4679 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4680 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4681 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4682 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4683 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4684 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4685 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4686 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4687 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4688 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4689 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4690 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4691 | .ops = &mv88e6095_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4692 | }, |
| 4693 | |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4694 | [MV88E6097] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4695 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4696 | .family = MV88E6XXX_FAMILY_6097, |
| 4697 | .name = "Marvell 88E6097/88E6097F", |
| 4698 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4699 | .num_macs = 8192, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4700 | .num_ports = 11, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4701 | .num_internal_phys = 8, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4702 | .max_vid = 4095, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4703 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4704 | .phy_base_addr = 0x0, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4705 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4706 | .global2_addr = 0x1c, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4707 | .age_time_coeff = 15000, |
Stefan Eichenberger | c534178 | 2016-11-25 09:41:29 +0100 | [diff] [blame] | 4708 | .g1_irqs = 8, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4709 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4710 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4711 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4712 | .multi_chip = true, |
Stefan Eichenberger | 2bfcfcd | 2016-12-05 14:12:42 +0100 | [diff] [blame] | 4713 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Stefan Eichenberger | 7d381a0 | 2016-11-22 17:47:21 +0100 | [diff] [blame] | 4714 | .ops = &mv88e6097_ops, |
| 4715 | }, |
| 4716 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4717 | [MV88E6123] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4718 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4719 | .family = MV88E6XXX_FAMILY_6165, |
| 4720 | .name = "Marvell 88E6123", |
| 4721 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4722 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4723 | .num_ports = 3, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4724 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4725 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4726 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4727 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4728 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4729 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4730 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4731 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4732 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4733 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4734 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4735 | .multi_chip = true, |
Andrew Lunn | 5ebe31d | 2017-06-07 15:06:19 +0200 | [diff] [blame] | 4736 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4737 | .ops = &mv88e6123_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4738 | }, |
| 4739 | |
| 4740 | [MV88E6131] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4741 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4742 | .family = MV88E6XXX_FAMILY_6185, |
| 4743 | .name = "Marvell 88E6131", |
| 4744 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4745 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4746 | .num_ports = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4747 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4748 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4749 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4750 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4751 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4752 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4753 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4754 | .g1_irqs = 9, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4755 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4756 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4757 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4758 | .ops = &mv88e6131_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4759 | }, |
| 4760 | |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4761 | [MV88E6141] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4762 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4763 | .family = MV88E6XXX_FAMILY_6341, |
Uwe Kleine-König | 79a68b2 | 2018-03-20 10:44:40 +0100 | [diff] [blame] | 4764 | .name = "Marvell 88E6141", |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4765 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4766 | .num_macs = 2048, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4767 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4768 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4769 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4770 | .max_vid = 4095, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4771 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4772 | .phy_base_addr = 0x10, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4773 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4774 | .global2_addr = 0x1c, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4775 | .age_time_coeff = 3750, |
| 4776 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 4777 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4778 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4779 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4780 | .multi_chip = true, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4781 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | 990e27b | 2017-03-28 13:50:32 -0400 | [diff] [blame] | 4782 | .ops = &mv88e6141_ops, |
| 4783 | }, |
| 4784 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4785 | [MV88E6161] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4786 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4787 | .family = MV88E6XXX_FAMILY_6165, |
| 4788 | .name = "Marvell 88E6161", |
| 4789 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4790 | .num_macs = 1024, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4791 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4792 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4793 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4794 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4795 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4796 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4797 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4798 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4799 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4800 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4801 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4802 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4803 | .multi_chip = true, |
Andrew Lunn | 5ebe31d | 2017-06-07 15:06:19 +0200 | [diff] [blame] | 4804 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 4805 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4806 | .ops = &mv88e6161_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4807 | }, |
| 4808 | |
| 4809 | [MV88E6165] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4810 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4811 | .family = MV88E6XXX_FAMILY_6165, |
| 4812 | .name = "Marvell 88E6165", |
| 4813 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4814 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4815 | .num_ports = 6, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4816 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4817 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4818 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4819 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4820 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4821 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4822 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4823 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4824 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4825 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4826 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4827 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4828 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Andrew Lunn | dfa5434 | 2018-07-18 22:38:22 +0200 | [diff] [blame] | 4829 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4830 | .ops = &mv88e6165_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4831 | }, |
| 4832 | |
| 4833 | [MV88E6171] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4834 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4835 | .family = MV88E6XXX_FAMILY_6351, |
| 4836 | .name = "Marvell 88E6171", |
| 4837 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4838 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4839 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4840 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4841 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4842 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4843 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4844 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4845 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4846 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4847 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4848 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4849 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4850 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4851 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4852 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4853 | .ops = &mv88e6171_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4854 | }, |
| 4855 | |
| 4856 | [MV88E6172] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4857 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4858 | .family = MV88E6XXX_FAMILY_6352, |
| 4859 | .name = "Marvell 88E6172", |
| 4860 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4861 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4862 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4863 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4864 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4865 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4866 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4867 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4868 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4869 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4870 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4871 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4872 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4873 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4874 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4875 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4876 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4877 | .ops = &mv88e6172_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4878 | }, |
| 4879 | |
| 4880 | [MV88E6175] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4881 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4882 | .family = MV88E6XXX_FAMILY_6351, |
| 4883 | .name = "Marvell 88E6175", |
| 4884 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4885 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4886 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4887 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4888 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4889 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4890 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4891 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4892 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4893 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4894 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4895 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4896 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4897 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4898 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4899 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4900 | .ops = &mv88e6175_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4901 | }, |
| 4902 | |
| 4903 | [MV88E6176] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4904 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4905 | .family = MV88E6XXX_FAMILY_6352, |
| 4906 | .name = "Marvell 88E6176", |
| 4907 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4908 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4909 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4910 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4911 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4912 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4913 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4914 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4915 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4916 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4917 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4918 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4919 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4920 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4921 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4922 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4923 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4924 | .ops = &mv88e6176_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4925 | }, |
| 4926 | |
| 4927 | [MV88E6185] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4928 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4929 | .family = MV88E6XXX_FAMILY_6185, |
| 4930 | .name = "Marvell 88E6185", |
| 4931 | .num_databases = 256, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4932 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4933 | .num_ports = 10, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 4934 | .num_internal_phys = 0, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 4935 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 4936 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4937 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 4938 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4939 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 4940 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 4941 | .g1_irqs = 8, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4942 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4943 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4944 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 4945 | .ops = &mv88e6185_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 4946 | }, |
| 4947 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4948 | [MV88E6190] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4949 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4950 | .family = MV88E6XXX_FAMILY_6390, |
| 4951 | .name = "Marvell 88E6190", |
| 4952 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4953 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4954 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 4955 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4956 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4957 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4958 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4959 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4960 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4961 | .global2_addr = 0x1c, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4962 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 4963 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4964 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4965 | .g2_irqs = 14, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4966 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4967 | .multi_chip = true, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4968 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4969 | .ops = &mv88e6190_ops, |
| 4970 | }, |
| 4971 | |
| 4972 | [MV88E6190X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4973 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4974 | .family = MV88E6XXX_FAMILY_6390, |
| 4975 | .name = "Marvell 88E6190X", |
| 4976 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 4977 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4978 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 4979 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 4980 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 4981 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4982 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 4983 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4984 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 4985 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 4986 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4987 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 4988 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 4989 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 4990 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 4991 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 4992 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4993 | .ops = &mv88e6190x_ops, |
| 4994 | }, |
| 4995 | |
| 4996 | [MV88E6191] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 4997 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 4998 | .family = MV88E6XXX_FAMILY_6390, |
| 4999 | .name = "Marvell 88E6191", |
| 5000 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5001 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5002 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5003 | .num_internal_phys = 9, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5004 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5005 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5006 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5007 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5008 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5009 | .age_time_coeff = 3750, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5010 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5011 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5012 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5013 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5014 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5015 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5016 | .ptp_support = true, |
Vivien Didelot | 2cf4cefb | 2017-03-28 13:50:34 -0400 | [diff] [blame] | 5017 | .ops = &mv88e6191_ops, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5018 | }, |
| 5019 | |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5020 | [MV88E6220] = { |
| 5021 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220, |
| 5022 | .family = MV88E6XXX_FAMILY_6250, |
| 5023 | .name = "Marvell 88E6220", |
| 5024 | .num_databases = 64, |
| 5025 | |
| 5026 | /* Ports 2-4 are not routed to pins |
| 5027 | * => usable ports 0, 1, 5, 6 |
| 5028 | */ |
| 5029 | .num_ports = 7, |
| 5030 | .num_internal_phys = 2, |
Hubert Feurstein | c857486 | 2019-07-31 10:23:48 +0200 | [diff] [blame] | 5031 | .invalid_port_mask = BIT(2) | BIT(3) | BIT(4), |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5032 | .max_vid = 4095, |
| 5033 | .port_base_addr = 0x08, |
| 5034 | .phy_base_addr = 0x00, |
| 5035 | .global1_addr = 0x0f, |
| 5036 | .global2_addr = 0x07, |
| 5037 | .age_time_coeff = 15000, |
| 5038 | .g1_irqs = 9, |
| 5039 | .g2_irqs = 10, |
| 5040 | .atu_move_port_mask = 0xf, |
| 5041 | .dual_chip = true, |
| 5042 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5043 | .ptp_support = true, |
Hubert Feurstein | 4902264 | 2019-07-31 10:23:46 +0200 | [diff] [blame] | 5044 | .ops = &mv88e6250_ops, |
| 5045 | }, |
| 5046 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5047 | [MV88E6240] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5048 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5049 | .family = MV88E6XXX_FAMILY_6352, |
| 5050 | .name = "Marvell 88E6240", |
| 5051 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5052 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5053 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5054 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5055 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5056 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5057 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5058 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5059 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5060 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5061 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5062 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5063 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5064 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5065 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5066 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5067 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5068 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5069 | .ops = &mv88e6240_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5070 | }, |
| 5071 | |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5072 | [MV88E6250] = { |
| 5073 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250, |
| 5074 | .family = MV88E6XXX_FAMILY_6250, |
| 5075 | .name = "Marvell 88E6250", |
| 5076 | .num_databases = 64, |
| 5077 | .num_ports = 7, |
| 5078 | .num_internal_phys = 5, |
| 5079 | .max_vid = 4095, |
| 5080 | .port_base_addr = 0x08, |
| 5081 | .phy_base_addr = 0x00, |
| 5082 | .global1_addr = 0x0f, |
| 5083 | .global2_addr = 0x07, |
| 5084 | .age_time_coeff = 15000, |
| 5085 | .g1_irqs = 9, |
| 5086 | .g2_irqs = 10, |
| 5087 | .atu_move_port_mask = 0xf, |
| 5088 | .dual_chip = true, |
| 5089 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Hubert Feurstein | 7150961 | 2019-07-31 10:23:51 +0200 | [diff] [blame] | 5090 | .ptp_support = true, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5091 | .ops = &mv88e6250_ops, |
| 5092 | }, |
| 5093 | |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5094 | [MV88E6290] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5095 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5096 | .family = MV88E6XXX_FAMILY_6390, |
| 5097 | .name = "Marvell 88E6290", |
| 5098 | .num_databases = 4096, |
| 5099 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5100 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5101 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5102 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5103 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5104 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5105 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5106 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5107 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5108 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5109 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5110 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5111 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5112 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5113 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5114 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5115 | .ops = &mv88e6290_ops, |
| 5116 | }, |
| 5117 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5118 | [MV88E6320] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5119 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5120 | .family = MV88E6XXX_FAMILY_6320, |
| 5121 | .name = "Marvell 88E6320", |
| 5122 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5123 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5124 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5125 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5126 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5127 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5128 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5129 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5130 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5131 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5132 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5133 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5134 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5135 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5136 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5137 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5138 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5139 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5140 | .ops = &mv88e6320_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5141 | }, |
| 5142 | |
| 5143 | [MV88E6321] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5144 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5145 | .family = MV88E6XXX_FAMILY_6320, |
| 5146 | .name = "Marvell 88E6321", |
| 5147 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5148 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5149 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5150 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5151 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5152 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5153 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5154 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5155 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5156 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5157 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5158 | .g1_irqs = 8, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5159 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5160 | .atu_move_port_mask = 0xf, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5161 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5162 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5163 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5164 | .ops = &mv88e6321_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5165 | }, |
| 5166 | |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5167 | [MV88E6341] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5168 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5169 | .family = MV88E6XXX_FAMILY_6341, |
| 5170 | .name = "Marvell 88E6341", |
| 5171 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5172 | .num_macs = 2048, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5173 | .num_internal_phys = 5, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5174 | .num_ports = 6, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5175 | .num_gpio = 11, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5176 | .max_vid = 4095, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5177 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5178 | .phy_base_addr = 0x10, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5179 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5180 | .global2_addr = 0x1c, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5181 | .age_time_coeff = 3750, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5182 | .atu_move_port_mask = 0x1f, |
Andrew Lunn | adfccf1 | 2018-03-17 20:32:03 +0100 | [diff] [blame] | 5183 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5184 | .g2_irqs = 10, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5185 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5186 | .multi_chip = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5187 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5188 | .ptp_support = true, |
Gregory CLEMENT | a75961d | 2017-01-30 20:29:34 +0100 | [diff] [blame] | 5189 | .ops = &mv88e6341_ops, |
| 5190 | }, |
| 5191 | |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5192 | [MV88E6350] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5193 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5194 | .family = MV88E6XXX_FAMILY_6351, |
| 5195 | .name = "Marvell 88E6350", |
| 5196 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5197 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5198 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5199 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5200 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5201 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5202 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5203 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5204 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5205 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5206 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5207 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5208 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5209 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5210 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5211 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5212 | .ops = &mv88e6350_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5213 | }, |
| 5214 | |
| 5215 | [MV88E6351] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5216 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5217 | .family = MV88E6XXX_FAMILY_6351, |
| 5218 | .name = "Marvell 88E6351", |
| 5219 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5220 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5221 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5222 | .num_internal_phys = 5, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5223 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5224 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5225 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5226 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5227 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5228 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5229 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5230 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5231 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5232 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5233 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5234 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5235 | .ops = &mv88e6351_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5236 | }, |
| 5237 | |
| 5238 | [MV88E6352] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5239 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5240 | .family = MV88E6XXX_FAMILY_6352, |
| 5241 | .name = "Marvell 88E6352", |
| 5242 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5243 | .num_macs = 8192, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5244 | .num_ports = 7, |
Andrew Lunn | bc39315 | 2018-03-17 20:32:04 +0100 | [diff] [blame] | 5245 | .num_internal_phys = 5, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5246 | .num_gpio = 15, |
Vivien Didelot | 3cf3c84 | 2017-05-01 14:05:10 -0400 | [diff] [blame] | 5247 | .max_vid = 4095, |
Vivien Didelot | 9dddd47 | 2016-06-20 13:14:10 -0400 | [diff] [blame] | 5248 | .port_base_addr = 0x10, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5249 | .phy_base_addr = 0x0, |
Vivien Didelot | a935c05 | 2016-09-29 12:21:53 -0400 | [diff] [blame] | 5250 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5251 | .global2_addr = 0x1c, |
Vivien Didelot | acddbd2 | 2016-07-18 20:45:39 -0400 | [diff] [blame] | 5252 | .age_time_coeff = 15000, |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5253 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5254 | .g2_irqs = 10, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5255 | .atu_move_port_mask = 0xf, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5256 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5257 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5258 | .tag_protocol = DSA_TAG_PROTO_EDSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5259 | .ptp_support = true, |
Vivien Didelot | b3469dd | 2016-09-29 12:22:00 -0400 | [diff] [blame] | 5260 | .ops = &mv88e6352_ops, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5261 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5262 | [MV88E6390] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5263 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5264 | .family = MV88E6XXX_FAMILY_6390, |
| 5265 | .name = "Marvell 88E6390", |
| 5266 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5267 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5268 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5269 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5270 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5271 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5272 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5273 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5274 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5275 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5276 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5277 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5278 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5279 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5280 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5281 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5282 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5283 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5284 | .ops = &mv88e6390_ops, |
| 5285 | }, |
| 5286 | [MV88E6390X] = { |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5287 | .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5288 | .family = MV88E6XXX_FAMILY_6390, |
| 5289 | .name = "Marvell 88E6390X", |
| 5290 | .num_databases = 4096, |
Andrew Lunn | d9ea562 | 2019-11-05 01:12:58 +0100 | [diff] [blame] | 5291 | .num_macs = 16384, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5292 | .num_ports = 11, /* 10 + Z80 */ |
Heiner Kallweit | 95150f2 | 2019-03-02 10:06:05 +0100 | [diff] [blame] | 5293 | .num_internal_phys = 9, |
Brandon Streiff | a73ccd6 | 2018-02-14 01:07:46 +0100 | [diff] [blame] | 5294 | .num_gpio = 16, |
Vivien Didelot | 931d182 | 2017-05-01 14:05:27 -0400 | [diff] [blame] | 5295 | .max_vid = 8191, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5296 | .port_base_addr = 0x0, |
Andrew Lunn | 9255bac | 2018-05-05 20:58:22 +0200 | [diff] [blame] | 5297 | .phy_base_addr = 0x0, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5298 | .global1_addr = 0x1b, |
Vivien Didelot | 9069c13 | 2017-07-17 13:03:44 -0400 | [diff] [blame] | 5299 | .global2_addr = 0x1c, |
Andrew Lunn | b91e055 | 2017-02-02 00:46:15 +0100 | [diff] [blame] | 5300 | .age_time_coeff = 3750, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5301 | .g1_irqs = 9, |
Vivien Didelot | d6c5e6a | 2017-07-17 13:03:40 -0400 | [diff] [blame] | 5302 | .g2_irqs = 14, |
Vivien Didelot | e606ca3 | 2017-03-11 16:12:55 -0500 | [diff] [blame] | 5303 | .atu_move_port_mask = 0x1f, |
Vivien Didelot | f364565 | 2017-03-30 17:37:07 -0400 | [diff] [blame] | 5304 | .pvt = true, |
Vivien Didelot | b3e05aa | 2017-07-17 13:03:46 -0400 | [diff] [blame] | 5305 | .multi_chip = true, |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5306 | .tag_protocol = DSA_TAG_PROTO_DSA, |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5307 | .ptp_support = true, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5308 | .ops = &mv88e6390x_ops, |
| 5309 | }, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5310 | }; |
| 5311 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5312 | static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num) |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5313 | { |
Vivien Didelot | a439c06 | 2016-04-17 13:23:58 -0400 | [diff] [blame] | 5314 | int i; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5315 | |
Vivien Didelot | 5f7c036 | 2016-06-20 13:14:04 -0400 | [diff] [blame] | 5316 | for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i) |
| 5317 | if (mv88e6xxx_table[i].prod_num == prod_num) |
| 5318 | return &mv88e6xxx_table[i]; |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5319 | |
Vivien Didelot | b9b3771 | 2015-10-30 19:39:48 -0400 | [diff] [blame] | 5320 | return NULL; |
| 5321 | } |
| 5322 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5323 | static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip) |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5324 | { |
| 5325 | const struct mv88e6xxx_info *info; |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5326 | unsigned int prod_num, rev; |
| 5327 | u16 id; |
| 5328 | int err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5329 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5330 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5331 | err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5332 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 8f6345b | 2016-07-20 18:18:36 -0400 | [diff] [blame] | 5333 | if (err) |
| 5334 | return err; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5335 | |
Vivien Didelot | 107fcc1 | 2017-06-12 12:37:36 -0400 | [diff] [blame] | 5336 | prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK; |
| 5337 | rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5338 | |
| 5339 | info = mv88e6xxx_lookup_info(prod_num); |
| 5340 | if (!info) |
| 5341 | return -ENODEV; |
| 5342 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5343 | /* Update the compatible info with the probed one */ |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5344 | chip->info = info; |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5345 | |
Vivien Didelot | ca070c1 | 2016-09-02 14:45:34 -0400 | [diff] [blame] | 5346 | err = mv88e6xxx_g2_require(chip); |
| 5347 | if (err) |
| 5348 | return err; |
| 5349 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5350 | dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n", |
| 5351 | chip->info->prod_num, chip->info->name, rev); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5352 | |
| 5353 | return 0; |
| 5354 | } |
| 5355 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5356 | static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5357 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5358 | struct mv88e6xxx_chip *chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5359 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5360 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
| 5361 | if (!chip) |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5362 | return NULL; |
| 5363 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5364 | chip->dev = dev; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5365 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5366 | mutex_init(&chip->reg_lock); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5367 | INIT_LIST_HEAD(&chip->mdios); |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 5368 | idr_init(&chip->policies); |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5369 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5370 | return chip; |
Vivien Didelot | 469d729 | 2016-06-20 13:14:06 -0400 | [diff] [blame] | 5371 | } |
| 5372 | |
Florian Fainelli | 5ed4e3e | 2017-11-10 15:22:52 -0800 | [diff] [blame] | 5373 | 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] | 5374 | int port, |
| 5375 | enum dsa_tag_protocol m) |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5376 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5377 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 2bbb33b | 2016-08-22 16:01:02 +0200 | [diff] [blame] | 5378 | |
Andrew Lunn | 443d5a1 | 2016-12-03 04:35:18 +0100 | [diff] [blame] | 5379 | return chip->info->tag_protocol; |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5380 | } |
| 5381 | |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5382 | static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port, |
Vivien Didelot | 3709aad | 2017-11-30 11:23:58 -0500 | [diff] [blame] | 5383 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5384 | { |
| 5385 | /* We don't need any dynamic resource from the kernel (yet), |
| 5386 | * so skip the prepare phase. |
| 5387 | */ |
| 5388 | |
| 5389 | return 0; |
| 5390 | } |
| 5391 | |
| 5392 | static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port, |
Vivien Didelot | 3709aad | 2017-11-30 11:23:58 -0500 | [diff] [blame] | 5393 | const struct switchdev_obj_port_mdb *mdb) |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5394 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5395 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5396 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5397 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5398 | if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, |
Vivien Didelot | 27c0e60 | 2017-06-15 12:14:01 -0400 | [diff] [blame] | 5399 | MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC)) |
Vivien Didelot | 774439e5 | 2017-06-08 18:34:08 -0400 | [diff] [blame] | 5400 | dev_err(ds->dev, "p%d: failed to load multicast MAC address\n", |
| 5401 | port); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5402 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5403 | } |
| 5404 | |
| 5405 | static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port, |
| 5406 | const struct switchdev_obj_port_mdb *mdb) |
| 5407 | { |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5408 | struct mv88e6xxx_chip *chip = ds->priv; |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5409 | int err; |
| 5410 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5411 | mv88e6xxx_reg_lock(chip); |
Vivien Didelot | d8291a9 | 2019-09-07 16:00:47 -0400 | [diff] [blame] | 5412 | 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] | 5413 | mv88e6xxx_reg_unlock(chip); |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5414 | |
| 5415 | return err; |
| 5416 | } |
| 5417 | |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5418 | static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port, |
| 5419 | struct dsa_mall_mirror_tc_entry *mirror, |
| 5420 | bool ingress) |
| 5421 | { |
| 5422 | enum mv88e6xxx_egress_direction direction = ingress ? |
| 5423 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5424 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5425 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5426 | bool other_mirrors = false; |
| 5427 | int i; |
| 5428 | int err; |
| 5429 | |
| 5430 | if (!chip->info->ops->set_egress_port) |
| 5431 | return -EOPNOTSUPP; |
| 5432 | |
| 5433 | mutex_lock(&chip->reg_lock); |
| 5434 | if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) != |
| 5435 | mirror->to_local_port) { |
| 5436 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5437 | other_mirrors |= ingress ? |
| 5438 | chip->ports[i].mirror_ingress : |
| 5439 | chip->ports[i].mirror_egress; |
| 5440 | |
| 5441 | /* Can't change egress port when other mirror is active */ |
| 5442 | if (other_mirrors) { |
| 5443 | err = -EBUSY; |
| 5444 | goto out; |
| 5445 | } |
| 5446 | |
| 5447 | err = chip->info->ops->set_egress_port(chip, |
| 5448 | direction, |
| 5449 | mirror->to_local_port); |
| 5450 | if (err) |
| 5451 | goto out; |
| 5452 | } |
| 5453 | |
| 5454 | err = mv88e6xxx_port_set_mirror(chip, port, direction, true); |
| 5455 | out: |
| 5456 | mutex_unlock(&chip->reg_lock); |
| 5457 | |
| 5458 | return err; |
| 5459 | } |
| 5460 | |
| 5461 | static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port, |
| 5462 | struct dsa_mall_mirror_tc_entry *mirror) |
| 5463 | { |
| 5464 | enum mv88e6xxx_egress_direction direction = mirror->ingress ? |
| 5465 | MV88E6XXX_EGRESS_DIR_INGRESS : |
| 5466 | MV88E6XXX_EGRESS_DIR_EGRESS; |
| 5467 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5468 | bool other_mirrors = false; |
| 5469 | int i; |
| 5470 | |
| 5471 | mutex_lock(&chip->reg_lock); |
| 5472 | if (mv88e6xxx_port_set_mirror(chip, port, direction, false)) |
| 5473 | dev_err(ds->dev, "p%d: failed to disable mirroring\n", port); |
| 5474 | |
| 5475 | for (i = 0; i < mv88e6xxx_num_ports(chip); i++) |
| 5476 | other_mirrors |= mirror->ingress ? |
| 5477 | chip->ports[i].mirror_ingress : |
| 5478 | chip->ports[i].mirror_egress; |
| 5479 | |
| 5480 | /* Reset egress port when no other mirror is active */ |
| 5481 | if (!other_mirrors) { |
| 5482 | if (chip->info->ops->set_egress_port(chip, |
| 5483 | direction, |
| 5484 | dsa_upstream_port(ds, |
Colin Ian King | 4e4637b | 2019-11-12 13:05:23 +0000 | [diff] [blame] | 5485 | port))) |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5486 | dev_err(ds->dev, "failed to set egress port\n"); |
| 5487 | } |
| 5488 | |
| 5489 | mutex_unlock(&chip->reg_lock); |
| 5490 | } |
| 5491 | |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5492 | static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port, |
| 5493 | bool unicast, bool multicast) |
| 5494 | { |
| 5495 | struct mv88e6xxx_chip *chip = ds->priv; |
| 5496 | int err = -EOPNOTSUPP; |
| 5497 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5498 | mv88e6xxx_reg_lock(chip); |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5499 | if (chip->info->ops->port_set_egress_floods) |
| 5500 | err = chip->info->ops->port_set_egress_floods(chip, port, |
| 5501 | unicast, |
| 5502 | multicast); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5503 | mv88e6xxx_reg_unlock(chip); |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5504 | |
| 5505 | return err; |
| 5506 | } |
| 5507 | |
Florian Fainelli | a82f67a | 2017-01-08 14:52:08 -0800 | [diff] [blame] | 5508 | static const struct dsa_switch_ops mv88e6xxx_switch_ops = { |
Andrew Lunn | 7b31436 | 2016-08-22 16:01:01 +0200 | [diff] [blame] | 5509 | .get_tag_protocol = mv88e6xxx_get_tag_protocol, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5510 | .setup = mv88e6xxx_setup, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 5511 | .teardown = mv88e6xxx_teardown, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 5512 | .phylink_validate = mv88e6xxx_validate, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 5513 | .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 5514 | .phylink_mac_config = mv88e6xxx_mac_config, |
Russell King | a5a6858 | 2020-03-14 10:15:43 +0000 | [diff] [blame] | 5515 | .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart, |
Russell King | c9a2356 | 2018-05-10 13:17:35 -0700 | [diff] [blame] | 5516 | .phylink_mac_link_down = mv88e6xxx_mac_link_down, |
| 5517 | .phylink_mac_link_up = mv88e6xxx_mac_link_up, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5518 | .get_strings = mv88e6xxx_get_strings, |
| 5519 | .get_ethtool_stats = mv88e6xxx_get_ethtool_stats, |
| 5520 | .get_sset_count = mv88e6xxx_get_sset_count, |
Andrew Lunn | 04aca99 | 2017-05-26 01:03:24 +0200 | [diff] [blame] | 5521 | .port_enable = mv88e6xxx_port_enable, |
| 5522 | .port_disable = mv88e6xxx_port_disable, |
Vivien Didelot | 08f5006 | 2017-08-01 16:32:41 -0400 | [diff] [blame] | 5523 | .get_mac_eee = mv88e6xxx_get_mac_eee, |
| 5524 | .set_mac_eee = mv88e6xxx_set_mac_eee, |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 5525 | .get_eeprom_len = mv88e6xxx_get_eeprom_len, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5526 | .get_eeprom = mv88e6xxx_get_eeprom, |
| 5527 | .set_eeprom = mv88e6xxx_set_eeprom, |
| 5528 | .get_regs_len = mv88e6xxx_get_regs_len, |
| 5529 | .get_regs = mv88e6xxx_get_regs, |
Vivien Didelot | da7dc87 | 2019-09-07 16:00:49 -0400 | [diff] [blame] | 5530 | .get_rxnfc = mv88e6xxx_get_rxnfc, |
| 5531 | .set_rxnfc = mv88e6xxx_set_rxnfc, |
Vivien Didelot | 2cfcd96 | 2016-07-18 20:45:40 -0400 | [diff] [blame] | 5532 | .set_ageing_time = mv88e6xxx_set_ageing_time, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5533 | .port_bridge_join = mv88e6xxx_port_bridge_join, |
| 5534 | .port_bridge_leave = mv88e6xxx_port_bridge_leave, |
Russell King | 4f85901 | 2019-02-20 15:35:05 -0800 | [diff] [blame] | 5535 | .port_egress_floods = mv88e6xxx_port_egress_floods, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5536 | .port_stp_state_set = mv88e6xxx_port_stp_state_set, |
Vivien Didelot | 749efcb | 2016-09-22 16:49:24 -0400 | [diff] [blame] | 5537 | .port_fast_age = mv88e6xxx_port_fast_age, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5538 | .port_vlan_filtering = mv88e6xxx_port_vlan_filtering, |
| 5539 | .port_vlan_prepare = mv88e6xxx_port_vlan_prepare, |
| 5540 | .port_vlan_add = mv88e6xxx_port_vlan_add, |
| 5541 | .port_vlan_del = mv88e6xxx_port_vlan_del, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5542 | .port_fdb_add = mv88e6xxx_port_fdb_add, |
| 5543 | .port_fdb_del = mv88e6xxx_port_fdb_del, |
| 5544 | .port_fdb_dump = mv88e6xxx_port_fdb_dump, |
Vivien Didelot | 7df8fbd | 2016-08-31 11:50:05 -0400 | [diff] [blame] | 5545 | .port_mdb_prepare = mv88e6xxx_port_mdb_prepare, |
| 5546 | .port_mdb_add = mv88e6xxx_port_mdb_add, |
| 5547 | .port_mdb_del = mv88e6xxx_port_mdb_del, |
Iwan R Timmer | f0942e0 | 2019-11-07 22:11:14 +0100 | [diff] [blame] | 5548 | .port_mirror_add = mv88e6xxx_port_mirror_add, |
| 5549 | .port_mirror_del = mv88e6xxx_port_mirror_del, |
Vivien Didelot | aec5ac8 | 2017-03-30 17:37:15 -0400 | [diff] [blame] | 5550 | .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join, |
| 5551 | .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave, |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 5552 | .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set, |
| 5553 | .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get, |
| 5554 | .port_txtstamp = mv88e6xxx_port_txtstamp, |
| 5555 | .port_rxtstamp = mv88e6xxx_port_rxtstamp, |
| 5556 | .get_ts_info = mv88e6xxx_get_ts_info, |
Andrew Lunn | 23e8b47 | 2019-10-25 01:03:52 +0200 | [diff] [blame] | 5557 | .devlink_param_get = mv88e6xxx_devlink_param_get, |
| 5558 | .devlink_param_set = mv88e6xxx_devlink_param_set, |
Vivien Didelot | f81ec90 | 2016-05-09 13:22:58 -0400 | [diff] [blame] | 5559 | }; |
| 5560 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 5561 | static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5562 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5563 | struct device *dev = chip->dev; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5564 | struct dsa_switch *ds; |
| 5565 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 5566 | ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5567 | if (!ds) |
| 5568 | return -ENOMEM; |
| 5569 | |
Vivien Didelot | 7e99e34 | 2019-10-21 16:51:30 -0400 | [diff] [blame] | 5570 | ds->dev = dev; |
| 5571 | ds->num_ports = mv88e6xxx_num_ports(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5572 | ds->priv = chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5573 | ds->dev = dev; |
Vivien Didelot | 9d490b4 | 2016-08-23 12:38:56 -0400 | [diff] [blame] | 5574 | ds->ops = &mv88e6xxx_switch_ops; |
Vivien Didelot | 9ff74f2 | 2017-03-15 15:53:50 -0400 | [diff] [blame] | 5575 | ds->ageing_time_min = chip->info->age_time_coeff; |
| 5576 | ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX; |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5577 | |
| 5578 | dev_set_drvdata(dev, ds); |
| 5579 | |
Vivien Didelot | 23c9ee4 | 2017-05-26 18:12:51 -0400 | [diff] [blame] | 5580 | return dsa_register_switch(ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5581 | } |
| 5582 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5583 | static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip) |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5584 | { |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5585 | dsa_unregister_switch(chip->ds); |
Vivien Didelot | b7e66a5 | 2016-06-20 13:14:02 -0400 | [diff] [blame] | 5586 | } |
| 5587 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5588 | static const void *pdata_device_get_match_data(struct device *dev) |
| 5589 | { |
| 5590 | const struct of_device_id *matches = dev->driver->of_match_table; |
| 5591 | const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data; |
| 5592 | |
| 5593 | for (; matches->name[0] || matches->type[0] || matches->compatible[0]; |
| 5594 | matches++) { |
| 5595 | if (!strcmp(pdata->compatible, matches->compatible)) |
| 5596 | return matches->data; |
| 5597 | } |
| 5598 | return NULL; |
| 5599 | } |
| 5600 | |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 5601 | /* There is no suspend to RAM support at DSA level yet, the switch configuration |
| 5602 | * would be lost after a power cycle so prevent it to be suspended. |
| 5603 | */ |
| 5604 | static int __maybe_unused mv88e6xxx_suspend(struct device *dev) |
| 5605 | { |
| 5606 | return -EOPNOTSUPP; |
| 5607 | } |
| 5608 | |
| 5609 | static int __maybe_unused mv88e6xxx_resume(struct device *dev) |
| 5610 | { |
| 5611 | return 0; |
| 5612 | } |
| 5613 | |
| 5614 | static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume); |
| 5615 | |
Vivien Didelot | 57d3231 | 2016-06-20 13:13:58 -0400 | [diff] [blame] | 5616 | static int mv88e6xxx_probe(struct mdio_device *mdiodev) |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5617 | { |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5618 | struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data; |
David S. Miller | 7ddae24 | 2018-05-20 19:04:24 -0400 | [diff] [blame] | 5619 | const struct mv88e6xxx_info *compat_info = NULL; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5620 | struct device *dev = &mdiodev->dev; |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 5621 | struct device_node *np = dev->of_node; |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5622 | struct mv88e6xxx_chip *chip; |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5623 | int port; |
Andrew Lunn | 52638f7 | 2016-05-10 23:27:22 +0200 | [diff] [blame] | 5624 | int err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5625 | |
Andrew Lunn | 7bb8c99 | 2018-05-31 00:15:42 +0200 | [diff] [blame] | 5626 | if (!np && !pdata) |
| 5627 | return -EINVAL; |
| 5628 | |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5629 | if (np) |
| 5630 | compat_info = of_device_get_match_data(dev); |
| 5631 | |
| 5632 | if (pdata) { |
| 5633 | compat_info = pdata_device_get_match_data(dev); |
| 5634 | |
| 5635 | if (!pdata->netdev) |
| 5636 | return -EINVAL; |
| 5637 | |
| 5638 | for (port = 0; port < DSA_MAX_PORTS; port++) { |
| 5639 | if (!(pdata->enabled_ports & (1 << port))) |
| 5640 | continue; |
| 5641 | if (strcmp(pdata->cd.port_names[port], "cpu")) |
| 5642 | continue; |
| 5643 | pdata->cd.netdev[port] = &pdata->netdev->dev; |
| 5644 | break; |
| 5645 | } |
| 5646 | } |
| 5647 | |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5648 | if (!compat_info) |
| 5649 | return -EINVAL; |
| 5650 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5651 | chip = mv88e6xxx_alloc_chip(dev); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5652 | if (!chip) { |
| 5653 | err = -ENOMEM; |
| 5654 | goto out; |
| 5655 | } |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5656 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5657 | chip->info = compat_info; |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5658 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5659 | err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr); |
Vivien Didelot | 4a70c4a | 2016-06-20 13:14:07 -0400 | [diff] [blame] | 5660 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5661 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5662 | |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 5663 | chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5664 | if (IS_ERR(chip->reset)) { |
| 5665 | err = PTR_ERR(chip->reset); |
| 5666 | goto out; |
| 5667 | } |
Baruch Siach | 7b75e49 | 2019-06-27 21:17:39 +0300 | [diff] [blame] | 5668 | if (chip->reset) |
| 5669 | usleep_range(1000, 2000); |
Andrew Lunn | b4308f0 | 2016-11-21 23:26:55 +0100 | [diff] [blame] | 5670 | |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5671 | err = mv88e6xxx_detect(chip); |
Vivien Didelot | bc46a3d | 2016-06-20 13:14:08 -0400 | [diff] [blame] | 5672 | if (err) |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5673 | goto out; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5674 | |
Vivien Didelot | e57e5e7 | 2016-08-15 17:19:00 -0400 | [diff] [blame] | 5675 | mv88e6xxx_phy_init(chip); |
| 5676 | |
Andrew Lunn | 00baabe | 2018-05-19 22:31:35 +0200 | [diff] [blame] | 5677 | if (chip->info->ops->get_eeprom) { |
| 5678 | if (np) |
| 5679 | of_property_read_u32(np, "eeprom-length", |
| 5680 | &chip->eeprom_len); |
| 5681 | else |
| 5682 | chip->eeprom_len = pdata->eeprom_len; |
| 5683 | } |
Andrew Lunn | f8cd875 | 2016-05-10 23:27:25 +0200 | [diff] [blame] | 5684 | |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5685 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5686 | err = mv88e6xxx_switch_reset(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5687 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 5688 | if (err) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5689 | goto out; |
Andrew Lunn | b516d45 | 2016-06-04 21:17:06 +0200 | [diff] [blame] | 5690 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 5691 | if (np) { |
| 5692 | chip->irq = of_irq_get(np, 0); |
| 5693 | if (chip->irq == -EPROBE_DEFER) { |
| 5694 | err = chip->irq; |
| 5695 | goto out; |
| 5696 | } |
Andrew Lunn | 83c0afa | 2016-06-04 21:17:07 +0200 | [diff] [blame] | 5697 | } |
| 5698 | |
Andrew Lunn | a27415d | 2019-05-01 00:10:50 +0200 | [diff] [blame] | 5699 | if (pdata) |
| 5700 | chip->irq = pdata->irq; |
| 5701 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5702 | /* 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] | 5703 | * the PHYs will link their interrupts to these interrupt |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5704 | * controllers |
| 5705 | */ |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5706 | mv88e6xxx_reg_lock(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5707 | if (chip->irq > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5708 | err = mv88e6xxx_g1_irq_setup(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5709 | else |
| 5710 | err = mv88e6xxx_irq_poll_setup(chip); |
Rasmus Villemoes | c9acece | 2019-06-20 13:50:42 +0000 | [diff] [blame] | 5711 | mv88e6xxx_reg_unlock(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5712 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5713 | if (err) |
| 5714 | goto out; |
| 5715 | |
| 5716 | if (chip->info->g2_irqs > 0) { |
| 5717 | err = mv88e6xxx_g2_irq_setup(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5718 | if (err) |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5719 | goto out_g1_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5720 | } |
| 5721 | |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5722 | err = mv88e6xxx_g1_atu_prob_irq_setup(chip); |
| 5723 | if (err) |
| 5724 | goto out_g2_irq; |
| 5725 | |
| 5726 | err = mv88e6xxx_g1_vtu_prob_irq_setup(chip); |
| 5727 | if (err) |
| 5728 | goto out_g1_atu_prob_irq; |
| 5729 | |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5730 | err = mv88e6xxx_mdios_register(chip, np); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5731 | if (err) |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 5732 | goto out_g1_vtu_prob_irq; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5733 | |
Florian Fainelli | 55ed0ce | 2017-01-26 10:45:51 -0800 | [diff] [blame] | 5734 | err = mv88e6xxx_register_switch(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5735 | if (err) |
| 5736 | goto out_mdio; |
| 5737 | |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5738 | return 0; |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5739 | |
| 5740 | out_mdio: |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5741 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | 62eb116 | 2018-01-14 02:32:45 +0100 | [diff] [blame] | 5742 | out_g1_vtu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5743 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
Andrew Lunn | 0977644 | 2018-01-14 02:32:44 +0100 | [diff] [blame] | 5744 | out_g1_atu_prob_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5745 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5746 | out_g2_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5747 | if (chip->info->g2_irqs > 0) |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5748 | mv88e6xxx_g2_irq_free(chip); |
| 5749 | out_g1_irq: |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5750 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 5751 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 294d711 | 2018-02-22 22:58:32 +0100 | [diff] [blame] | 5752 | else |
| 5753 | mv88e6xxx_irq_poll_free(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5754 | out: |
Andrew Lunn | 877b7cb | 2018-05-19 22:31:34 +0200 | [diff] [blame] | 5755 | if (pdata) |
| 5756 | dev_put(pdata->netdev); |
| 5757 | |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5758 | return err; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5759 | } |
| 5760 | |
| 5761 | static void mv88e6xxx_remove(struct mdio_device *mdiodev) |
| 5762 | { |
| 5763 | struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev); |
Vivien Didelot | 04bed14 | 2016-08-31 18:06:13 -0400 | [diff] [blame] | 5764 | struct mv88e6xxx_chip *chip = ds->priv; |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5765 | |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 5766 | if (chip->info->ptp_support) { |
| 5767 | mv88e6xxx_hwtstamp_free(chip); |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5768 | mv88e6xxx_ptp_free(chip); |
Brandon Streiff | c6fe0ad | 2018-02-14 01:07:50 +0100 | [diff] [blame] | 5769 | } |
Brandon Streiff | 2fa8d3a | 2018-02-14 01:07:45 +0100 | [diff] [blame] | 5770 | |
Andrew Lunn | 930188c | 2016-08-22 16:01:03 +0200 | [diff] [blame] | 5771 | mv88e6xxx_phy_destroy(chip); |
Vivien Didelot | fad09c7 | 2016-06-21 12:28:20 -0400 | [diff] [blame] | 5772 | mv88e6xxx_unregister_switch(chip); |
Andrew Lunn | a3c53be5 | 2017-01-24 14:53:50 +0100 | [diff] [blame] | 5773 | mv88e6xxx_mdios_unregister(chip); |
Andrew Lunn | dc30c35 | 2016-10-16 19:56:49 +0200 | [diff] [blame] | 5774 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 5775 | mv88e6xxx_g1_vtu_prob_irq_free(chip); |
| 5776 | mv88e6xxx_g1_atu_prob_irq_free(chip); |
| 5777 | |
| 5778 | if (chip->info->g2_irqs > 0) |
| 5779 | mv88e6xxx_g2_irq_free(chip); |
| 5780 | |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 5781 | if (chip->irq > 0) |
Andrew Lunn | 46712644 | 2016-11-20 20:14:15 +0100 | [diff] [blame] | 5782 | mv88e6xxx_g1_irq_free(chip); |
Andrew Lunn | 76f38f1 | 2018-03-17 20:21:09 +0100 | [diff] [blame] | 5783 | else |
| 5784 | mv88e6xxx_irq_poll_free(chip); |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5785 | } |
| 5786 | |
| 5787 | static const struct of_device_id mv88e6xxx_of_match[] = { |
Vivien Didelot | caac854 | 2016-06-20 13:14:09 -0400 | [diff] [blame] | 5788 | { |
| 5789 | .compatible = "marvell,mv88e6085", |
| 5790 | .data = &mv88e6xxx_table[MV88E6085], |
| 5791 | }, |
Andrew Lunn | 1a3b39e | 2016-11-21 23:26:57 +0100 | [diff] [blame] | 5792 | { |
| 5793 | .compatible = "marvell,mv88e6190", |
| 5794 | .data = &mv88e6xxx_table[MV88E6190], |
| 5795 | }, |
Rasmus Villemoes | 1f71836 | 2019-06-04 07:34:32 +0000 | [diff] [blame] | 5796 | { |
| 5797 | .compatible = "marvell,mv88e6250", |
| 5798 | .data = &mv88e6xxx_table[MV88E6250], |
| 5799 | }, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5800 | { /* sentinel */ }, |
| 5801 | }; |
| 5802 | |
| 5803 | MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match); |
| 5804 | |
| 5805 | static struct mdio_driver mv88e6xxx_driver = { |
| 5806 | .probe = mv88e6xxx_probe, |
| 5807 | .remove = mv88e6xxx_remove, |
| 5808 | .mdiodrv.driver = { |
| 5809 | .name = "mv88e6085", |
| 5810 | .of_match_table = mv88e6xxx_of_match, |
Miquel Raynal | bcd3d9d | 2019-02-05 12:07:28 +0100 | [diff] [blame] | 5811 | .pm = &mv88e6xxx_pm_ops, |
Andrew Lunn | 14c7b3c | 2016-05-10 23:27:21 +0200 | [diff] [blame] | 5812 | }, |
| 5813 | }; |
| 5814 | |
Andrew Lunn | 7324d50 | 2019-04-27 19:19:10 +0200 | [diff] [blame] | 5815 | mdio_module_driver(mv88e6xxx_driver); |
Ben Hutchings | 3d825ed | 2011-11-25 14:37:16 +0000 | [diff] [blame] | 5816 | |
| 5817 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 5818 | MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); |
| 5819 | MODULE_LICENSE("GPL"); |