blob: c6678aa9b4ef0716890f8ace36cda4cf609de045 [file] [log] [blame]
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04002 * Marvell 88e6xxx Ethernet switch single-chip support
3 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00004 * Copyright (c) 2008 Marvell Semiconductor
5 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
7 *
Vivien Didelot4333d612017-03-28 15:10:36 -04008 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
9 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
10 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
Barry Grussling19b2f972013-01-08 16:05:54 +000017#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070018#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020019#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070020#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020021#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000024#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000025#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020026#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000027#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040028#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020029#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020030#include <linux/of_mdio.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000031#include <linux/netdevice.h>
Andrew Lunnc8c1b392015-11-20 03:56:24 +010032#include <linux/gpio/consumer.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000033#include <linux/phy.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000034#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040035
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040036#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040037#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040038#include "global2.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020039#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010040#include "port.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000042
Vivien Didelotfad09c72016-06-21 12:28:20 -040043static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040044{
Vivien Didelotfad09c72016-06-21 12:28:20 -040045 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
46 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040047 dump_stack();
48 }
49}
50
Vivien Didelot914b32f2016-06-20 13:14:11 -040051/* The switch ADDR[4:1] configuration pins define the chip SMI device address
52 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
53 *
54 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
55 * is the only device connected to the SMI master. In this mode it responds to
56 * all 32 possible SMI addresses, and thus maps directly the internal devices.
57 *
58 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
59 * multiple devices to share the SMI interface. In this mode it responds to only
60 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000061 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040062
Vivien Didelotfad09c72016-06-21 12:28:20 -040063static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040064 int addr, int reg, u16 *val)
65{
Vivien Didelotfad09c72016-06-21 12:28:20 -040066 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040067 return -EOPNOTSUPP;
68
Vivien Didelotfad09c72016-06-21 12:28:20 -040069 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040070}
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040073 int addr, int reg, u16 val)
74{
Vivien Didelotfad09c72016-06-21 12:28:20 -040075 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040076 return -EOPNOTSUPP;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040079}
80
Vivien Didelotfad09c72016-06-21 12:28:20 -040081static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040082 int addr, int reg, u16 *val)
83{
84 int ret;
85
Vivien Didelotfad09c72016-06-21 12:28:20 -040086 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040087 if (ret < 0)
88 return ret;
89
90 *val = ret & 0xffff;
91
92 return 0;
93}
94
Vivien Didelotfad09c72016-06-21 12:28:20 -040095static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040096 int addr, int reg, u16 val)
97{
98 int ret;
99
Vivien Didelotfad09c72016-06-21 12:28:20 -0400100 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400101 if (ret < 0)
102 return ret;
103
104 return 0;
105}
106
Vivien Didelotc08026a2016-09-29 12:21:59 -0400107static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400108 .read = mv88e6xxx_smi_single_chip_read,
109 .write = mv88e6xxx_smi_single_chip_write,
110};
111
Vivien Didelotfad09c72016-06-21 12:28:20 -0400112static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000113{
114 int ret;
115 int i;
116
117 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400118 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000119 if (ret < 0)
120 return ret;
121
Andrew Lunncca8b132015-04-02 04:06:39 +0200122 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000123 return 0;
124 }
125
126 return -ETIMEDOUT;
127}
128
Vivien Didelotfad09c72016-06-21 12:28:20 -0400129static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400130 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000131{
132 int ret;
133
Barry Grussling3675c8d2013-01-08 16:05:53 +0000134 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400135 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000136 if (ret < 0)
137 return ret;
138
Barry Grussling3675c8d2013-01-08 16:05:53 +0000139 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400140 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200141 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000142 if (ret < 0)
143 return ret;
144
Barry Grussling3675c8d2013-01-08 16:05:53 +0000145 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400146 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000147 if (ret < 0)
148 return ret;
149
Barry Grussling3675c8d2013-01-08 16:05:53 +0000150 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400151 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000152 if (ret < 0)
153 return ret;
154
Vivien Didelot914b32f2016-06-20 13:14:11 -0400155 *val = ret & 0xffff;
156
157 return 0;
158}
159
Vivien Didelotfad09c72016-06-21 12:28:20 -0400160static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400161 int addr, int reg, u16 val)
162{
163 int ret;
164
165 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400166 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400167 if (ret < 0)
168 return ret;
169
170 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400171 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400172 if (ret < 0)
173 return ret;
174
175 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400176 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400177 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
178 if (ret < 0)
179 return ret;
180
181 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400182 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400183 if (ret < 0)
184 return ret;
185
186 return 0;
187}
188
Vivien Didelotc08026a2016-09-29 12:21:59 -0400189static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400190 .read = mv88e6xxx_smi_multi_chip_read,
191 .write = mv88e6xxx_smi_multi_chip_write,
192};
193
Vivien Didelotec561272016-09-02 14:45:33 -0400194int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400195{
196 int err;
197
Vivien Didelotfad09c72016-06-21 12:28:20 -0400198 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400199
Vivien Didelotfad09c72016-06-21 12:28:20 -0400200 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400201 if (err)
202 return err;
203
Vivien Didelotfad09c72016-06-21 12:28:20 -0400204 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400205 addr, reg, *val);
206
207 return 0;
208}
209
Vivien Didelotec561272016-09-02 14:45:33 -0400210int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400211{
212 int err;
213
Vivien Didelotfad09c72016-06-21 12:28:20 -0400214 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400215
Vivien Didelotfad09c72016-06-21 12:28:20 -0400216 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400217 if (err)
218 return err;
219
Vivien Didelotfad09c72016-06-21 12:28:20 -0400220 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400221 addr, reg, val);
222
223 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000224}
225
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200226struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100227{
228 struct mv88e6xxx_mdio_bus *mdio_bus;
229
230 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
231 list);
232 if (!mdio_bus)
233 return NULL;
234
235 return mdio_bus->bus;
236}
237
Andrew Lunndc30c352016-10-16 19:56:49 +0200238static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
239{
240 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
241 unsigned int n = d->hwirq;
242
243 chip->g1_irq.masked |= (1 << n);
244}
245
246static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
247{
248 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
249 unsigned int n = d->hwirq;
250
251 chip->g1_irq.masked &= ~(1 << n);
252}
253
254static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
255{
256 struct mv88e6xxx_chip *chip = dev_id;
257 unsigned int nhandled = 0;
258 unsigned int sub_irq;
259 unsigned int n;
260 u16 reg;
261 int err;
262
263 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400264 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200265 mutex_unlock(&chip->reg_lock);
266
267 if (err)
268 goto out;
269
270 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
271 if (reg & (1 << n)) {
272 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
273 handle_nested_irq(sub_irq);
274 ++nhandled;
275 }
276 }
277out:
278 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
279}
280
281static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
282{
283 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
284
285 mutex_lock(&chip->reg_lock);
286}
287
288static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
289{
290 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
291 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
292 u16 reg;
293 int err;
294
Vivien Didelotd77f4322017-06-15 12:14:03 -0400295 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200296 if (err)
297 goto out;
298
299 reg &= ~mask;
300 reg |= (~chip->g1_irq.masked & mask);
301
Vivien Didelotd77f4322017-06-15 12:14:03 -0400302 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200303 if (err)
304 goto out;
305
306out:
307 mutex_unlock(&chip->reg_lock);
308}
309
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530310static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200311 .name = "mv88e6xxx-g1",
312 .irq_mask = mv88e6xxx_g1_irq_mask,
313 .irq_unmask = mv88e6xxx_g1_irq_unmask,
314 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
315 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
316};
317
318static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
319 unsigned int irq,
320 irq_hw_number_t hwirq)
321{
322 struct mv88e6xxx_chip *chip = d->host_data;
323
324 irq_set_chip_data(irq, d->host_data);
325 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
326 irq_set_noprobe(irq);
327
328 return 0;
329}
330
331static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
332 .map = mv88e6xxx_g1_irq_domain_map,
333 .xlate = irq_domain_xlate_twocell,
334};
335
336static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
337{
338 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100339 u16 mask;
340
Vivien Didelotd77f4322017-06-15 12:14:03 -0400341 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100342 mask |= GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400343 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100344
345 free_irq(chip->irq, chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200346
Andreas Färber5edef2f2016-11-27 23:26:28 +0100347 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100348 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200349 irq_dispose_mapping(virq);
350 }
351
Andrew Lunna3db3d32016-11-20 20:14:14 +0100352 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200353}
354
355static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
356{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100357 int err, irq, virq;
358 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200359
360 chip->g1_irq.nirqs = chip->info->g1_irqs;
361 chip->g1_irq.domain = irq_domain_add_simple(
362 NULL, chip->g1_irq.nirqs, 0,
363 &mv88e6xxx_g1_irq_domain_ops, chip);
364 if (!chip->g1_irq.domain)
365 return -ENOMEM;
366
367 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
368 irq_create_mapping(chip->g1_irq.domain, irq);
369
370 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
371 chip->g1_irq.masked = ~0;
372
Vivien Didelotd77f4322017-06-15 12:14:03 -0400373 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200374 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100375 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200376
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100377 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200378
Vivien Didelotd77f4322017-06-15 12:14:03 -0400379 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200380 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100381 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200382
383 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400384 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200385 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100386 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200387
388 err = request_threaded_irq(chip->irq, NULL,
389 mv88e6xxx_g1_irq_thread_fn,
390 IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
391 dev_name(chip->dev), chip);
392 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100393 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200394
395 return 0;
396
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100397out_disable:
398 mask |= GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400399 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100400
401out_mapping:
402 for (irq = 0; irq < 16; irq++) {
403 virq = irq_find_mapping(chip->g1_irq.domain, irq);
404 irq_dispose_mapping(virq);
405 }
406
407 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200408
409 return err;
410}
411
Vivien Didelotec561272016-09-02 14:45:33 -0400412int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400413{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200414 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400415
Andrew Lunn6441e6692016-08-19 00:01:55 +0200416 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400417 u16 val;
418 int err;
419
420 err = mv88e6xxx_read(chip, addr, reg, &val);
421 if (err)
422 return err;
423
424 if (!(val & mask))
425 return 0;
426
427 usleep_range(1000, 2000);
428 }
429
Andrew Lunn30853552016-08-19 00:01:57 +0200430 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400431 return -ETIMEDOUT;
432}
433
Vivien Didelotf22ab642016-07-18 20:45:31 -0400434/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400435int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400436{
437 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200438 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400439
440 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200441 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
442 if (err)
443 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400444
445 /* Set the Update bit to trigger a write operation */
446 val = BIT(15) | update;
447
448 return mv88e6xxx_write(chip, addr, reg, val);
449}
450
Vivien Didelotd78343d2016-11-04 03:23:36 +0100451static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
452 int link, int speed, int duplex,
453 phy_interface_t mode)
454{
455 int err;
456
457 if (!chip->info->ops->port_set_link)
458 return 0;
459
460 /* Port's MAC control must not be changed unless the link is down */
461 err = chip->info->ops->port_set_link(chip, port, 0);
462 if (err)
463 return err;
464
465 if (chip->info->ops->port_set_speed) {
466 err = chip->info->ops->port_set_speed(chip, port, speed);
467 if (err && err != -EOPNOTSUPP)
468 goto restore_link;
469 }
470
471 if (chip->info->ops->port_set_duplex) {
472 err = chip->info->ops->port_set_duplex(chip, port, duplex);
473 if (err && err != -EOPNOTSUPP)
474 goto restore_link;
475 }
476
477 if (chip->info->ops->port_set_rgmii_delay) {
478 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
479 if (err && err != -EOPNOTSUPP)
480 goto restore_link;
481 }
482
Andrew Lunnf39908d2017-02-04 20:02:50 +0100483 if (chip->info->ops->port_set_cmode) {
484 err = chip->info->ops->port_set_cmode(chip, port, mode);
485 if (err && err != -EOPNOTSUPP)
486 goto restore_link;
487 }
488
Vivien Didelotd78343d2016-11-04 03:23:36 +0100489 err = 0;
490restore_link:
491 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400492 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100493
494 return err;
495}
496
Andrew Lunndea87022015-08-31 15:56:47 +0200497/* We expect the switch to perform auto negotiation if there is a real
498 * phy. However, in the case of a fixed link phy, we force the port
499 * settings from the fixed link settings.
500 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400501static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
502 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200503{
Vivien Didelot04bed142016-08-31 18:06:13 -0400504 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200505 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200506
507 if (!phy_is_pseudo_fixed_link(phydev))
508 return;
509
Vivien Didelotfad09c72016-06-21 12:28:20 -0400510 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100511 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
512 phydev->duplex, phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400513 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100514
515 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400516 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200517}
518
Andrew Lunna605a0f2016-11-21 23:26:58 +0100519static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000520{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100521 if (!chip->info->ops->stats_snapshot)
522 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000523
Andrew Lunna605a0f2016-11-21 23:26:58 +0100524 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000525}
526
Andrew Lunne413e7e2015-04-02 04:06:38 +0200527static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100528 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
529 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
530 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
531 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
532 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
533 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
534 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
535 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
536 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
537 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
538 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
539 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
540 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
541 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
542 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
543 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
544 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
545 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
546 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
547 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
548 { "single", 4, 0x14, STATS_TYPE_BANK0, },
549 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
550 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
551 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
552 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
553 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
554 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
555 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
556 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
557 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
558 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
559 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
560 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
561 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
562 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
563 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
564 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
565 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
566 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
567 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
568 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
569 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
570 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
571 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
572 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
573 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
574 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
575 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
576 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
577 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
578 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
579 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
580 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
581 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
582 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
583 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
584 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
585 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
586 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200587};
588
Vivien Didelotfad09c72016-06-21 12:28:20 -0400589static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100590 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100591 int port, u16 bank1_select,
592 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200593{
Andrew Lunn80c46272015-06-20 18:42:30 +0200594 u32 low;
595 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100596 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200597 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200598 u64 value;
599
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100600 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100601 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200602 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
603 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200604 return UINT64_MAX;
605
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200606 low = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200607 if (s->sizeof_stat == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200608 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
609 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200610 return UINT64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200611 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200612 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100613 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100614 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100615 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100616 /* fall through */
617 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100618 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100619 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunn80c46272015-06-20 18:42:30 +0200620 if (s->sizeof_stat == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100621 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500622 break;
623 default:
624 return UINT64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200625 }
626 value = (((u64)high) << 16) | low;
627 return value;
628}
629
Andrew Lunndfafe442016-11-21 23:27:02 +0100630static void mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
631 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100632{
633 struct mv88e6xxx_hw_stat *stat;
634 int i, j;
635
636 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
637 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100638 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100639 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
640 ETH_GSTRING_LEN);
641 j++;
642 }
643 }
644}
645
Andrew Lunndfafe442016-11-21 23:27:02 +0100646static void mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
647 uint8_t *data)
648{
649 mv88e6xxx_stats_get_strings(chip, data,
650 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
651}
652
653static void mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
654 uint8_t *data)
655{
656 mv88e6xxx_stats_get_strings(chip, data,
657 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
658}
659
660static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
661 uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100662{
Vivien Didelot04bed142016-08-31 18:06:13 -0400663 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunndfafe442016-11-21 23:27:02 +0100664
665 if (chip->info->ops->stats_get_strings)
666 chip->info->ops->stats_get_strings(chip, data);
667}
668
669static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
670 int types)
671{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100672 struct mv88e6xxx_hw_stat *stat;
673 int i, j;
674
675 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
676 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100677 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100678 j++;
679 }
680 return j;
681}
682
Andrew Lunndfafe442016-11-21 23:27:02 +0100683static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
684{
685 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
686 STATS_TYPE_PORT);
687}
688
689static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
690{
691 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
692 STATS_TYPE_BANK1);
693}
694
695static int mv88e6xxx_get_sset_count(struct dsa_switch *ds)
696{
697 struct mv88e6xxx_chip *chip = ds->priv;
698
699 if (chip->info->ops->stats_get_sset_count)
700 return chip->info->ops->stats_get_sset_count(chip);
701
702 return 0;
703}
704
Andrew Lunn052f9472016-11-21 23:27:03 +0100705static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100706 uint64_t *data, int types,
707 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100708{
709 struct mv88e6xxx_hw_stat *stat;
710 int i, j;
711
712 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
713 stat = &mv88e6xxx_hw_stats[i];
714 if (stat->type & types) {
Andrew Lunne0d8b612016-11-21 23:27:04 +0100715 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
716 bank1_select,
717 histogram);
Andrew Lunn052f9472016-11-21 23:27:03 +0100718 j++;
719 }
720 }
721}
722
723static void mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
724 uint64_t *data)
725{
726 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100727 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400728 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100729}
730
731static void mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
732 uint64_t *data)
733{
734 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100735 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400736 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
737 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100738}
739
740static void mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
741 uint64_t *data)
742{
743 return mv88e6xxx_stats_get_stats(chip, port, data,
744 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400745 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
746 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100747}
748
749static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
750 uint64_t *data)
751{
752 if (chip->info->ops->stats_get_stats)
753 chip->info->ops->stats_get_stats(chip, port, data);
754}
755
Vivien Didelotf81ec902016-05-09 13:22:58 -0400756static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
757 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000758{
Vivien Didelot04bed142016-08-31 18:06:13 -0400759 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000760 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000761
Vivien Didelotfad09c72016-06-21 12:28:20 -0400762 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000763
Andrew Lunna605a0f2016-11-21 23:26:58 +0100764 ret = mv88e6xxx_stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000765 if (ret < 0) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400766 mutex_unlock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000767 return;
768 }
Andrew Lunn052f9472016-11-21 23:27:03 +0100769
770 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000771
Vivien Didelotfad09c72016-06-21 12:28:20 -0400772 mutex_unlock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000773}
Ben Hutchings98e67302011-11-25 14:36:19 +0000774
Andrew Lunnde2273872016-11-21 23:27:01 +0100775static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
776{
777 if (chip->info->ops->stats_set_histogram)
778 return chip->info->ops->stats_set_histogram(chip);
779
780 return 0;
781}
782
Vivien Didelotf81ec902016-05-09 13:22:58 -0400783static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700784{
785 return 32 * sizeof(u16);
786}
787
Vivien Didelotf81ec902016-05-09 13:22:58 -0400788static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
789 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700790{
Vivien Didelot04bed142016-08-31 18:06:13 -0400791 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200792 int err;
793 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700794 u16 *p = _p;
795 int i;
796
797 regs->version = 0;
798
799 memset(p, 0xff, 32 * sizeof(u16));
800
Vivien Didelotfad09c72016-06-21 12:28:20 -0400801 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -0400802
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700803 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700804
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200805 err = mv88e6xxx_port_read(chip, port, i, &reg);
806 if (!err)
807 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700808 }
Vivien Didelot23062512016-05-09 13:22:45 -0400809
Vivien Didelotfad09c72016-06-21 12:28:20 -0400810 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700811}
812
Vivien Didelot08f50062017-08-01 16:32:41 -0400813static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
814 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800815{
Vivien Didelot5480db62017-08-01 16:32:40 -0400816 /* Nothing to do on the port's MAC */
817 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800818}
819
Vivien Didelot08f50062017-08-01 16:32:41 -0400820static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
821 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800822{
Vivien Didelot5480db62017-08-01 16:32:40 -0400823 /* Nothing to do on the port's MAC */
824 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800825}
826
Vivien Didelote5887a22017-03-30 17:37:11 -0400827static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700828{
Vivien Didelote5887a22017-03-30 17:37:11 -0400829 struct dsa_switch *ds = NULL;
830 struct net_device *br;
831 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500832 int i;
833
Vivien Didelote5887a22017-03-30 17:37:11 -0400834 if (dev < DSA_MAX_SWITCHES)
835 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500836
Vivien Didelote5887a22017-03-30 17:37:11 -0400837 /* Prevent frames from unknown switch or port */
838 if (!ds || port >= ds->num_ports)
839 return 0;
840
841 /* Frames from DSA links and CPU ports can egress any local port */
842 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
843 return mv88e6xxx_port_mask(chip);
844
845 br = ds->ports[port].bridge_dev;
846 pvlan = 0;
847
848 /* Frames from user ports can egress any local DSA links and CPU ports,
849 * as well as any local member of their bridge group.
850 */
851 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
852 if (dsa_is_cpu_port(chip->ds, i) ||
853 dsa_is_dsa_port(chip->ds, i) ||
854 (br && chip->ds->ports[i].bridge_dev == br))
855 pvlan |= BIT(i);
856
857 return pvlan;
858}
859
Vivien Didelot240ea3e2017-03-30 17:37:12 -0400860static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -0400861{
862 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500863
864 /* prevent frames from going back out of the port they came in on */
865 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700866
Vivien Didelot5a7921f2016-11-04 03:23:28 +0100867 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700868}
869
Vivien Didelotf81ec902016-05-09 13:22:58 -0400870static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
871 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700872{
Vivien Didelot04bed142016-08-31 18:06:13 -0400873 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -0400874 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700875
Vivien Didelotfad09c72016-06-21 12:28:20 -0400876 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -0400877 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400878 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -0400879
880 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400881 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700882}
883
Vivien Didelot9e907d72017-07-17 13:03:43 -0400884static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
885{
886 if (chip->info->ops->pot_clear)
887 return chip->info->ops->pot_clear(chip);
888
889 return 0;
890}
891
Vivien Didelot51c901a2017-07-17 13:03:41 -0400892static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
893{
894 if (chip->info->ops->mgmt_rsvd2cpu)
895 return chip->info->ops->mgmt_rsvd2cpu(chip);
896
897 return 0;
898}
899
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500900static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
901{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500902 int err;
903
Vivien Didelotdaefc942017-03-11 16:12:54 -0500904 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
905 if (err)
906 return err;
907
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500908 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
909 if (err)
910 return err;
911
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500912 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
913}
914
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400915static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
916{
917 int port;
918 int err;
919
920 if (!chip->info->ops->irl_init_all)
921 return 0;
922
923 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
924 /* Disable ingress rate limiting by resetting all per port
925 * ingress rate limit resources to their initial state.
926 */
927 err = chip->info->ops->irl_init_all(chip, port);
928 if (err)
929 return err;
930 }
931
932 return 0;
933}
934
Vivien Didelot17a15942017-03-30 17:37:09 -0400935static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
936{
937 u16 pvlan = 0;
938
939 if (!mv88e6xxx_has_pvt(chip))
940 return -EOPNOTSUPP;
941
942 /* Skip the local source device, which uses in-chip port VLAN */
943 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -0400944 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -0400945
946 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
947}
948
Vivien Didelot81228992017-03-30 17:37:08 -0400949static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
950{
Vivien Didelot17a15942017-03-30 17:37:09 -0400951 int dev, port;
952 int err;
953
Vivien Didelot81228992017-03-30 17:37:08 -0400954 if (!mv88e6xxx_has_pvt(chip))
955 return 0;
956
957 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
958 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
959 */
Vivien Didelot17a15942017-03-30 17:37:09 -0400960 err = mv88e6xxx_g2_misc_4_bit_port(chip);
961 if (err)
962 return err;
963
964 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
965 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
966 err = mv88e6xxx_pvt_map(chip, dev, port);
967 if (err)
968 return err;
969 }
970 }
971
972 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -0400973}
974
Vivien Didelot749efcb2016-09-22 16:49:24 -0400975static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
976{
977 struct mv88e6xxx_chip *chip = ds->priv;
978 int err;
979
980 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -0500981 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400982 mutex_unlock(&chip->reg_lock);
983
984 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400985 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400986}
987
Vivien Didelotb486d7c2017-05-01 14:05:13 -0400988static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
989{
990 if (!chip->info->max_vid)
991 return 0;
992
993 return mv88e6xxx_g1_vtu_flush(chip);
994}
995
Vivien Didelotf1394b782017-05-01 14:05:22 -0400996static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
997 struct mv88e6xxx_vtu_entry *entry)
998{
999 if (!chip->info->ops->vtu_getnext)
1000 return -EOPNOTSUPP;
1001
1002 return chip->info->ops->vtu_getnext(chip, entry);
1003}
1004
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001005static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1006 struct mv88e6xxx_vtu_entry *entry)
1007{
1008 if (!chip->info->ops->vtu_loadpurge)
1009 return -EOPNOTSUPP;
1010
1011 return chip->info->ops->vtu_loadpurge(chip, entry);
1012}
1013
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001014static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001015{
1016 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001017 struct mv88e6xxx_vtu_entry vlan = {
1018 .vid = chip->info->max_vid,
1019 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001020 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001021
1022 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1023
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001024 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001025 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001026 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001027 if (err)
1028 return err;
1029
1030 set_bit(*fid, fid_bitmap);
1031 }
1032
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001033 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001034 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001035 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001036 if (err)
1037 return err;
1038
1039 if (!vlan.valid)
1040 break;
1041
1042 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001043 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001044
1045 /* The reset value 0x000 is used to indicate that multiple address
1046 * databases are not needed. Return the next positive available.
1047 */
1048 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001049 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001050 return -ENOSPC;
1051
1052 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001053 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001054}
1055
Vivien Didelot567aa592017-05-01 14:05:25 -04001056static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1057 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001058{
1059 int err;
1060
1061 if (!vid)
1062 return -EINVAL;
1063
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001064 entry->vid = vid - 1;
1065 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001066
Vivien Didelotf1394b782017-05-01 14:05:22 -04001067 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001068 if (err)
1069 return err;
1070
Vivien Didelot567aa592017-05-01 14:05:25 -04001071 if (entry->vid == vid && entry->valid)
1072 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001073
Vivien Didelot567aa592017-05-01 14:05:25 -04001074 if (new) {
1075 int i;
1076
1077 /* Initialize a fresh VLAN entry */
1078 memset(entry, 0, sizeof(*entry));
1079 entry->valid = true;
1080 entry->vid = vid;
1081
Vivien Didelot553a7682017-06-07 18:12:16 -04001082 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001083 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001084 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001085 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001086
1087 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001088 }
1089
Vivien Didelot567aa592017-05-01 14:05:25 -04001090 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1091 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001092}
1093
Vivien Didelotda9c3592016-02-12 12:09:40 -05001094static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1095 u16 vid_begin, u16 vid_end)
1096{
Vivien Didelot04bed142016-08-31 18:06:13 -04001097 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001098 struct mv88e6xxx_vtu_entry vlan = {
1099 .vid = vid_begin - 1,
1100 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001101 int i, err;
1102
1103 if (!vid_begin)
1104 return -EOPNOTSUPP;
1105
Vivien Didelotfad09c72016-06-21 12:28:20 -04001106 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001107
Vivien Didelotda9c3592016-02-12 12:09:40 -05001108 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001109 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001110 if (err)
1111 goto unlock;
1112
1113 if (!vlan.valid)
1114 break;
1115
1116 if (vlan.vid > vid_end)
1117 break;
1118
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001119 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001120 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1121 continue;
1122
Andrew Lunn66e28092016-12-11 21:07:19 +01001123 if (!ds->ports[port].netdev)
1124 continue;
1125
Vivien Didelotbd00e0532017-05-01 14:05:11 -04001126 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001127 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001128 continue;
1129
Vivien Didelotfae8a252017-01-27 15:29:42 -05001130 if (ds->ports[i].bridge_dev ==
1131 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001132 break; /* same bridge, check next VLAN */
1133
Vivien Didelotfae8a252017-01-27 15:29:42 -05001134 if (!ds->ports[i].bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001135 continue;
1136
Vivien Didelot774439e52017-06-08 18:34:08 -04001137 dev_err(ds->dev, "p%d: hw VLAN %d already used by %s\n",
1138 port, vlan.vid,
1139 netdev_name(ds->ports[i].bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001140 err = -EOPNOTSUPP;
1141 goto unlock;
1142 }
1143 } while (vlan.vid < vid_end);
1144
1145unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001146 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001147
1148 return err;
1149}
1150
Vivien Didelotf81ec902016-05-09 13:22:58 -04001151static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1152 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001153{
Vivien Didelot04bed142016-08-31 18:06:13 -04001154 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001155 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1156 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001157 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001158
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001159 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001160 return -EOPNOTSUPP;
1161
Vivien Didelotfad09c72016-06-21 12:28:20 -04001162 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001163 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001164 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001165
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001166 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001167}
1168
Vivien Didelot57d32312016-06-20 13:13:58 -04001169static int
1170mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
1171 const struct switchdev_obj_port_vlan *vlan,
1172 struct switchdev_trans *trans)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001173{
Vivien Didelot04bed142016-08-31 18:06:13 -04001174 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001175 int err;
1176
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001177 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001178 return -EOPNOTSUPP;
1179
Vivien Didelotda9c3592016-02-12 12:09:40 -05001180 /* If the requested port doesn't belong to the same bridge as the VLAN
1181 * members, do not support it (yet) and fallback to software VLAN.
1182 */
1183 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1184 vlan->vid_end);
1185 if (err)
1186 return err;
1187
Vivien Didelot76e398a2015-11-01 12:33:55 -05001188 /* We don't need any dynamic resource from the kernel (yet),
1189 * so skip the prepare phase.
1190 */
1191 return 0;
1192}
1193
Vivien Didelotfad09c72016-06-21 12:28:20 -04001194static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001195 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001196{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001197 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001198 int err;
1199
Vivien Didelot567aa592017-05-01 14:05:25 -04001200 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001201 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001202 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001203
Vivien Didelotc91498e2017-06-07 18:12:13 -04001204 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001205
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001206 return mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001207}
1208
Vivien Didelotf81ec902016-05-09 13:22:58 -04001209static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
1210 const struct switchdev_obj_port_vlan *vlan,
1211 struct switchdev_trans *trans)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001212{
Vivien Didelot04bed142016-08-31 18:06:13 -04001213 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001214 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1215 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001216 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001217 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001218
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001219 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001220 return;
1221
Vivien Didelotc91498e2017-06-07 18:12:13 -04001222 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001223 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001224 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001225 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001226 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001227 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001228
Vivien Didelotfad09c72016-06-21 12:28:20 -04001229 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001230
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001231 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001232 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001233 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1234 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001235
Vivien Didelot77064f32016-11-04 03:23:30 +01001236 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001237 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1238 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001239
Vivien Didelotfad09c72016-06-21 12:28:20 -04001240 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001241}
1242
Vivien Didelotfad09c72016-06-21 12:28:20 -04001243static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001244 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001245{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001246 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001247 int i, err;
1248
Vivien Didelot567aa592017-05-01 14:05:25 -04001249 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001250 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001251 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001252
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001253 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001254 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001255 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001256
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001257 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001258
1259 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001260 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001261 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001262 if (vlan.member[i] !=
1263 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001264 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001265 break;
1266 }
1267 }
1268
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001269 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001270 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001271 return err;
1272
Vivien Didelote606ca32017-03-11 16:12:55 -05001273 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001274}
1275
Vivien Didelotf81ec902016-05-09 13:22:58 -04001276static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1277 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001278{
Vivien Didelot04bed142016-08-31 18:06:13 -04001279 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001280 u16 pvid, vid;
1281 int err = 0;
1282
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001283 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001284 return -EOPNOTSUPP;
1285
Vivien Didelotfad09c72016-06-21 12:28:20 -04001286 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001287
Vivien Didelot77064f32016-11-04 03:23:30 +01001288 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001289 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001290 goto unlock;
1291
Vivien Didelot76e398a2015-11-01 12:33:55 -05001292 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001293 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001294 if (err)
1295 goto unlock;
1296
1297 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001298 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001299 if (err)
1300 goto unlock;
1301 }
1302 }
1303
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001304unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001305 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001306
1307 return err;
1308}
1309
Vivien Didelot83dabd12016-08-31 11:50:04 -04001310static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1311 const unsigned char *addr, u16 vid,
1312 u8 state)
Vivien Didelotfd231c82015-08-10 09:09:50 -04001313{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001314 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot88472932016-09-19 19:56:11 -04001315 struct mv88e6xxx_atu_entry entry;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001316 int err;
Vivien Didelotfd231c82015-08-10 09:09:50 -04001317
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001318 /* Null VLAN ID corresponds to the port private database */
1319 if (vid == 0)
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001320 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001321 else
Vivien Didelot567aa592017-05-01 14:05:25 -04001322 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001323 if (err)
1324 return err;
1325
Vivien Didelot27c0e602017-06-15 12:14:01 -04001326 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001327 ether_addr_copy(entry.mac, addr);
1328 eth_addr_dec(entry.mac);
1329
1330 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
Vivien Didelot88472932016-09-19 19:56:11 -04001331 if (err)
1332 return err;
1333
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001334 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelot27c0e602017-06-15 12:14:01 -04001335 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001336 !ether_addr_equal(entry.mac, addr)) {
1337 memset(&entry, 0, sizeof(entry));
1338 ether_addr_copy(entry.mac, addr);
1339 }
1340
Vivien Didelot88472932016-09-19 19:56:11 -04001341 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelot27c0e602017-06-15 12:14:01 -04001342 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001343 entry.portvec &= ~BIT(port);
1344 if (!entry.portvec)
Vivien Didelot27c0e602017-06-15 12:14:01 -04001345 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelot88472932016-09-19 19:56:11 -04001346 } else {
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001347 entry.portvec |= BIT(port);
Vivien Didelot88472932016-09-19 19:56:11 -04001348 entry.state = state;
Vivien Didelotfd231c82015-08-10 09:09:50 -04001349 }
1350
Vivien Didelot9c13c022017-03-11 16:12:52 -05001351 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001352}
1353
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001354static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1355 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001356{
Vivien Didelot04bed142016-08-31 18:06:13 -04001357 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001358 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001359
Vivien Didelotfad09c72016-06-21 12:28:20 -04001360 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001361 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1362 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001363 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001364
1365 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001366}
1367
Vivien Didelotf81ec902016-05-09 13:22:58 -04001368static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001369 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001370{
Vivien Didelot04bed142016-08-31 18:06:13 -04001371 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001372 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001373
Vivien Didelotfad09c72016-06-21 12:28:20 -04001374 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001375 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001376 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001377 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001378
Vivien Didelot83dabd12016-08-31 11:50:04 -04001379 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001380}
1381
Vivien Didelot83dabd12016-08-31 11:50:04 -04001382static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1383 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001384 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001385{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001386 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001387 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001388 int err;
1389
Vivien Didelot27c0e602017-06-15 12:14:01 -04001390 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001391 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001392
1393 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001394 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001395 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001396 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001397
Vivien Didelot27c0e602017-06-15 12:14:01 -04001398 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001399 break;
1400
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001401 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001402 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001403
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001404 if (!is_unicast_ether_addr(addr.mac))
1405 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001406
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001407 is_static = (addr.state ==
1408 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1409 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001410 if (err)
1411 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001412 } while (!is_broadcast_ether_addr(addr.mac));
1413
1414 return err;
1415}
1416
Vivien Didelot83dabd12016-08-31 11:50:04 -04001417static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001418 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001419{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001420 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001421 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001422 };
1423 u16 fid;
1424 int err;
1425
1426 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001427 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001428 if (err)
1429 return err;
1430
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001431 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001432 if (err)
1433 return err;
1434
1435 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001436 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001437 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001438 if (err)
1439 return err;
1440
1441 if (!vlan.valid)
1442 break;
1443
1444 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001445 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001446 if (err)
1447 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001448 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001449
1450 return err;
1451}
1452
Vivien Didelotf81ec902016-05-09 13:22:58 -04001453static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001454 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001455{
Vivien Didelot04bed142016-08-31 18:06:13 -04001456 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001457 int err;
1458
Vivien Didelotfad09c72016-06-21 12:28:20 -04001459 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001460 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001461 mutex_unlock(&chip->reg_lock);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001462
1463 return err;
1464}
1465
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001466static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1467 struct net_device *br)
1468{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001469 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001470 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001471 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001472 int err;
1473
1474 /* Remap the Port VLAN of each local bridge group member */
1475 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1476 if (chip->ds->ports[port].bridge_dev == br) {
1477 err = mv88e6xxx_port_vlan_map(chip, port);
1478 if (err)
1479 return err;
1480 }
1481 }
1482
Vivien Didelote96a6e02017-03-30 17:37:13 -04001483 if (!mv88e6xxx_has_pvt(chip))
1484 return 0;
1485
1486 /* Remap the Port VLAN of each cross-chip bridge group member */
1487 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1488 ds = chip->ds->dst->ds[dev];
1489 if (!ds)
1490 break;
1491
1492 for (port = 0; port < ds->num_ports; ++port) {
1493 if (ds->ports[port].bridge_dev == br) {
1494 err = mv88e6xxx_pvt_map(chip, dev, port);
1495 if (err)
1496 return err;
1497 }
1498 }
1499 }
1500
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001501 return 0;
1502}
1503
Vivien Didelotf81ec902016-05-09 13:22:58 -04001504static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001505 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001506{
Vivien Didelot04bed142016-08-31 18:06:13 -04001507 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001508 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001509
Vivien Didelotfad09c72016-06-21 12:28:20 -04001510 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001511 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001512 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001513
Vivien Didelot466dfa02016-02-26 13:16:05 -05001514 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001515}
1516
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001517static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1518 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001519{
Vivien Didelot04bed142016-08-31 18:06:13 -04001520 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001521
Vivien Didelotfad09c72016-06-21 12:28:20 -04001522 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001523 if (mv88e6xxx_bridge_map(chip, br) ||
1524 mv88e6xxx_port_vlan_map(chip, port))
1525 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001526 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001527}
1528
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001529static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1530 int port, struct net_device *br)
1531{
1532 struct mv88e6xxx_chip *chip = ds->priv;
1533 int err;
1534
1535 if (!mv88e6xxx_has_pvt(chip))
1536 return 0;
1537
1538 mutex_lock(&chip->reg_lock);
1539 err = mv88e6xxx_pvt_map(chip, dev, port);
1540 mutex_unlock(&chip->reg_lock);
1541
1542 return err;
1543}
1544
1545static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1546 int port, struct net_device *br)
1547{
1548 struct mv88e6xxx_chip *chip = ds->priv;
1549
1550 if (!mv88e6xxx_has_pvt(chip))
1551 return;
1552
1553 mutex_lock(&chip->reg_lock);
1554 if (mv88e6xxx_pvt_map(chip, dev, port))
1555 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1556 mutex_unlock(&chip->reg_lock);
1557}
1558
Vivien Didelot17e708b2016-12-05 17:30:27 -05001559static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1560{
1561 if (chip->info->ops->reset)
1562 return chip->info->ops->reset(chip);
1563
1564 return 0;
1565}
1566
Vivien Didelot309eca62016-12-05 17:30:26 -05001567static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1568{
1569 struct gpio_desc *gpiod = chip->reset;
1570
1571 /* If there is a GPIO connected to the reset pin, toggle it */
1572 if (gpiod) {
1573 gpiod_set_value_cansleep(gpiod, 1);
1574 usleep_range(10000, 20000);
1575 gpiod_set_value_cansleep(gpiod, 0);
1576 usleep_range(10000, 20000);
1577 }
1578}
1579
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001580static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1581{
1582 int i, err;
1583
1584 /* Set all ports to the Disabled state */
1585 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001586 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001587 if (err)
1588 return err;
1589 }
1590
1591 /* Wait for transmit queues to drain,
1592 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1593 */
1594 usleep_range(2000, 4000);
1595
1596 return 0;
1597}
1598
Vivien Didelotfad09c72016-06-21 12:28:20 -04001599static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001600{
Vivien Didelota935c052016-09-29 12:21:53 -04001601 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001602
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001603 err = mv88e6xxx_disable_ports(chip);
1604 if (err)
1605 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001606
Vivien Didelot309eca62016-12-05 17:30:26 -05001607 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001608
Vivien Didelot17e708b2016-12-05 17:30:27 -05001609 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001610}
1611
Vivien Didelot43145572017-03-11 16:12:59 -05001612static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001613 enum mv88e6xxx_frame_mode frame,
1614 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001615{
1616 int err;
1617
Vivien Didelot43145572017-03-11 16:12:59 -05001618 if (!chip->info->ops->port_set_frame_mode)
1619 return -EOPNOTSUPP;
1620
1621 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001622 if (err)
1623 return err;
1624
Vivien Didelot43145572017-03-11 16:12:59 -05001625 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1626 if (err)
1627 return err;
1628
1629 if (chip->info->ops->port_set_ether_type)
1630 return chip->info->ops->port_set_ether_type(chip, port, etype);
1631
1632 return 0;
1633}
1634
1635static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1636{
1637 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001638 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001639 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001640}
1641
1642static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1643{
1644 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001645 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001646 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001647}
1648
1649static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1650{
1651 return mv88e6xxx_set_port_mode(chip, port,
1652 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001653 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1654 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001655}
1656
1657static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1658{
1659 if (dsa_is_dsa_port(chip->ds, port))
1660 return mv88e6xxx_set_port_mode_dsa(chip, port);
1661
1662 if (dsa_is_normal_port(chip->ds, port))
1663 return mv88e6xxx_set_port_mode_normal(chip, port);
1664
1665 /* Setup CPU port mode depending on its supported tag format */
1666 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1667 return mv88e6xxx_set_port_mode_dsa(chip, port);
1668
1669 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1670 return mv88e6xxx_set_port_mode_edsa(chip, port);
1671
1672 return -EINVAL;
1673}
1674
Vivien Didelotea698f42017-03-11 16:12:50 -05001675static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1676{
1677 bool message = dsa_is_dsa_port(chip->ds, port);
1678
1679 return mv88e6xxx_port_set_message_port(chip, port, message);
1680}
1681
Vivien Didelot601aeed2017-03-11 16:13:00 -05001682static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1683{
1684 bool flood = port == dsa_upstream_port(chip->ds);
1685
1686 /* Upstream ports flood frames with unknown unicast or multicast DA */
1687 if (chip->info->ops->port_set_egress_floods)
1688 return chip->info->ops->port_set_egress_floods(chip, port,
1689 flood, flood);
1690
1691 return 0;
1692}
1693
Andrew Lunn6d917822017-05-26 01:03:21 +02001694static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1695 bool on)
1696{
Vivien Didelot523a8902017-05-26 18:02:42 -04001697 if (chip->info->ops->serdes_power)
1698 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001699
Vivien Didelot523a8902017-05-26 18:02:42 -04001700 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001701}
1702
Vivien Didelotfad09c72016-06-21 12:28:20 -04001703static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001704{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001705 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001706 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001707 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001708
Vivien Didelotd78343d2016-11-04 03:23:36 +01001709 /* MAC Forcing register: don't force link, speed, duplex or flow control
1710 * state to any particular values on physical ports, but force the CPU
1711 * port and all DSA ports to their maximum bandwidth and full duplex.
1712 */
1713 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1714 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1715 SPEED_MAX, DUPLEX_FULL,
1716 PHY_INTERFACE_MODE_NA);
1717 else
1718 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1719 SPEED_UNFORCED, DUPLEX_UNFORCED,
1720 PHY_INTERFACE_MODE_NA);
1721 if (err)
1722 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001723
1724 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1725 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1726 * tunneling, determine priority by looking at 802.1p and IP
1727 * priority fields (IP prio has precedence), and set STP state
1728 * to Forwarding.
1729 *
1730 * If this is the CPU link, use DSA or EDSA tagging depending
1731 * on which tagging mode was configured.
1732 *
1733 * If this is a link to another switch, use DSA tagging mode.
1734 *
1735 * If this is the upstream port for this switch, enable
1736 * forwarding of unknown unicasts and multicasts.
1737 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001738 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1739 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1740 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1741 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001742 if (err)
1743 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001744
Vivien Didelot601aeed2017-03-11 16:13:00 -05001745 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001746 if (err)
1747 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001748
Vivien Didelot601aeed2017-03-11 16:13:00 -05001749 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001750 if (err)
1751 return err;
1752
Andrew Lunn04aca992017-05-26 01:03:24 +02001753 /* Enable the SERDES interface for DSA and CPU ports. Normal
1754 * ports SERDES are enabled when the port is enabled, thus
1755 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001756 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001757 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1758 err = mv88e6xxx_serdes_power(chip, port, true);
1759 if (err)
1760 return err;
1761 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001762
Vivien Didelot8efdda42015-08-13 12:52:23 -04001763 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001764 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001765 * untagged frames on this port, do a destination address lookup on all
1766 * received packets as usual, disable ARP mirroring and don't send a
1767 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001768 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001769 err = mv88e6xxx_port_set_map_da(chip, port);
1770 if (err)
1771 return err;
1772
Andrew Lunn54d792f2015-05-06 01:09:47 +02001773 reg = 0;
Andrew Lunna23b2962017-02-04 20:15:28 +01001774 if (chip->info->ops->port_set_upstream_port) {
1775 err = chip->info->ops->port_set_upstream_port(
1776 chip, port, dsa_upstream_port(ds));
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001777 if (err)
1778 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001779 }
1780
Andrew Lunna23b2962017-02-04 20:15:28 +01001781 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001782 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001783 if (err)
1784 return err;
1785
Vivien Didelotcd782652017-06-08 18:34:13 -04001786 if (chip->info->ops->port_set_jumbo_size) {
1787 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001788 if (err)
1789 return err;
1790 }
1791
Andrew Lunn54d792f2015-05-06 01:09:47 +02001792 /* Port Association Vector: when learning source addresses
1793 * of packets, add the address to the address database using
1794 * a port bitmap that has only the bit for this port set and
1795 * the other bits clear.
1796 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001797 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001798 /* Disable learning for CPU port */
1799 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001800 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001801
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001802 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1803 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001804 if (err)
1805 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001806
1807 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001808 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1809 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001810 if (err)
1811 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001812
Vivien Didelot08984322017-06-08 18:34:12 -04001813 if (chip->info->ops->port_pause_limit) {
1814 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001815 if (err)
1816 return err;
1817 }
1818
Vivien Didelotc8c94892017-03-11 16:13:01 -05001819 if (chip->info->ops->port_disable_learn_limit) {
1820 err = chip->info->ops->port_disable_learn_limit(chip, port);
1821 if (err)
1822 return err;
1823 }
1824
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001825 if (chip->info->ops->port_disable_pri_override) {
1826 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001827 if (err)
1828 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001829 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001830
Andrew Lunnef0a7312016-12-03 04:35:16 +01001831 if (chip->info->ops->port_tag_remap) {
1832 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001833 if (err)
1834 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001835 }
1836
Andrew Lunnef70b112016-12-03 04:45:18 +01001837 if (chip->info->ops->port_egress_rate_limiting) {
1838 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001839 if (err)
1840 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001841 }
1842
Vivien Didelotea698f42017-03-11 16:12:50 -05001843 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001844 if (err)
1845 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001846
Vivien Didelot207afda2016-04-14 14:42:09 -04001847 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001848 * database, and allow bidirectional communication between the
1849 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001850 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001851 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001852 if (err)
1853 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001854
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001855 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001856 if (err)
1857 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001858
1859 /* Default VLAN ID and priority: don't set a default VLAN
1860 * ID, and set the default packet priority to zero.
1861 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04001862 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02001863}
1864
Andrew Lunn04aca992017-05-26 01:03:24 +02001865static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
1866 struct phy_device *phydev)
1867{
1868 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04001869 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02001870
1871 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001872 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02001873 mutex_unlock(&chip->reg_lock);
1874
1875 return err;
1876}
1877
1878static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
1879 struct phy_device *phydev)
1880{
1881 struct mv88e6xxx_chip *chip = ds->priv;
1882
1883 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001884 if (mv88e6xxx_serdes_power(chip, port, false))
1885 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02001886 mutex_unlock(&chip->reg_lock);
1887}
1888
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001889static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
1890 unsigned int ageing_time)
1891{
Vivien Didelot04bed142016-08-31 18:06:13 -04001892 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001893 int err;
1894
1895 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05001896 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001897 mutex_unlock(&chip->reg_lock);
1898
1899 return err;
1900}
1901
Vivien Didelot97299342016-07-18 20:45:30 -04001902static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04001903{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001904 struct dsa_switch *ds = chip->ds;
Vivien Didelotb0745e872016-05-09 13:22:53 -04001905 u32 upstream_port = dsa_upstream_port(ds);
Vivien Didelot08a01262016-05-09 13:22:50 -04001906 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04001907
Vivien Didelotfa8d1172017-06-08 18:34:11 -04001908 if (chip->info->ops->set_cpu_port) {
1909 err = chip->info->ops->set_cpu_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01001910 if (err)
1911 return err;
1912 }
1913
Vivien Didelotfa8d1172017-06-08 18:34:11 -04001914 if (chip->info->ops->set_egress_port) {
1915 err = chip->info->ops->set_egress_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01001916 if (err)
1917 return err;
1918 }
Vivien Didelotb0745e872016-05-09 13:22:53 -04001919
Vivien Didelot50484ff2016-05-09 13:22:54 -04001920 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04001921 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
1922 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04001923 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04001924 if (err)
1925 return err;
1926
Vivien Didelot08a01262016-05-09 13:22:50 -04001927 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04001928 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001929 if (err)
1930 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001931 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001932 if (err)
1933 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001934 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001935 if (err)
1936 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001937 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001938 if (err)
1939 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001940 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04001941 if (err)
1942 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001943 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04001944 if (err)
1945 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001946 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04001947 if (err)
1948 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001949 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04001950 if (err)
1951 return err;
1952
1953 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04001954 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04001955 if (err)
1956 return err;
1957
Andrew Lunnde2273872016-11-21 23:27:01 +01001958 /* Initialize the statistics unit */
1959 err = mv88e6xxx_stats_set_histogram(chip);
1960 if (err)
1961 return err;
1962
Vivien Didelot97299342016-07-18 20:45:30 -04001963 /* Clear the statistics counters for all ports */
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001964 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_STATS_OP,
1965 MV88E6XXX_G1_STATS_OP_BUSY |
1966 MV88E6XXX_G1_STATS_OP_FLUSH_ALL);
Vivien Didelot97299342016-07-18 20:45:30 -04001967 if (err)
1968 return err;
1969
1970 /* Wait for the flush to complete. */
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +01001971 err = mv88e6xxx_g1_stats_wait(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04001972 if (err)
1973 return err;
1974
1975 return 0;
1976}
1977
Vivien Didelotf81ec902016-05-09 13:22:58 -04001978static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07001979{
Vivien Didelot04bed142016-08-31 18:06:13 -04001980 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04001981 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04001982 int i;
1983
Vivien Didelotfad09c72016-06-21 12:28:20 -04001984 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01001985 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001986
Vivien Didelotfad09c72016-06-21 12:28:20 -04001987 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04001988
Vivien Didelot97299342016-07-18 20:45:30 -04001989 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001990 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot97299342016-07-18 20:45:30 -04001991 err = mv88e6xxx_setup_port(chip, i);
1992 if (err)
1993 goto unlock;
1994 }
1995
1996 /* Setup Switch Global 1 Registers */
1997 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04001998 if (err)
1999 goto unlock;
2000
Vivien Didelot97299342016-07-18 20:45:30 -04002001 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002002 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002003 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002004 if (err)
2005 goto unlock;
2006 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002007
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002008 err = mv88e6xxx_irl_setup(chip);
2009 if (err)
2010 goto unlock;
2011
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002012 err = mv88e6xxx_phy_setup(chip);
2013 if (err)
2014 goto unlock;
2015
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002016 err = mv88e6xxx_vtu_setup(chip);
2017 if (err)
2018 goto unlock;
2019
Vivien Didelot81228992017-03-30 17:37:08 -04002020 err = mv88e6xxx_pvt_setup(chip);
2021 if (err)
2022 goto unlock;
2023
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002024 err = mv88e6xxx_atu_setup(chip);
2025 if (err)
2026 goto unlock;
2027
Vivien Didelot9e907d72017-07-17 13:03:43 -04002028 err = mv88e6xxx_pot_setup(chip);
2029 if (err)
2030 goto unlock;
2031
Vivien Didelot51c901a2017-07-17 13:03:41 -04002032 err = mv88e6xxx_rsvd2cpu_setup(chip);
2033 if (err)
2034 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002035
Vivien Didelot6b17e862015-08-13 12:52:18 -04002036unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002037 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002038
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002039 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002040}
2041
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002042static int mv88e6xxx_set_addr(struct dsa_switch *ds, u8 *addr)
2043{
Vivien Didelot04bed142016-08-31 18:06:13 -04002044 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002045 int err;
2046
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002047 if (!chip->info->ops->set_switch_mac)
2048 return -EOPNOTSUPP;
2049
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002050 mutex_lock(&chip->reg_lock);
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002051 err = chip->info->ops->set_switch_mac(chip, addr);
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002052 mutex_unlock(&chip->reg_lock);
2053
2054 return err;
2055}
2056
Vivien Didelote57e5e72016-08-15 17:19:00 -04002057static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002058{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002059 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2060 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002061 u16 val;
2062 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002063
Andrew Lunnee26a222017-01-24 14:53:48 +01002064 if (!chip->info->ops->phy_read)
2065 return -EOPNOTSUPP;
2066
Vivien Didelotfad09c72016-06-21 12:28:20 -04002067 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002068 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002069 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002070
Andrew Lunnda9f3302017-02-01 03:40:05 +01002071 if (reg == MII_PHYSID2) {
2072 /* Some internal PHYS don't have a model number. Use
2073 * the mv88e6390 family model number instead.
2074 */
2075 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002076 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002077 }
2078
Vivien Didelote57e5e72016-08-15 17:19:00 -04002079 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002080}
2081
Vivien Didelote57e5e72016-08-15 17:19:00 -04002082static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002083{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002084 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2085 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002086 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002087
Andrew Lunnee26a222017-01-24 14:53:48 +01002088 if (!chip->info->ops->phy_write)
2089 return -EOPNOTSUPP;
2090
Vivien Didelotfad09c72016-06-21 12:28:20 -04002091 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002092 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002093 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002094
2095 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002096}
2097
Vivien Didelotfad09c72016-06-21 12:28:20 -04002098static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002099 struct device_node *np,
2100 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002101{
2102 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002103 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002104 struct mii_bus *bus;
2105 int err;
2106
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002107 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002108 if (!bus)
2109 return -ENOMEM;
2110
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002111 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002112 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002113 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002114 INIT_LIST_HEAD(&mdio_bus->list);
2115 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002116
Andrew Lunnb516d452016-06-04 21:17:06 +02002117 if (np) {
2118 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002119 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002120 } else {
2121 bus->name = "mv88e6xxx SMI";
2122 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2123 }
2124
2125 bus->read = mv88e6xxx_mdio_read;
2126 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002127 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002128
Andrew Lunna3c53be52017-01-24 14:53:50 +01002129 if (np)
2130 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002131 else
2132 err = mdiobus_register(bus);
2133 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002134 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002135 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002136 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002137
2138 if (external)
2139 list_add_tail(&mdio_bus->list, &chip->mdios);
2140 else
2141 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002142
2143 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002144}
2145
Andrew Lunna3c53be52017-01-24 14:53:50 +01002146static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2147 { .compatible = "marvell,mv88e6xxx-mdio-external",
2148 .data = (void *)true },
2149 { },
2150};
2151
2152static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2153 struct device_node *np)
2154{
2155 const struct of_device_id *match;
2156 struct device_node *child;
2157 int err;
2158
2159 /* Always register one mdio bus for the internal/default mdio
2160 * bus. This maybe represented in the device tree, but is
2161 * optional.
2162 */
2163 child = of_get_child_by_name(np, "mdio");
2164 err = mv88e6xxx_mdio_register(chip, child, false);
2165 if (err)
2166 return err;
2167
2168 /* Walk the device tree, and see if there are any other nodes
2169 * which say they are compatible with the external mdio
2170 * bus.
2171 */
2172 for_each_available_child_of_node(np, child) {
2173 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2174 if (match) {
2175 err = mv88e6xxx_mdio_register(chip, child, true);
2176 if (err)
2177 return err;
2178 }
2179 }
2180
2181 return 0;
2182}
2183
2184static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
Andrew Lunnb516d452016-06-04 21:17:06 +02002185
2186{
Andrew Lunna3c53be52017-01-24 14:53:50 +01002187 struct mv88e6xxx_mdio_bus *mdio_bus;
2188 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002189
Andrew Lunna3c53be52017-01-24 14:53:50 +01002190 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2191 bus = mdio_bus->bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002192
Andrew Lunna3c53be52017-01-24 14:53:50 +01002193 mdiobus_unregister(bus);
2194 }
Andrew Lunnb516d452016-06-04 21:17:06 +02002195}
2196
Vivien Didelot855b1932016-07-20 18:18:35 -04002197static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2198{
Vivien Didelot04bed142016-08-31 18:06:13 -04002199 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002200
2201 return chip->eeprom_len;
2202}
2203
Vivien Didelot855b1932016-07-20 18:18:35 -04002204static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2205 struct ethtool_eeprom *eeprom, u8 *data)
2206{
Vivien Didelot04bed142016-08-31 18:06:13 -04002207 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002208 int err;
2209
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002210 if (!chip->info->ops->get_eeprom)
2211 return -EOPNOTSUPP;
2212
Vivien Didelot855b1932016-07-20 18:18:35 -04002213 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002214 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002215 mutex_unlock(&chip->reg_lock);
2216
2217 if (err)
2218 return err;
2219
2220 eeprom->magic = 0xc3ec4951;
2221
2222 return 0;
2223}
2224
Vivien Didelot855b1932016-07-20 18:18:35 -04002225static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2226 struct ethtool_eeprom *eeprom, u8 *data)
2227{
Vivien Didelot04bed142016-08-31 18:06:13 -04002228 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002229 int err;
2230
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002231 if (!chip->info->ops->set_eeprom)
2232 return -EOPNOTSUPP;
2233
Vivien Didelot855b1932016-07-20 18:18:35 -04002234 if (eeprom->magic != 0xc3ec4951)
2235 return -EINVAL;
2236
2237 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002238 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002239 mutex_unlock(&chip->reg_lock);
2240
2241 return err;
2242}
2243
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002244static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002245 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002246 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002247 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002248 .phy_read = mv88e6185_phy_ppu_read,
2249 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002250 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002251 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002252 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002253 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002254 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002255 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002256 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002257 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002258 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002259 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002260 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002261 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002262 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2263 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002264 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002265 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2266 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002267 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002268 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002269 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002270 .ppu_enable = mv88e6185_g1_ppu_enable,
2271 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002272 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002273 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002274 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002275};
2276
2277static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002278 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002279 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002280 .phy_read = mv88e6185_phy_ppu_read,
2281 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002282 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002283 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002284 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002285 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002286 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002287 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002288 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002289 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2290 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002291 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002292 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002293 .ppu_enable = mv88e6185_g1_ppu_enable,
2294 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002295 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002296 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002297 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002298};
2299
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002300static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002301 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002302 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002303 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2304 .phy_read = mv88e6xxx_g2_smi_phy_read,
2305 .phy_write = mv88e6xxx_g2_smi_phy_write,
2306 .port_set_link = mv88e6xxx_port_set_link,
2307 .port_set_duplex = mv88e6xxx_port_set_duplex,
2308 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002309 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002310 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002311 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002312 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002313 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002314 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002315 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002316 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002317 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002318 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
2319 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2320 .stats_get_strings = mv88e6095_stats_get_strings,
2321 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002322 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2323 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002324 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002325 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002326 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002327 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002328 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002329 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002330};
2331
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002332static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002333 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002334 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002335 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002336 .phy_read = mv88e6xxx_g2_smi_phy_read,
2337 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002338 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002339 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002340 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002341 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002342 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002343 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002344 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002345 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002346 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2347 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002348 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002349 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2350 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002351 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002352 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002353 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002354 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002355 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002356 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002357};
2358
2359static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002360 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002361 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002362 .phy_read = mv88e6185_phy_ppu_read,
2363 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002364 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002365 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002366 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002367 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002368 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002369 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002370 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002371 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002372 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002373 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002374 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002375 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002376 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2377 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002378 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002379 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2380 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002381 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002382 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002383 .ppu_enable = mv88e6185_g1_ppu_enable,
2384 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002385 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002386 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002387 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002388};
2389
Vivien Didelot990e27b2017-03-28 13:50:32 -04002390static const struct mv88e6xxx_ops mv88e6141_ops = {
2391 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002392 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002393 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2394 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2395 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2396 .phy_read = mv88e6xxx_g2_smi_phy_read,
2397 .phy_write = mv88e6xxx_g2_smi_phy_write,
2398 .port_set_link = mv88e6xxx_port_set_link,
2399 .port_set_duplex = mv88e6xxx_port_set_duplex,
2400 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2401 .port_set_speed = mv88e6390_port_set_speed,
2402 .port_tag_remap = mv88e6095_port_tag_remap,
2403 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2404 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2405 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002406 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002407 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002408 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002409 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2410 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2411 .stats_snapshot = mv88e6390_g1_stats_snapshot,
2412 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2413 .stats_get_strings = mv88e6320_stats_get_strings,
2414 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002415 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2416 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002417 .watchdog_ops = &mv88e6390_watchdog_ops,
2418 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002419 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002420 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002421 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002422 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002423};
2424
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002425static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002426 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002427 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002428 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002429 .phy_read = mv88e6xxx_g2_smi_phy_read,
2430 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002431 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002432 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002433 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002434 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002435 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002436 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002437 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002438 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002439 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002440 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002441 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002442 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002443 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002444 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2445 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002446 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002447 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2448 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002449 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002450 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002451 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002452 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002453 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002454 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002455};
2456
2457static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002458 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002459 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002460 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002461 .phy_read = mv88e6165_phy_read,
2462 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002463 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002464 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002465 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002466 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002467 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002468 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002469 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2470 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002471 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002472 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2473 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002474 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002475 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002476 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002477 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002478 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002479 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002480};
2481
2482static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002483 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002484 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002485 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002486 .phy_read = mv88e6xxx_g2_smi_phy_read,
2487 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002488 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002489 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002490 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002491 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002492 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002493 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002494 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002495 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002496 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002497 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002498 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002499 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002500 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002501 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002502 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2503 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002504 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002505 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2506 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002507 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002508 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002509 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002510 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002511 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002512 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002513};
2514
2515static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002516 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002517 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002518 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2519 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002520 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002521 .phy_read = mv88e6xxx_g2_smi_phy_read,
2522 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002523 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002524 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002525 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002526 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002527 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002528 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002529 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002530 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002531 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002532 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002533 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002534 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002535 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002536 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002537 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2538 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002539 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002540 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2541 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002542 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002543 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002544 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002545 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002546 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002547 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002548 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002549};
2550
2551static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002552 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002553 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002554 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002555 .phy_read = mv88e6xxx_g2_smi_phy_read,
2556 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002557 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002558 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002559 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002560 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002561 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002562 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002563 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002564 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002565 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002566 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002567 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002568 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002569 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002570 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002571 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2572 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002573 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002574 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2575 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002576 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002577 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002578 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002579 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002580 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002581 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002582};
2583
2584static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002585 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002586 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002587 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2588 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002589 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002590 .phy_read = mv88e6xxx_g2_smi_phy_read,
2591 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002592 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002593 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002594 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002595 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002596 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002597 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002598 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002599 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002600 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002601 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002602 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002603 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002604 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002605 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002606 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2607 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002608 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002609 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2610 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002611 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002612 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002613 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002614 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002615 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002616 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002617 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002618};
2619
2620static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002621 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002622 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002623 .phy_read = mv88e6185_phy_ppu_read,
2624 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002625 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002626 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002627 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002628 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002629 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002630 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002631 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002632 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002633 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2634 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002635 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002636 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2637 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002638 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002639 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002640 .ppu_enable = mv88e6185_g1_ppu_enable,
2641 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002642 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002643 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002644 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002645};
2646
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002647static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002648 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002649 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002650 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2651 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002652 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2653 .phy_read = mv88e6xxx_g2_smi_phy_read,
2654 .phy_write = mv88e6xxx_g2_smi_phy_write,
2655 .port_set_link = mv88e6xxx_port_set_link,
2656 .port_set_duplex = mv88e6xxx_port_set_duplex,
2657 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2658 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002659 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002660 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002661 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002662 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002663 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002664 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002665 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002666 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002667 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002668 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2669 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002670 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002671 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2672 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002673 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002674 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002675 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002676 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002677 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2678 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002679 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002680};
2681
2682static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002683 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002684 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002685 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2686 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002687 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2688 .phy_read = mv88e6xxx_g2_smi_phy_read,
2689 .phy_write = mv88e6xxx_g2_smi_phy_write,
2690 .port_set_link = mv88e6xxx_port_set_link,
2691 .port_set_duplex = mv88e6xxx_port_set_duplex,
2692 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2693 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002694 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002695 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002696 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002697 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002698 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002699 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002700 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002701 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002702 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002703 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2704 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002705 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002706 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2707 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002708 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002709 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002710 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002711 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002712 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2713 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002714 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002715};
2716
2717static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002718 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002719 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002720 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2721 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002722 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2723 .phy_read = mv88e6xxx_g2_smi_phy_read,
2724 .phy_write = mv88e6xxx_g2_smi_phy_write,
2725 .port_set_link = mv88e6xxx_port_set_link,
2726 .port_set_duplex = mv88e6xxx_port_set_duplex,
2727 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2728 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002729 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002730 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002731 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002732 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002733 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002734 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002735 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002736 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002737 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002738 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2739 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002740 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002741 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2742 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002743 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002744 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002745 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002746 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002747 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2748 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002749 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002750};
2751
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002752static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002753 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002754 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002755 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2756 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002757 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002758 .phy_read = mv88e6xxx_g2_smi_phy_read,
2759 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002760 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002761 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002762 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002763 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002764 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002765 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002766 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002767 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002768 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002769 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002770 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002771 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002772 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002773 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002774 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2775 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002776 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002777 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2778 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002779 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002780 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002781 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002782 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002783 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002784 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002785 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002786};
2787
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002788static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002789 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002790 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002791 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2792 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002793 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2794 .phy_read = mv88e6xxx_g2_smi_phy_read,
2795 .phy_write = mv88e6xxx_g2_smi_phy_write,
2796 .port_set_link = mv88e6xxx_port_set_link,
2797 .port_set_duplex = mv88e6xxx_port_set_duplex,
2798 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2799 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002800 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002801 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002802 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002803 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002804 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002805 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002806 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002807 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002808 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002809 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002810 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2811 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002812 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002813 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2814 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002815 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002816 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002817 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002818 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002819 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2820 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002821 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002822};
2823
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002824static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002825 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002826 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002827 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2828 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002829 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002830 .phy_read = mv88e6xxx_g2_smi_phy_read,
2831 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002832 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002833 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002834 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002835 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002836 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002837 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002838 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002839 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002840 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002841 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002842 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002843 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002844 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002845 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2846 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002847 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002848 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2849 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002850 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002851 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002852 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002853 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002854 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002855};
2856
2857static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04002858 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002859 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002860 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2861 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002862 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002863 .phy_read = mv88e6xxx_g2_smi_phy_read,
2864 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002865 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002866 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002867 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002868 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002869 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002870 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002871 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002872 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002873 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002874 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002875 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002876 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002877 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002878 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2879 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002880 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002881 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2882 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002883 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002884 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002885 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002886};
2887
Vivien Didelot16e329a2017-03-28 13:50:33 -04002888static const struct mv88e6xxx_ops mv88e6341_ops = {
2889 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002890 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002891 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2892 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2893 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2894 .phy_read = mv88e6xxx_g2_smi_phy_read,
2895 .phy_write = mv88e6xxx_g2_smi_phy_write,
2896 .port_set_link = mv88e6xxx_port_set_link,
2897 .port_set_duplex = mv88e6xxx_port_set_duplex,
2898 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2899 .port_set_speed = mv88e6390_port_set_speed,
2900 .port_tag_remap = mv88e6095_port_tag_remap,
2901 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2902 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2903 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002904 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002905 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002906 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002907 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2908 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2909 .stats_snapshot = mv88e6390_g1_stats_snapshot,
2910 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2911 .stats_get_strings = mv88e6320_stats_get_strings,
2912 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002913 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2914 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002915 .watchdog_ops = &mv88e6390_watchdog_ops,
2916 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002917 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002918 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002919 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002920 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002921};
2922
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002923static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002924 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002925 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002926 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002927 .phy_read = mv88e6xxx_g2_smi_phy_read,
2928 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002929 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002930 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002931 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002932 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002933 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002934 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002935 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002936 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002937 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002938 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002939 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002940 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002941 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002942 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002943 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2944 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002945 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002946 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2947 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002948 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002949 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002950 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002951 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002952 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002953 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002954};
2955
2956static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002957 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002958 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002959 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002960 .phy_read = mv88e6xxx_g2_smi_phy_read,
2961 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002962 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002963 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002964 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002965 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002966 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002967 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002968 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002969 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002970 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002971 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002972 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002973 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002974 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002975 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002976 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2977 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002978 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002979 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2980 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002981 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002982 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002983 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002984 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002985 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002986 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002987};
2988
2989static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002990 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002991 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002992 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2993 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002994 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002995 .phy_read = mv88e6xxx_g2_smi_phy_read,
2996 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002997 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002998 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002999 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003000 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003001 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003002 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003003 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003004 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003005 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003006 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003007 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003008 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003009 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003010 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01003011 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3012 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003013 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003014 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3015 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003016 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003017 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003018 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003019 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003020 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003021 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003022 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003023};
3024
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003025static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003026 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003027 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003028 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3029 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003030 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3031 .phy_read = mv88e6xxx_g2_smi_phy_read,
3032 .phy_write = mv88e6xxx_g2_smi_phy_write,
3033 .port_set_link = mv88e6xxx_port_set_link,
3034 .port_set_duplex = mv88e6xxx_port_set_duplex,
3035 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3036 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003037 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003038 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003039 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003040 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003041 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003042 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003043 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003044 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003045 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003046 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003047 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003048 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003049 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3050 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003051 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003052 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3053 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003054 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003055 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003056 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003057 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003058 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3059 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003060 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003061};
3062
3063static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003064 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003065 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003066 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3067 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003068 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3069 .phy_read = mv88e6xxx_g2_smi_phy_read,
3070 .phy_write = mv88e6xxx_g2_smi_phy_write,
3071 .port_set_link = mv88e6xxx_port_set_link,
3072 .port_set_duplex = mv88e6xxx_port_set_duplex,
3073 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3074 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003075 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003076 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003077 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003078 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003079 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003080 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003081 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003082 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003083 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003084 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003085 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003086 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003087 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3088 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003089 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003090 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3091 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003092 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003093 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003094 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003095 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003096 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3097 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003098 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003099};
3100
Vivien Didelotf81ec902016-05-09 13:22:58 -04003101static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3102 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003103 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003104 .family = MV88E6XXX_FAMILY_6097,
3105 .name = "Marvell 88E6085",
3106 .num_databases = 4096,
3107 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003108 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003109 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003110 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003111 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003112 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003113 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003114 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003115 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003116 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003117 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003118 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003119 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003120 },
3121
3122 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003123 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003124 .family = MV88E6XXX_FAMILY_6095,
3125 .name = "Marvell 88E6095/88E6095F",
3126 .num_databases = 256,
3127 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003128 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003129 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003130 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003131 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003132 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003133 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003134 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003135 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003136 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003137 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003138 },
3139
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003140 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003141 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003142 .family = MV88E6XXX_FAMILY_6097,
3143 .name = "Marvell 88E6097/88E6097F",
3144 .num_databases = 4096,
3145 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003146 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003147 .port_base_addr = 0x10,
3148 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003149 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003150 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003151 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003152 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003153 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003154 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003155 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003156 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003157 .ops = &mv88e6097_ops,
3158 },
3159
Vivien Didelotf81ec902016-05-09 13:22:58 -04003160 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003161 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003162 .family = MV88E6XXX_FAMILY_6165,
3163 .name = "Marvell 88E6123",
3164 .num_databases = 4096,
3165 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003166 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003167 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003168 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003169 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003170 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003171 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003172 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003173 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003174 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003175 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003176 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003177 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003178 },
3179
3180 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003181 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003182 .family = MV88E6XXX_FAMILY_6185,
3183 .name = "Marvell 88E6131",
3184 .num_databases = 256,
3185 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003186 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003187 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003188 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003189 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003190 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003191 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003192 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003193 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003194 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003195 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003196 },
3197
Vivien Didelot990e27b2017-03-28 13:50:32 -04003198 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003199 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003200 .family = MV88E6XXX_FAMILY_6341,
3201 .name = "Marvell 88E6341",
3202 .num_databases = 4096,
3203 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003204 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003205 .port_base_addr = 0x10,
3206 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003207 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003208 .age_time_coeff = 3750,
3209 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003210 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003211 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003212 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003213 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003214 .ops = &mv88e6141_ops,
3215 },
3216
Vivien Didelotf81ec902016-05-09 13:22:58 -04003217 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003218 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003219 .family = MV88E6XXX_FAMILY_6165,
3220 .name = "Marvell 88E6161",
3221 .num_databases = 4096,
3222 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003223 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003224 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003225 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003226 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003227 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003228 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003229 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003230 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003231 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003232 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003233 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003234 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003235 },
3236
3237 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003238 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003239 .family = MV88E6XXX_FAMILY_6165,
3240 .name = "Marvell 88E6165",
3241 .num_databases = 4096,
3242 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003243 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003244 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003245 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003246 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003247 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003248 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003249 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003250 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003251 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003252 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003253 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003254 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003255 },
3256
3257 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003258 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003259 .family = MV88E6XXX_FAMILY_6351,
3260 .name = "Marvell 88E6171",
3261 .num_databases = 4096,
3262 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003263 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003264 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003265 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003266 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003267 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003268 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003269 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003270 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003271 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003272 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003273 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003274 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003275 },
3276
3277 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003278 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003279 .family = MV88E6XXX_FAMILY_6352,
3280 .name = "Marvell 88E6172",
3281 .num_databases = 4096,
3282 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003283 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003284 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003285 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003286 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003287 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003288 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003289 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003290 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003291 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003292 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003293 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003294 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003295 },
3296
3297 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003298 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003299 .family = MV88E6XXX_FAMILY_6351,
3300 .name = "Marvell 88E6175",
3301 .num_databases = 4096,
3302 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003303 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003304 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003305 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003306 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003307 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003308 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003309 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003310 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003311 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003312 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003313 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003314 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003315 },
3316
3317 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003318 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003319 .family = MV88E6XXX_FAMILY_6352,
3320 .name = "Marvell 88E6176",
3321 .num_databases = 4096,
3322 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003323 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003324 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003325 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003326 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003327 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003328 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003329 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003330 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003331 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003332 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003333 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003334 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003335 },
3336
3337 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003338 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003339 .family = MV88E6XXX_FAMILY_6185,
3340 .name = "Marvell 88E6185",
3341 .num_databases = 256,
3342 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003343 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003344 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003345 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003346 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003347 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003348 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003349 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003350 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003351 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003352 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003353 },
3354
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003355 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003356 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003357 .family = MV88E6XXX_FAMILY_6390,
3358 .name = "Marvell 88E6190",
3359 .num_databases = 4096,
3360 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003361 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003362 .port_base_addr = 0x0,
3363 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003364 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003365 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003366 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003367 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003368 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003369 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003370 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003371 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003372 .ops = &mv88e6190_ops,
3373 },
3374
3375 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003376 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003377 .family = MV88E6XXX_FAMILY_6390,
3378 .name = "Marvell 88E6190X",
3379 .num_databases = 4096,
3380 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003381 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003382 .port_base_addr = 0x0,
3383 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003384 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003385 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003386 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003387 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003388 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003389 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003390 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003391 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003392 .ops = &mv88e6190x_ops,
3393 },
3394
3395 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003396 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003397 .family = MV88E6XXX_FAMILY_6390,
3398 .name = "Marvell 88E6191",
3399 .num_databases = 4096,
3400 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003401 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003402 .port_base_addr = 0x0,
3403 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003404 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003405 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003406 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003407 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003408 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003409 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003410 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003411 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003412 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003413 },
3414
Vivien Didelotf81ec902016-05-09 13:22:58 -04003415 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003416 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003417 .family = MV88E6XXX_FAMILY_6352,
3418 .name = "Marvell 88E6240",
3419 .num_databases = 4096,
3420 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003421 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003422 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003423 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003424 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003425 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003426 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003427 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003428 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003429 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003430 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003431 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003432 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003433 },
3434
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003435 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003436 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003437 .family = MV88E6XXX_FAMILY_6390,
3438 .name = "Marvell 88E6290",
3439 .num_databases = 4096,
3440 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003441 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003442 .port_base_addr = 0x0,
3443 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003444 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003445 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003446 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003447 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003448 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003449 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003450 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003451 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003452 .ops = &mv88e6290_ops,
3453 },
3454
Vivien Didelotf81ec902016-05-09 13:22:58 -04003455 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003456 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003457 .family = MV88E6XXX_FAMILY_6320,
3458 .name = "Marvell 88E6320",
3459 .num_databases = 4096,
3460 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003461 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003462 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003463 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003464 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003465 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003466 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003467 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003468 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003469 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003470 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003471 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003472 },
3473
3474 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003475 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003476 .family = MV88E6XXX_FAMILY_6320,
3477 .name = "Marvell 88E6321",
3478 .num_databases = 4096,
3479 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003480 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003481 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003482 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003483 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003484 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003485 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003486 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003487 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003488 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003489 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003490 },
3491
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003492 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003493 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003494 .family = MV88E6XXX_FAMILY_6341,
3495 .name = "Marvell 88E6341",
3496 .num_databases = 4096,
3497 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003498 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003499 .port_base_addr = 0x10,
3500 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003501 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003502 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003503 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003504 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003505 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003506 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003507 .tag_protocol = DSA_TAG_PROTO_EDSA,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003508 .ops = &mv88e6341_ops,
3509 },
3510
Vivien Didelotf81ec902016-05-09 13:22:58 -04003511 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003512 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003513 .family = MV88E6XXX_FAMILY_6351,
3514 .name = "Marvell 88E6350",
3515 .num_databases = 4096,
3516 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003517 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003518 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003519 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003520 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003521 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003522 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003523 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003524 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003525 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003526 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003527 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003528 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003529 },
3530
3531 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003532 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003533 .family = MV88E6XXX_FAMILY_6351,
3534 .name = "Marvell 88E6351",
3535 .num_databases = 4096,
3536 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003537 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003538 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003539 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003540 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003541 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003542 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003543 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003544 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003545 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003546 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003547 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003548 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003549 },
3550
3551 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003552 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003553 .family = MV88E6XXX_FAMILY_6352,
3554 .name = "Marvell 88E6352",
3555 .num_databases = 4096,
3556 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003557 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003558 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003559 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003560 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003561 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003562 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003563 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003564 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003565 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003566 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003567 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003568 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003569 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003570 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003571 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003572 .family = MV88E6XXX_FAMILY_6390,
3573 .name = "Marvell 88E6390",
3574 .num_databases = 4096,
3575 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003576 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003577 .port_base_addr = 0x0,
3578 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003579 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003580 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003581 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003582 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003583 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003584 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003585 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003586 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003587 .ops = &mv88e6390_ops,
3588 },
3589 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003590 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003591 .family = MV88E6XXX_FAMILY_6390,
3592 .name = "Marvell 88E6390X",
3593 .num_databases = 4096,
3594 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003595 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003596 .port_base_addr = 0x0,
3597 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003598 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003599 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003600 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003601 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003602 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003603 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003604 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003605 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003606 .ops = &mv88e6390x_ops,
3607 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003608};
3609
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003610static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003611{
Vivien Didelota439c062016-04-17 13:23:58 -04003612 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003613
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003614 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3615 if (mv88e6xxx_table[i].prod_num == prod_num)
3616 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003617
Vivien Didelotb9b37712015-10-30 19:39:48 -04003618 return NULL;
3619}
3620
Vivien Didelotfad09c72016-06-21 12:28:20 -04003621static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003622{
3623 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003624 unsigned int prod_num, rev;
3625 u16 id;
3626 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003627
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003628 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003629 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003630 mutex_unlock(&chip->reg_lock);
3631 if (err)
3632 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003633
Vivien Didelot107fcc12017-06-12 12:37:36 -04003634 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3635 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003636
3637 info = mv88e6xxx_lookup_info(prod_num);
3638 if (!info)
3639 return -ENODEV;
3640
Vivien Didelotcaac8542016-06-20 13:14:09 -04003641 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003642 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003643
Vivien Didelotca070c12016-09-02 14:45:34 -04003644 err = mv88e6xxx_g2_require(chip);
3645 if (err)
3646 return err;
3647
Vivien Didelotfad09c72016-06-21 12:28:20 -04003648 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3649 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003650
3651 return 0;
3652}
3653
Vivien Didelotfad09c72016-06-21 12:28:20 -04003654static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003655{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003656 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003657
Vivien Didelotfad09c72016-06-21 12:28:20 -04003658 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3659 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003660 return NULL;
3661
Vivien Didelotfad09c72016-06-21 12:28:20 -04003662 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003663
Vivien Didelotfad09c72016-06-21 12:28:20 -04003664 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003665 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003666
Vivien Didelotfad09c72016-06-21 12:28:20 -04003667 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003668}
3669
Vivien Didelotfad09c72016-06-21 12:28:20 -04003670static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003671 struct mii_bus *bus, int sw_addr)
3672{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003673 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003674 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003675 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003676 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003677 else
3678 return -EINVAL;
3679
Vivien Didelotfad09c72016-06-21 12:28:20 -04003680 chip->bus = bus;
3681 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003682
3683 return 0;
3684}
3685
Andrew Lunn7b314362016-08-22 16:01:01 +02003686static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds)
3687{
Vivien Didelot04bed142016-08-31 18:06:13 -04003688 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003689
Andrew Lunn443d5a12016-12-03 04:35:18 +01003690 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003691}
3692
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003693static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3694 struct device *host_dev, int sw_addr,
3695 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003696{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003697 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003698 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003699 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003700
Vivien Didelota439c062016-04-17 13:23:58 -04003701 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003702 if (!bus)
3703 return NULL;
3704
Vivien Didelotfad09c72016-06-21 12:28:20 -04003705 chip = mv88e6xxx_alloc_chip(dsa_dev);
3706 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003707 return NULL;
3708
Vivien Didelotcaac8542016-06-20 13:14:09 -04003709 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003710 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003711
Vivien Didelotfad09c72016-06-21 12:28:20 -04003712 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003713 if (err)
3714 goto free;
3715
Vivien Didelotfad09c72016-06-21 12:28:20 -04003716 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003717 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003718 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003719
Andrew Lunndc30c352016-10-16 19:56:49 +02003720 mutex_lock(&chip->reg_lock);
3721 err = mv88e6xxx_switch_reset(chip);
3722 mutex_unlock(&chip->reg_lock);
3723 if (err)
3724 goto free;
3725
Vivien Didelote57e5e72016-08-15 17:19:00 -04003726 mv88e6xxx_phy_init(chip);
3727
Andrew Lunna3c53be52017-01-24 14:53:50 +01003728 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003729 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003730 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003731
Vivien Didelotfad09c72016-06-21 12:28:20 -04003732 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003733
Vivien Didelotfad09c72016-06-21 12:28:20 -04003734 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003735free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003736 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003737
3738 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003739}
3740
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003741static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
3742 const struct switchdev_obj_port_mdb *mdb,
3743 struct switchdev_trans *trans)
3744{
3745 /* We don't need any dynamic resource from the kernel (yet),
3746 * so skip the prepare phase.
3747 */
3748
3749 return 0;
3750}
3751
3752static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
3753 const struct switchdev_obj_port_mdb *mdb,
3754 struct switchdev_trans *trans)
3755{
Vivien Didelot04bed142016-08-31 18:06:13 -04003756 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003757
3758 mutex_lock(&chip->reg_lock);
3759 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003760 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003761 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3762 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003763 mutex_unlock(&chip->reg_lock);
3764}
3765
3766static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3767 const struct switchdev_obj_port_mdb *mdb)
3768{
Vivien Didelot04bed142016-08-31 18:06:13 -04003769 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003770 int err;
3771
3772 mutex_lock(&chip->reg_lock);
3773 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003774 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003775 mutex_unlock(&chip->reg_lock);
3776
3777 return err;
3778}
3779
Florian Fainellia82f67a2017-01-08 14:52:08 -08003780static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003781 .probe = mv88e6xxx_drv_probe,
Andrew Lunn7b314362016-08-22 16:01:01 +02003782 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003783 .setup = mv88e6xxx_setup,
3784 .set_addr = mv88e6xxx_set_addr,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003785 .adjust_link = mv88e6xxx_adjust_link,
3786 .get_strings = mv88e6xxx_get_strings,
3787 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3788 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003789 .port_enable = mv88e6xxx_port_enable,
3790 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04003791 .get_mac_eee = mv88e6xxx_get_mac_eee,
3792 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003793 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003794 .get_eeprom = mv88e6xxx_get_eeprom,
3795 .set_eeprom = mv88e6xxx_set_eeprom,
3796 .get_regs_len = mv88e6xxx_get_regs_len,
3797 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003798 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003799 .port_bridge_join = mv88e6xxx_port_bridge_join,
3800 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3801 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04003802 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003803 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3804 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3805 .port_vlan_add = mv88e6xxx_port_vlan_add,
3806 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003807 .port_fdb_add = mv88e6xxx_port_fdb_add,
3808 .port_fdb_del = mv88e6xxx_port_fdb_del,
3809 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003810 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
3811 .port_mdb_add = mv88e6xxx_port_mdb_add,
3812 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04003813 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
3814 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003815};
3816
Florian Fainelliab3d4082017-01-08 14:52:07 -08003817static struct dsa_switch_driver mv88e6xxx_switch_drv = {
3818 .ops = &mv88e6xxx_switch_ops,
3819};
3820
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003821static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003822{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003823 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003824 struct dsa_switch *ds;
3825
Vivien Didelot73b12042017-03-30 17:37:10 -04003826 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003827 if (!ds)
3828 return -ENOMEM;
3829
Vivien Didelotfad09c72016-06-21 12:28:20 -04003830 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04003831 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04003832 ds->ageing_time_min = chip->info->age_time_coeff;
3833 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003834
3835 dev_set_drvdata(dev, ds);
3836
Vivien Didelot23c9ee42017-05-26 18:12:51 -04003837 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003838}
3839
Vivien Didelotfad09c72016-06-21 12:28:20 -04003840static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003841{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003842 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003843}
3844
Vivien Didelot57d32312016-06-20 13:13:58 -04003845static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003846{
3847 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003848 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003849 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003850 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003851 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02003852 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003853
Vivien Didelotcaac8542016-06-20 13:14:09 -04003854 compat_info = of_device_get_match_data(dev);
3855 if (!compat_info)
3856 return -EINVAL;
3857
Vivien Didelotfad09c72016-06-21 12:28:20 -04003858 chip = mv88e6xxx_alloc_chip(dev);
3859 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003860 return -ENOMEM;
3861
Vivien Didelotfad09c72016-06-21 12:28:20 -04003862 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003863
Vivien Didelotfad09c72016-06-21 12:28:20 -04003864 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003865 if (err)
3866 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003867
Andrew Lunnb4308f02016-11-21 23:26:55 +01003868 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
3869 if (IS_ERR(chip->reset))
3870 return PTR_ERR(chip->reset);
3871
Vivien Didelotfad09c72016-06-21 12:28:20 -04003872 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003873 if (err)
3874 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003875
Vivien Didelote57e5e72016-08-15 17:19:00 -04003876 mv88e6xxx_phy_init(chip);
3877
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003878 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003879 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04003880 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003881
Andrew Lunndc30c352016-10-16 19:56:49 +02003882 mutex_lock(&chip->reg_lock);
3883 err = mv88e6xxx_switch_reset(chip);
3884 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02003885 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02003886 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02003887
Andrew Lunndc30c352016-10-16 19:56:49 +02003888 chip->irq = of_irq_get(np, 0);
3889 if (chip->irq == -EPROBE_DEFER) {
3890 err = chip->irq;
3891 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02003892 }
3893
Andrew Lunndc30c352016-10-16 19:56:49 +02003894 if (chip->irq > 0) {
3895 /* Has to be performed before the MDIO bus is created,
3896 * because the PHYs will link there interrupts to these
3897 * interrupt controllers
3898 */
3899 mutex_lock(&chip->reg_lock);
3900 err = mv88e6xxx_g1_irq_setup(chip);
3901 mutex_unlock(&chip->reg_lock);
3902
3903 if (err)
3904 goto out;
3905
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003906 if (chip->info->g2_irqs > 0) {
Andrew Lunndc30c352016-10-16 19:56:49 +02003907 err = mv88e6xxx_g2_irq_setup(chip);
3908 if (err)
3909 goto out_g1_irq;
3910 }
3911 }
3912
Andrew Lunna3c53be52017-01-24 14:53:50 +01003913 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02003914 if (err)
3915 goto out_g2_irq;
3916
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003917 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02003918 if (err)
3919 goto out_mdio;
3920
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003921 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02003922
3923out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01003924 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02003925out_g2_irq:
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003926 if (chip->info->g2_irqs > 0 && chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02003927 mv88e6xxx_g2_irq_free(chip);
3928out_g1_irq:
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01003929 if (chip->irq > 0) {
3930 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01003931 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01003932 mutex_unlock(&chip->reg_lock);
3933 }
Andrew Lunndc30c352016-10-16 19:56:49 +02003934out:
3935 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003936}
3937
3938static void mv88e6xxx_remove(struct mdio_device *mdiodev)
3939{
3940 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04003941 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003942
Andrew Lunn930188c2016-08-22 16:01:03 +02003943 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04003944 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003945 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02003946
Andrew Lunn467126442016-11-20 20:14:15 +01003947 if (chip->irq > 0) {
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003948 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01003949 mv88e6xxx_g2_irq_free(chip);
3950 mv88e6xxx_g1_irq_free(chip);
3951 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003952}
3953
3954static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04003955 {
3956 .compatible = "marvell,mv88e6085",
3957 .data = &mv88e6xxx_table[MV88E6085],
3958 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003959 {
3960 .compatible = "marvell,mv88e6190",
3961 .data = &mv88e6xxx_table[MV88E6190],
3962 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003963 { /* sentinel */ },
3964};
3965
3966MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
3967
3968static struct mdio_driver mv88e6xxx_driver = {
3969 .probe = mv88e6xxx_probe,
3970 .remove = mv88e6xxx_remove,
3971 .mdiodrv.driver = {
3972 .name = "mv88e6085",
3973 .of_match_table = mv88e6xxx_of_match,
3974 },
3975};
3976
Ben Hutchings98e67302011-11-25 14:36:19 +00003977static int __init mv88e6xxx_init(void)
3978{
Florian Fainelliab3d4082017-01-08 14:52:07 -08003979 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003980 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00003981}
3982module_init(mv88e6xxx_init);
3983
3984static void __exit mv88e6xxx_cleanup(void)
3985{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003986 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08003987 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00003988}
3989module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00003990
3991MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
3992MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
3993MODULE_LICENSE("GPL");