blob: 874e2a154834b0eea5fdc6713df59f1e05d9d0ba [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 Lunnc8c1b39a2015-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
310static struct irq_chip mv88e6xxx_g1_irq_chip = {
311 .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 Didelotf81ec902016-05-09 13:22:58 -0400813static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port,
814 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800815{
Vivien Didelot04bed142016-08-31 18:06:13 -0400816 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot9c938292016-08-15 17:19:02 -0400817 u16 reg;
818 int err;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800819
Vivien Didelotfad09c72016-06-21 12:28:20 -0400820 if (!mv88e6xxx_has(chip, MV88E6XXX_FLAG_EEE))
Vivien Didelotaadbdb82016-05-09 13:22:44 -0400821 return -EOPNOTSUPP;
822
Vivien Didelotfad09c72016-06-21 12:28:20 -0400823 mutex_lock(&chip->reg_lock);
Andrew Lunn2f40c692015-04-02 04:06:37 +0200824
Vivien Didelot9c938292016-08-15 17:19:02 -0400825 err = mv88e6xxx_phy_read(chip, port, 16, &reg);
826 if (err)
Andrew Lunn2f40c692015-04-02 04:06:37 +0200827 goto out;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800828
829 e->eee_enabled = !!(reg & 0x0200);
830 e->tx_lpi_enabled = !!(reg & 0x0100);
831
Vivien Didelot5f83dc92017-06-12 12:37:33 -0400832 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
Vivien Didelot9c938292016-08-15 17:19:02 -0400833 if (err)
Andrew Lunn2f40c692015-04-02 04:06:37 +0200834 goto out;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800835
Vivien Didelot5f83dc92017-06-12 12:37:33 -0400836 e->eee_active = !!(reg & MV88E6352_PORT_STS_EEE);
Andrew Lunn2f40c692015-04-02 04:06:37 +0200837out:
Vivien Didelotfad09c72016-06-21 12:28:20 -0400838 mutex_unlock(&chip->reg_lock);
Vivien Didelot9c938292016-08-15 17:19:02 -0400839
840 return err;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800841}
842
Vivien Didelotf81ec902016-05-09 13:22:58 -0400843static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
844 struct phy_device *phydev, struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800845{
Vivien Didelot04bed142016-08-31 18:06:13 -0400846 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot9c938292016-08-15 17:19:02 -0400847 u16 reg;
848 int err;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800849
Vivien Didelotfad09c72016-06-21 12:28:20 -0400850 if (!mv88e6xxx_has(chip, MV88E6XXX_FLAG_EEE))
Vivien Didelotaadbdb82016-05-09 13:22:44 -0400851 return -EOPNOTSUPP;
852
Vivien Didelotfad09c72016-06-21 12:28:20 -0400853 mutex_lock(&chip->reg_lock);
Guenter Roeck11b3b452015-03-06 22:23:51 -0800854
Vivien Didelot9c938292016-08-15 17:19:02 -0400855 err = mv88e6xxx_phy_read(chip, port, 16, &reg);
856 if (err)
Andrew Lunn2f40c692015-04-02 04:06:37 +0200857 goto out;
858
Vivien Didelot9c938292016-08-15 17:19:02 -0400859 reg &= ~0x0300;
Andrew Lunn2f40c692015-04-02 04:06:37 +0200860 if (e->eee_enabled)
861 reg |= 0x0200;
862 if (e->tx_lpi_enabled)
863 reg |= 0x0100;
864
Vivien Didelot9c938292016-08-15 17:19:02 -0400865 err = mv88e6xxx_phy_write(chip, port, 16, reg);
Andrew Lunn2f40c692015-04-02 04:06:37 +0200866out:
Vivien Didelotfad09c72016-06-21 12:28:20 -0400867 mutex_unlock(&chip->reg_lock);
Andrew Lunn2f40c692015-04-02 04:06:37 +0200868
Vivien Didelot9c938292016-08-15 17:19:02 -0400869 return err;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800870}
871
Vivien Didelote5887a22017-03-30 17:37:11 -0400872static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700873{
Vivien Didelote5887a22017-03-30 17:37:11 -0400874 struct dsa_switch *ds = NULL;
875 struct net_device *br;
876 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500877 int i;
878
Vivien Didelote5887a22017-03-30 17:37:11 -0400879 if (dev < DSA_MAX_SWITCHES)
880 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500881
Vivien Didelote5887a22017-03-30 17:37:11 -0400882 /* Prevent frames from unknown switch or port */
883 if (!ds || port >= ds->num_ports)
884 return 0;
885
886 /* Frames from DSA links and CPU ports can egress any local port */
887 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
888 return mv88e6xxx_port_mask(chip);
889
890 br = ds->ports[port].bridge_dev;
891 pvlan = 0;
892
893 /* Frames from user ports can egress any local DSA links and CPU ports,
894 * as well as any local member of their bridge group.
895 */
896 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
897 if (dsa_is_cpu_port(chip->ds, i) ||
898 dsa_is_dsa_port(chip->ds, i) ||
899 (br && chip->ds->ports[i].bridge_dev == br))
900 pvlan |= BIT(i);
901
902 return pvlan;
903}
904
Vivien Didelot240ea3e2017-03-30 17:37:12 -0400905static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -0400906{
907 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500908
909 /* prevent frames from going back out of the port they came in on */
910 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700911
Vivien Didelot5a7921f2016-11-04 03:23:28 +0100912 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700913}
914
Vivien Didelotf81ec902016-05-09 13:22:58 -0400915static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
916 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700917{
Vivien Didelot04bed142016-08-31 18:06:13 -0400918 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -0400919 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700920
Vivien Didelotfad09c72016-06-21 12:28:20 -0400921 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -0400922 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400923 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -0400924
925 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400926 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700927}
928
Vivien Didelot51c901a2017-07-17 13:03:41 -0400929static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
930{
931 if (chip->info->ops->mgmt_rsvd2cpu)
932 return chip->info->ops->mgmt_rsvd2cpu(chip);
933
934 return 0;
935}
936
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500937static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
938{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500939 int err;
940
Vivien Didelotdaefc942017-03-11 16:12:54 -0500941 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
942 if (err)
943 return err;
944
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500945 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
946 if (err)
947 return err;
948
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500949 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
950}
951
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400952static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
953{
954 int port;
955 int err;
956
957 if (!chip->info->ops->irl_init_all)
958 return 0;
959
960 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
961 /* Disable ingress rate limiting by resetting all per port
962 * ingress rate limit resources to their initial state.
963 */
964 err = chip->info->ops->irl_init_all(chip, port);
965 if (err)
966 return err;
967 }
968
969 return 0;
970}
971
Vivien Didelot17a15942017-03-30 17:37:09 -0400972static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
973{
974 u16 pvlan = 0;
975
976 if (!mv88e6xxx_has_pvt(chip))
977 return -EOPNOTSUPP;
978
979 /* Skip the local source device, which uses in-chip port VLAN */
980 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -0400981 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -0400982
983 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
984}
985
Vivien Didelot81228992017-03-30 17:37:08 -0400986static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
987{
Vivien Didelot17a15942017-03-30 17:37:09 -0400988 int dev, port;
989 int err;
990
Vivien Didelot81228992017-03-30 17:37:08 -0400991 if (!mv88e6xxx_has_pvt(chip))
992 return 0;
993
994 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
995 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
996 */
Vivien Didelot17a15942017-03-30 17:37:09 -0400997 err = mv88e6xxx_g2_misc_4_bit_port(chip);
998 if (err)
999 return err;
1000
1001 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1002 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1003 err = mv88e6xxx_pvt_map(chip, dev, port);
1004 if (err)
1005 return err;
1006 }
1007 }
1008
1009 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001010}
1011
Vivien Didelot749efcb2016-09-22 16:49:24 -04001012static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1013{
1014 struct mv88e6xxx_chip *chip = ds->priv;
1015 int err;
1016
1017 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001018 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001019 mutex_unlock(&chip->reg_lock);
1020
1021 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001022 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001023}
1024
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001025static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1026{
1027 if (!chip->info->max_vid)
1028 return 0;
1029
1030 return mv88e6xxx_g1_vtu_flush(chip);
1031}
1032
Vivien Didelotf1394b782017-05-01 14:05:22 -04001033static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1034 struct mv88e6xxx_vtu_entry *entry)
1035{
1036 if (!chip->info->ops->vtu_getnext)
1037 return -EOPNOTSUPP;
1038
1039 return chip->info->ops->vtu_getnext(chip, entry);
1040}
1041
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001042static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1043 struct mv88e6xxx_vtu_entry *entry)
1044{
1045 if (!chip->info->ops->vtu_loadpurge)
1046 return -EOPNOTSUPP;
1047
1048 return chip->info->ops->vtu_loadpurge(chip, entry);
1049}
1050
Vivien Didelotf81ec902016-05-09 13:22:58 -04001051static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
1052 struct switchdev_obj_port_vlan *vlan,
Vivien Didelot438ff532017-05-17 15:46:05 -04001053 switchdev_obj_dump_cb_t *cb)
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001054{
Vivien Didelot04bed142016-08-31 18:06:13 -04001055 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001056 struct mv88e6xxx_vtu_entry next = {
1057 .vid = chip->info->max_vid,
1058 };
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001059 u16 pvid;
1060 int err;
1061
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001062 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001063 return -EOPNOTSUPP;
1064
Vivien Didelotfad09c72016-06-21 12:28:20 -04001065 mutex_lock(&chip->reg_lock);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001066
Vivien Didelot77064f32016-11-04 03:23:30 +01001067 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001068 if (err)
1069 goto unlock;
1070
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001071 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001072 err = mv88e6xxx_vtu_getnext(chip, &next);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001073 if (err)
1074 break;
1075
1076 if (!next.valid)
1077 break;
1078
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001079 if (next.member[port] ==
1080 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001081 continue;
1082
1083 /* reinit and dump this VLAN obj */
Vivien Didelot57d32312016-06-20 13:13:58 -04001084 vlan->vid_begin = next.vid;
1085 vlan->vid_end = next.vid;
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001086 vlan->flags = 0;
1087
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001088 if (next.member[port] ==
1089 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED)
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001090 vlan->flags |= BRIDGE_VLAN_INFO_UNTAGGED;
1091
1092 if (next.vid == pvid)
1093 vlan->flags |= BRIDGE_VLAN_INFO_PVID;
1094
1095 err = cb(&vlan->obj);
1096 if (err)
1097 break;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001098 } while (next.vid < chip->info->max_vid);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001099
1100unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001101 mutex_unlock(&chip->reg_lock);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001102
1103 return err;
1104}
1105
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001106static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001107{
1108 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001109 struct mv88e6xxx_vtu_entry vlan = {
1110 .vid = chip->info->max_vid,
1111 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001112 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001113
1114 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1115
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001116 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001117 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001118 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001119 if (err)
1120 return err;
1121
1122 set_bit(*fid, fid_bitmap);
1123 }
1124
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001125 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001126 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001127 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001128 if (err)
1129 return err;
1130
1131 if (!vlan.valid)
1132 break;
1133
1134 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001135 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001136
1137 /* The reset value 0x000 is used to indicate that multiple address
1138 * databases are not needed. Return the next positive available.
1139 */
1140 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001141 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001142 return -ENOSPC;
1143
1144 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001145 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001146}
1147
Vivien Didelot567aa592017-05-01 14:05:25 -04001148static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1149 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001150{
1151 int err;
1152
1153 if (!vid)
1154 return -EINVAL;
1155
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001156 entry->vid = vid - 1;
1157 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001158
Vivien Didelotf1394b782017-05-01 14:05:22 -04001159 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001160 if (err)
1161 return err;
1162
Vivien Didelot567aa592017-05-01 14:05:25 -04001163 if (entry->vid == vid && entry->valid)
1164 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001165
Vivien Didelot567aa592017-05-01 14:05:25 -04001166 if (new) {
1167 int i;
1168
1169 /* Initialize a fresh VLAN entry */
1170 memset(entry, 0, sizeof(*entry));
1171 entry->valid = true;
1172 entry->vid = vid;
1173
Vivien Didelot553a7682017-06-07 18:12:16 -04001174 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001175 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001176 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001177 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001178
1179 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001180 }
1181
Vivien Didelot567aa592017-05-01 14:05:25 -04001182 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1183 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001184}
1185
Vivien Didelotda9c3592016-02-12 12:09:40 -05001186static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1187 u16 vid_begin, u16 vid_end)
1188{
Vivien Didelot04bed142016-08-31 18:06:13 -04001189 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001190 struct mv88e6xxx_vtu_entry vlan = {
1191 .vid = vid_begin - 1,
1192 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001193 int i, err;
1194
1195 if (!vid_begin)
1196 return -EOPNOTSUPP;
1197
Vivien Didelotfad09c72016-06-21 12:28:20 -04001198 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001199
Vivien Didelotda9c3592016-02-12 12:09:40 -05001200 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001201 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001202 if (err)
1203 goto unlock;
1204
1205 if (!vlan.valid)
1206 break;
1207
1208 if (vlan.vid > vid_end)
1209 break;
1210
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001211 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001212 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1213 continue;
1214
Andrew Lunn66e28092016-12-11 21:07:19 +01001215 if (!ds->ports[port].netdev)
1216 continue;
1217
Vivien Didelotbd00e052017-05-01 14:05:11 -04001218 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001219 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001220 continue;
1221
Vivien Didelotfae8a252017-01-27 15:29:42 -05001222 if (ds->ports[i].bridge_dev ==
1223 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001224 break; /* same bridge, check next VLAN */
1225
Vivien Didelotfae8a252017-01-27 15:29:42 -05001226 if (!ds->ports[i].bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001227 continue;
1228
Vivien Didelot774439e52017-06-08 18:34:08 -04001229 dev_err(ds->dev, "p%d: hw VLAN %d already used by %s\n",
1230 port, vlan.vid,
1231 netdev_name(ds->ports[i].bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001232 err = -EOPNOTSUPP;
1233 goto unlock;
1234 }
1235 } while (vlan.vid < vid_end);
1236
1237unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001238 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001239
1240 return err;
1241}
1242
Vivien Didelotf81ec902016-05-09 13:22:58 -04001243static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1244 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001245{
Vivien Didelot04bed142016-08-31 18:06:13 -04001246 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001247 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1248 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001249 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001250
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001251 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001252 return -EOPNOTSUPP;
1253
Vivien Didelotfad09c72016-06-21 12:28:20 -04001254 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001255 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001256 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001257
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001258 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001259}
1260
Vivien Didelot57d32312016-06-20 13:13:58 -04001261static int
1262mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
1263 const struct switchdev_obj_port_vlan *vlan,
1264 struct switchdev_trans *trans)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001265{
Vivien Didelot04bed142016-08-31 18:06:13 -04001266 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001267 int err;
1268
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001269 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001270 return -EOPNOTSUPP;
1271
Vivien Didelotda9c3592016-02-12 12:09:40 -05001272 /* If the requested port doesn't belong to the same bridge as the VLAN
1273 * members, do not support it (yet) and fallback to software VLAN.
1274 */
1275 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1276 vlan->vid_end);
1277 if (err)
1278 return err;
1279
Vivien Didelot76e398a2015-11-01 12:33:55 -05001280 /* We don't need any dynamic resource from the kernel (yet),
1281 * so skip the prepare phase.
1282 */
1283 return 0;
1284}
1285
Vivien Didelotfad09c72016-06-21 12:28:20 -04001286static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001287 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001288{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001289 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001290 int err;
1291
Vivien Didelot567aa592017-05-01 14:05:25 -04001292 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001293 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001294 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001295
Vivien Didelotc91498e2017-06-07 18:12:13 -04001296 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001297
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001298 return mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001299}
1300
Vivien Didelotf81ec902016-05-09 13:22:58 -04001301static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
1302 const struct switchdev_obj_port_vlan *vlan,
1303 struct switchdev_trans *trans)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001304{
Vivien Didelot04bed142016-08-31 18:06:13 -04001305 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001306 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1307 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001308 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001309 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001310
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001311 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001312 return;
1313
Vivien Didelotc91498e2017-06-07 18:12:13 -04001314 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001315 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001316 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001317 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001318 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001319 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001320
Vivien Didelotfad09c72016-06-21 12:28:20 -04001321 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001322
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001323 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001324 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001325 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1326 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001327
Vivien Didelot77064f32016-11-04 03:23:30 +01001328 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001329 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1330 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001331
Vivien Didelotfad09c72016-06-21 12:28:20 -04001332 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001333}
1334
Vivien Didelotfad09c72016-06-21 12:28:20 -04001335static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001336 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001337{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001338 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001339 int i, err;
1340
Vivien Didelot567aa592017-05-01 14:05:25 -04001341 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001342 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001343 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001344
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001345 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001346 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001347 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001348
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001349 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001350
1351 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001352 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001353 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001354 if (vlan.member[i] !=
1355 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001356 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001357 break;
1358 }
1359 }
1360
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001361 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001362 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001363 return err;
1364
Vivien Didelote606ca32017-03-11 16:12:55 -05001365 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001366}
1367
Vivien Didelotf81ec902016-05-09 13:22:58 -04001368static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1369 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001370{
Vivien Didelot04bed142016-08-31 18:06:13 -04001371 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001372 u16 pvid, vid;
1373 int err = 0;
1374
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001375 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001376 return -EOPNOTSUPP;
1377
Vivien Didelotfad09c72016-06-21 12:28:20 -04001378 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001379
Vivien Didelot77064f32016-11-04 03:23:30 +01001380 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001381 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001382 goto unlock;
1383
Vivien Didelot76e398a2015-11-01 12:33:55 -05001384 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001385 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001386 if (err)
1387 goto unlock;
1388
1389 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001390 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001391 if (err)
1392 goto unlock;
1393 }
1394 }
1395
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001396unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001397 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001398
1399 return err;
1400}
1401
Vivien Didelot83dabd12016-08-31 11:50:04 -04001402static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1403 const unsigned char *addr, u16 vid,
1404 u8 state)
Vivien Didelotfd231c82015-08-10 09:09:50 -04001405{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001406 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot88472932016-09-19 19:56:11 -04001407 struct mv88e6xxx_atu_entry entry;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001408 int err;
Vivien Didelotfd231c82015-08-10 09:09:50 -04001409
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001410 /* Null VLAN ID corresponds to the port private database */
1411 if (vid == 0)
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001412 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001413 else
Vivien Didelot567aa592017-05-01 14:05:25 -04001414 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001415 if (err)
1416 return err;
1417
Vivien Didelot27c0e602017-06-15 12:14:01 -04001418 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001419 ether_addr_copy(entry.mac, addr);
1420 eth_addr_dec(entry.mac);
1421
1422 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
Vivien Didelot88472932016-09-19 19:56:11 -04001423 if (err)
1424 return err;
1425
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001426 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelot27c0e602017-06-15 12:14:01 -04001427 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001428 !ether_addr_equal(entry.mac, addr)) {
1429 memset(&entry, 0, sizeof(entry));
1430 ether_addr_copy(entry.mac, addr);
1431 }
1432
Vivien Didelot88472932016-09-19 19:56:11 -04001433 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelot27c0e602017-06-15 12:14:01 -04001434 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001435 entry.portvec &= ~BIT(port);
1436 if (!entry.portvec)
Vivien Didelot27c0e602017-06-15 12:14:01 -04001437 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelot88472932016-09-19 19:56:11 -04001438 } else {
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001439 entry.portvec |= BIT(port);
Vivien Didelot88472932016-09-19 19:56:11 -04001440 entry.state = state;
Vivien Didelotfd231c82015-08-10 09:09:50 -04001441 }
1442
Vivien Didelot9c13c022017-03-11 16:12:52 -05001443 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001444}
1445
Vivien Didelotf81ec902016-05-09 13:22:58 -04001446static int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
1447 const struct switchdev_obj_port_fdb *fdb,
1448 struct switchdev_trans *trans)
Vivien Didelot146a3202015-10-08 11:35:12 -04001449{
1450 /* We don't need any dynamic resource from the kernel (yet),
1451 * so skip the prepare phase.
1452 */
1453 return 0;
1454}
1455
Vivien Didelotf81ec902016-05-09 13:22:58 -04001456static void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1457 const struct switchdev_obj_port_fdb *fdb,
1458 struct switchdev_trans *trans)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001459{
Vivien Didelot04bed142016-08-31 18:06:13 -04001460 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot6630e232015-08-06 01:44:07 -04001461
Vivien Didelotfad09c72016-06-21 12:28:20 -04001462 mutex_lock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001463 if (mv88e6xxx_port_db_load_purge(chip, port, fdb->addr, fdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001464 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04001465 dev_err(ds->dev, "p%d: failed to load unicast MAC address\n",
1466 port);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001467 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001468}
1469
Vivien Didelotf81ec902016-05-09 13:22:58 -04001470static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
1471 const struct switchdev_obj_port_fdb *fdb)
David S. Millercdf09692015-08-11 12:00:37 -07001472{
Vivien Didelot04bed142016-08-31 18:06:13 -04001473 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001474 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001475
Vivien Didelotfad09c72016-06-21 12:28:20 -04001476 mutex_lock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001477 err = mv88e6xxx_port_db_load_purge(chip, port, fdb->addr, fdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001478 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001479 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001480
Vivien Didelot83dabd12016-08-31 11:50:04 -04001481 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001482}
1483
Vivien Didelot83dabd12016-08-31 11:50:04 -04001484static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1485 u16 fid, u16 vid, int port,
1486 struct switchdev_obj *obj,
Vivien Didelot438ff532017-05-17 15:46:05 -04001487 switchdev_obj_dump_cb_t *cb)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001488{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001489 struct mv88e6xxx_atu_entry addr;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001490 int err;
1491
Vivien Didelot27c0e602017-06-15 12:14:01 -04001492 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001493 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001494
1495 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001496 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001497 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001498 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001499
Vivien Didelot27c0e602017-06-15 12:14:01 -04001500 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001501 break;
1502
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001503 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001504 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001505
Vivien Didelot83dabd12016-08-31 11:50:04 -04001506 if (obj->id == SWITCHDEV_OBJ_ID_PORT_FDB) {
1507 struct switchdev_obj_port_fdb *fdb;
1508
1509 if (!is_unicast_ether_addr(addr.mac))
1510 continue;
1511
1512 fdb = SWITCHDEV_OBJ_PORT_FDB(obj);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001513 fdb->vid = vid;
1514 ether_addr_copy(fdb->addr, addr.mac);
Vivien Didelot27c0e602017-06-15 12:14:01 -04001515 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001516 fdb->ndm_state = NUD_NOARP;
1517 else
1518 fdb->ndm_state = NUD_REACHABLE;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04001519 } else if (obj->id == SWITCHDEV_OBJ_ID_PORT_MDB) {
1520 struct switchdev_obj_port_mdb *mdb;
1521
1522 if (!is_multicast_ether_addr(addr.mac))
1523 continue;
1524
1525 mdb = SWITCHDEV_OBJ_PORT_MDB(obj);
1526 mdb->vid = vid;
1527 ether_addr_copy(mdb->addr, addr.mac);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001528 } else {
1529 return -EOPNOTSUPP;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001530 }
Vivien Didelot83dabd12016-08-31 11:50:04 -04001531
1532 err = cb(obj);
1533 if (err)
1534 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001535 } while (!is_broadcast_ether_addr(addr.mac));
1536
1537 return err;
1538}
1539
Vivien Didelot83dabd12016-08-31 11:50:04 -04001540static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
1541 struct switchdev_obj *obj,
Vivien Didelot438ff532017-05-17 15:46:05 -04001542 switchdev_obj_dump_cb_t *cb)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001543{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001544 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001545 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001546 };
1547 u16 fid;
1548 int err;
1549
1550 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001551 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001552 if (err)
1553 return err;
1554
1555 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, obj, cb);
1556 if (err)
1557 return err;
1558
1559 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001560 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001561 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001562 if (err)
1563 return err;
1564
1565 if (!vlan.valid)
1566 break;
1567
1568 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
1569 obj, cb);
1570 if (err)
1571 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001572 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001573
1574 return err;
1575}
1576
Vivien Didelotf81ec902016-05-09 13:22:58 -04001577static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
1578 struct switchdev_obj_port_fdb *fdb,
Vivien Didelot438ff532017-05-17 15:46:05 -04001579 switchdev_obj_dump_cb_t *cb)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001580{
Vivien Didelot04bed142016-08-31 18:06:13 -04001581 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001582 int err;
1583
Vivien Didelotfad09c72016-06-21 12:28:20 -04001584 mutex_lock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001585 err = mv88e6xxx_port_db_dump(chip, port, &fdb->obj, cb);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001586 mutex_unlock(&chip->reg_lock);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001587
1588 return err;
1589}
1590
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001591static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1592 struct net_device *br)
1593{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001594 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001595 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001596 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001597 int err;
1598
1599 /* Remap the Port VLAN of each local bridge group member */
1600 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1601 if (chip->ds->ports[port].bridge_dev == br) {
1602 err = mv88e6xxx_port_vlan_map(chip, port);
1603 if (err)
1604 return err;
1605 }
1606 }
1607
Vivien Didelote96a6e02017-03-30 17:37:13 -04001608 if (!mv88e6xxx_has_pvt(chip))
1609 return 0;
1610
1611 /* Remap the Port VLAN of each cross-chip bridge group member */
1612 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1613 ds = chip->ds->dst->ds[dev];
1614 if (!ds)
1615 break;
1616
1617 for (port = 0; port < ds->num_ports; ++port) {
1618 if (ds->ports[port].bridge_dev == br) {
1619 err = mv88e6xxx_pvt_map(chip, dev, port);
1620 if (err)
1621 return err;
1622 }
1623 }
1624 }
1625
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001626 return 0;
1627}
1628
Vivien Didelotf81ec902016-05-09 13:22:58 -04001629static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001630 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001631{
Vivien Didelot04bed142016-08-31 18:06:13 -04001632 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001633 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001634
Vivien Didelotfad09c72016-06-21 12:28:20 -04001635 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001636 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001637 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001638
Vivien Didelot466dfa02016-02-26 13:16:05 -05001639 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001640}
1641
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001642static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1643 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001644{
Vivien Didelot04bed142016-08-31 18:06:13 -04001645 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001646
Vivien Didelotfad09c72016-06-21 12:28:20 -04001647 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001648 if (mv88e6xxx_bridge_map(chip, br) ||
1649 mv88e6xxx_port_vlan_map(chip, port))
1650 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001651 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001652}
1653
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001654static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1655 int port, struct net_device *br)
1656{
1657 struct mv88e6xxx_chip *chip = ds->priv;
1658 int err;
1659
1660 if (!mv88e6xxx_has_pvt(chip))
1661 return 0;
1662
1663 mutex_lock(&chip->reg_lock);
1664 err = mv88e6xxx_pvt_map(chip, dev, port);
1665 mutex_unlock(&chip->reg_lock);
1666
1667 return err;
1668}
1669
1670static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1671 int port, struct net_device *br)
1672{
1673 struct mv88e6xxx_chip *chip = ds->priv;
1674
1675 if (!mv88e6xxx_has_pvt(chip))
1676 return;
1677
1678 mutex_lock(&chip->reg_lock);
1679 if (mv88e6xxx_pvt_map(chip, dev, port))
1680 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1681 mutex_unlock(&chip->reg_lock);
1682}
1683
Vivien Didelot17e708b2016-12-05 17:30:27 -05001684static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1685{
1686 if (chip->info->ops->reset)
1687 return chip->info->ops->reset(chip);
1688
1689 return 0;
1690}
1691
Vivien Didelot309eca62016-12-05 17:30:26 -05001692static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1693{
1694 struct gpio_desc *gpiod = chip->reset;
1695
1696 /* If there is a GPIO connected to the reset pin, toggle it */
1697 if (gpiod) {
1698 gpiod_set_value_cansleep(gpiod, 1);
1699 usleep_range(10000, 20000);
1700 gpiod_set_value_cansleep(gpiod, 0);
1701 usleep_range(10000, 20000);
1702 }
1703}
1704
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001705static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1706{
1707 int i, err;
1708
1709 /* Set all ports to the Disabled state */
1710 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001711 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001712 if (err)
1713 return err;
1714 }
1715
1716 /* Wait for transmit queues to drain,
1717 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1718 */
1719 usleep_range(2000, 4000);
1720
1721 return 0;
1722}
1723
Vivien Didelotfad09c72016-06-21 12:28:20 -04001724static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001725{
Vivien Didelota935c052016-09-29 12:21:53 -04001726 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001727
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001728 err = mv88e6xxx_disable_ports(chip);
1729 if (err)
1730 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001731
Vivien Didelot309eca62016-12-05 17:30:26 -05001732 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001733
Vivien Didelot17e708b2016-12-05 17:30:27 -05001734 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001735}
1736
Vivien Didelot43145572017-03-11 16:12:59 -05001737static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001738 enum mv88e6xxx_frame_mode frame,
1739 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001740{
1741 int err;
1742
Vivien Didelot43145572017-03-11 16:12:59 -05001743 if (!chip->info->ops->port_set_frame_mode)
1744 return -EOPNOTSUPP;
1745
1746 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001747 if (err)
1748 return err;
1749
Vivien Didelot43145572017-03-11 16:12:59 -05001750 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1751 if (err)
1752 return err;
1753
1754 if (chip->info->ops->port_set_ether_type)
1755 return chip->info->ops->port_set_ether_type(chip, port, etype);
1756
1757 return 0;
1758}
1759
1760static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1761{
1762 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001763 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001764 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001765}
1766
1767static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1768{
1769 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001770 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001771 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001772}
1773
1774static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1775{
1776 return mv88e6xxx_set_port_mode(chip, port,
1777 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001778 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1779 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001780}
1781
1782static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1783{
1784 if (dsa_is_dsa_port(chip->ds, port))
1785 return mv88e6xxx_set_port_mode_dsa(chip, port);
1786
1787 if (dsa_is_normal_port(chip->ds, port))
1788 return mv88e6xxx_set_port_mode_normal(chip, port);
1789
1790 /* Setup CPU port mode depending on its supported tag format */
1791 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1792 return mv88e6xxx_set_port_mode_dsa(chip, port);
1793
1794 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1795 return mv88e6xxx_set_port_mode_edsa(chip, port);
1796
1797 return -EINVAL;
1798}
1799
Vivien Didelotea698f42017-03-11 16:12:50 -05001800static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1801{
1802 bool message = dsa_is_dsa_port(chip->ds, port);
1803
1804 return mv88e6xxx_port_set_message_port(chip, port, message);
1805}
1806
Vivien Didelot601aeed2017-03-11 16:13:00 -05001807static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1808{
1809 bool flood = port == dsa_upstream_port(chip->ds);
1810
1811 /* Upstream ports flood frames with unknown unicast or multicast DA */
1812 if (chip->info->ops->port_set_egress_floods)
1813 return chip->info->ops->port_set_egress_floods(chip, port,
1814 flood, flood);
1815
1816 return 0;
1817}
1818
Andrew Lunn6d917822017-05-26 01:03:21 +02001819static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1820 bool on)
1821{
Vivien Didelot523a8902017-05-26 18:02:42 -04001822 if (chip->info->ops->serdes_power)
1823 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001824
Vivien Didelot523a8902017-05-26 18:02:42 -04001825 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001826}
1827
Vivien Didelotfad09c72016-06-21 12:28:20 -04001828static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001829{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001830 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001831 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001832 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001833
Vivien Didelotd78343d2016-11-04 03:23:36 +01001834 /* MAC Forcing register: don't force link, speed, duplex or flow control
1835 * state to any particular values on physical ports, but force the CPU
1836 * port and all DSA ports to their maximum bandwidth and full duplex.
1837 */
1838 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1839 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1840 SPEED_MAX, DUPLEX_FULL,
1841 PHY_INTERFACE_MODE_NA);
1842 else
1843 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1844 SPEED_UNFORCED, DUPLEX_UNFORCED,
1845 PHY_INTERFACE_MODE_NA);
1846 if (err)
1847 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001848
1849 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1850 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1851 * tunneling, determine priority by looking at 802.1p and IP
1852 * priority fields (IP prio has precedence), and set STP state
1853 * to Forwarding.
1854 *
1855 * If this is the CPU link, use DSA or EDSA tagging depending
1856 * on which tagging mode was configured.
1857 *
1858 * If this is a link to another switch, use DSA tagging mode.
1859 *
1860 * If this is the upstream port for this switch, enable
1861 * forwarding of unknown unicasts and multicasts.
1862 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001863 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1864 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1865 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1866 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001867 if (err)
1868 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001869
Vivien Didelot601aeed2017-03-11 16:13:00 -05001870 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001871 if (err)
1872 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001873
Vivien Didelot601aeed2017-03-11 16:13:00 -05001874 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001875 if (err)
1876 return err;
1877
Andrew Lunn04aca992017-05-26 01:03:24 +02001878 /* Enable the SERDES interface for DSA and CPU ports. Normal
1879 * ports SERDES are enabled when the port is enabled, thus
1880 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001881 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001882 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1883 err = mv88e6xxx_serdes_power(chip, port, true);
1884 if (err)
1885 return err;
1886 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001887
Vivien Didelot8efdda42015-08-13 12:52:23 -04001888 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001889 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001890 * untagged frames on this port, do a destination address lookup on all
1891 * received packets as usual, disable ARP mirroring and don't send a
1892 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001893 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001894 err = mv88e6xxx_port_set_map_da(chip, port);
1895 if (err)
1896 return err;
1897
Andrew Lunn54d792f2015-05-06 01:09:47 +02001898 reg = 0;
Andrew Lunna23b2962017-02-04 20:15:28 +01001899 if (chip->info->ops->port_set_upstream_port) {
1900 err = chip->info->ops->port_set_upstream_port(
1901 chip, port, dsa_upstream_port(ds));
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001902 if (err)
1903 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001904 }
1905
Andrew Lunna23b2962017-02-04 20:15:28 +01001906 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001907 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001908 if (err)
1909 return err;
1910
Vivien Didelotcd782652017-06-08 18:34:13 -04001911 if (chip->info->ops->port_set_jumbo_size) {
1912 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001913 if (err)
1914 return err;
1915 }
1916
Andrew Lunn54d792f2015-05-06 01:09:47 +02001917 /* Port Association Vector: when learning source addresses
1918 * of packets, add the address to the address database using
1919 * a port bitmap that has only the bit for this port set and
1920 * the other bits clear.
1921 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001922 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001923 /* Disable learning for CPU port */
1924 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001925 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001926
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001927 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1928 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001929 if (err)
1930 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001931
1932 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001933 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1934 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001935 if (err)
1936 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001937
Vivien Didelot08984322017-06-08 18:34:12 -04001938 if (chip->info->ops->port_pause_limit) {
1939 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001940 if (err)
1941 return err;
1942 }
1943
Vivien Didelotc8c94892017-03-11 16:13:01 -05001944 if (chip->info->ops->port_disable_learn_limit) {
1945 err = chip->info->ops->port_disable_learn_limit(chip, port);
1946 if (err)
1947 return err;
1948 }
1949
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001950 if (chip->info->ops->port_disable_pri_override) {
1951 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001952 if (err)
1953 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001954 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001955
Andrew Lunnef0a7312016-12-03 04:35:16 +01001956 if (chip->info->ops->port_tag_remap) {
1957 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001958 if (err)
1959 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001960 }
1961
Andrew Lunnef70b112016-12-03 04:45:18 +01001962 if (chip->info->ops->port_egress_rate_limiting) {
1963 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001964 if (err)
1965 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001966 }
1967
Vivien Didelotea698f42017-03-11 16:12:50 -05001968 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001969 if (err)
1970 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001971
Vivien Didelot207afda2016-04-14 14:42:09 -04001972 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001973 * database, and allow bidirectional communication between the
1974 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001975 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001976 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001977 if (err)
1978 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001979
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001980 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001981 if (err)
1982 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001983
1984 /* Default VLAN ID and priority: don't set a default VLAN
1985 * ID, and set the default packet priority to zero.
1986 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04001987 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02001988}
1989
Andrew Lunn04aca992017-05-26 01:03:24 +02001990static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
1991 struct phy_device *phydev)
1992{
1993 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04001994 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02001995
1996 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001997 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02001998 mutex_unlock(&chip->reg_lock);
1999
2000 return err;
2001}
2002
2003static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2004 struct phy_device *phydev)
2005{
2006 struct mv88e6xxx_chip *chip = ds->priv;
2007
2008 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002009 if (mv88e6xxx_serdes_power(chip, port, false))
2010 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02002011 mutex_unlock(&chip->reg_lock);
2012}
2013
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002014static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2015 unsigned int ageing_time)
2016{
Vivien Didelot04bed142016-08-31 18:06:13 -04002017 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002018 int err;
2019
2020 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002021 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002022 mutex_unlock(&chip->reg_lock);
2023
2024 return err;
2025}
2026
Vivien Didelot97299342016-07-18 20:45:30 -04002027static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002028{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002029 struct dsa_switch *ds = chip->ds;
Vivien Didelotb0745e872016-05-09 13:22:53 -04002030 u32 upstream_port = dsa_upstream_port(ds);
Vivien Didelot08a01262016-05-09 13:22:50 -04002031 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002032
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002033 if (chip->info->ops->set_cpu_port) {
2034 err = chip->info->ops->set_cpu_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01002035 if (err)
2036 return err;
2037 }
2038
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002039 if (chip->info->ops->set_egress_port) {
2040 err = chip->info->ops->set_egress_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01002041 if (err)
2042 return err;
2043 }
Vivien Didelotb0745e872016-05-09 13:22:53 -04002044
Vivien Didelot50484ff2016-05-09 13:22:54 -04002045 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04002046 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
2047 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04002048 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04002049 if (err)
2050 return err;
2051
Vivien Didelot08a01262016-05-09 13:22:50 -04002052 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002053 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002054 if (err)
2055 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002056 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002057 if (err)
2058 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002059 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002060 if (err)
2061 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002062 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002063 if (err)
2064 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002065 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002066 if (err)
2067 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002068 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002069 if (err)
2070 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002071 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002072 if (err)
2073 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002074 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002075 if (err)
2076 return err;
2077
2078 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002079 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002080 if (err)
2081 return err;
2082
Andrew Lunnde2273872016-11-21 23:27:01 +01002083 /* Initialize the statistics unit */
2084 err = mv88e6xxx_stats_set_histogram(chip);
2085 if (err)
2086 return err;
2087
Vivien Didelot97299342016-07-18 20:45:30 -04002088 /* Clear the statistics counters for all ports */
Vivien Didelot57d1ef32017-06-15 12:14:05 -04002089 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_STATS_OP,
2090 MV88E6XXX_G1_STATS_OP_BUSY |
2091 MV88E6XXX_G1_STATS_OP_FLUSH_ALL);
Vivien Didelot97299342016-07-18 20:45:30 -04002092 if (err)
2093 return err;
2094
2095 /* Wait for the flush to complete. */
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +01002096 err = mv88e6xxx_g1_stats_wait(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002097 if (err)
2098 return err;
2099
2100 return 0;
2101}
2102
Vivien Didelotf81ec902016-05-09 13:22:58 -04002103static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002104{
Vivien Didelot04bed142016-08-31 18:06:13 -04002105 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002106 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002107 int i;
2108
Vivien Didelotfad09c72016-06-21 12:28:20 -04002109 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002110 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002111
Vivien Didelotfad09c72016-06-21 12:28:20 -04002112 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002113
Vivien Didelot97299342016-07-18 20:45:30 -04002114 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002115 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot97299342016-07-18 20:45:30 -04002116 err = mv88e6xxx_setup_port(chip, i);
2117 if (err)
2118 goto unlock;
2119 }
2120
2121 /* Setup Switch Global 1 Registers */
2122 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002123 if (err)
2124 goto unlock;
2125
Vivien Didelot97299342016-07-18 20:45:30 -04002126 /* Setup Switch Global 2 Registers */
2127 if (mv88e6xxx_has(chip, MV88E6XXX_FLAG_GLOBAL2)) {
2128 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002129 if (err)
2130 goto unlock;
2131 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002132
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002133 err = mv88e6xxx_irl_setup(chip);
2134 if (err)
2135 goto unlock;
2136
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002137 err = mv88e6xxx_phy_setup(chip);
2138 if (err)
2139 goto unlock;
2140
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002141 err = mv88e6xxx_vtu_setup(chip);
2142 if (err)
2143 goto unlock;
2144
Vivien Didelot81228992017-03-30 17:37:08 -04002145 err = mv88e6xxx_pvt_setup(chip);
2146 if (err)
2147 goto unlock;
2148
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002149 err = mv88e6xxx_atu_setup(chip);
2150 if (err)
2151 goto unlock;
2152
Vivien Didelot51c901a2017-07-17 13:03:41 -04002153 err = mv88e6xxx_rsvd2cpu_setup(chip);
2154 if (err)
2155 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002156
Vivien Didelot6b17e862015-08-13 12:52:18 -04002157unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002158 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002159
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002160 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002161}
2162
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002163static int mv88e6xxx_set_addr(struct dsa_switch *ds, u8 *addr)
2164{
Vivien Didelot04bed142016-08-31 18:06:13 -04002165 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002166 int err;
2167
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002168 if (!chip->info->ops->set_switch_mac)
2169 return -EOPNOTSUPP;
2170
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002171 mutex_lock(&chip->reg_lock);
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002172 err = chip->info->ops->set_switch_mac(chip, addr);
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002173 mutex_unlock(&chip->reg_lock);
2174
2175 return err;
2176}
2177
Vivien Didelote57e5e72016-08-15 17:19:00 -04002178static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002179{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002180 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2181 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002182 u16 val;
2183 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002184
Andrew Lunnee26a222017-01-24 14:53:48 +01002185 if (!chip->info->ops->phy_read)
2186 return -EOPNOTSUPP;
2187
Vivien Didelotfad09c72016-06-21 12:28:20 -04002188 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002189 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002190 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002191
Andrew Lunnda9f3302017-02-01 03:40:05 +01002192 if (reg == MII_PHYSID2) {
2193 /* Some internal PHYS don't have a model number. Use
2194 * the mv88e6390 family model number instead.
2195 */
2196 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002197 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002198 }
2199
Vivien Didelote57e5e72016-08-15 17:19:00 -04002200 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002201}
2202
Vivien Didelote57e5e72016-08-15 17:19:00 -04002203static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002204{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002205 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2206 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002207 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002208
Andrew Lunnee26a222017-01-24 14:53:48 +01002209 if (!chip->info->ops->phy_write)
2210 return -EOPNOTSUPP;
2211
Vivien Didelotfad09c72016-06-21 12:28:20 -04002212 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002213 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002214 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002215
2216 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002217}
2218
Vivien Didelotfad09c72016-06-21 12:28:20 -04002219static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002220 struct device_node *np,
2221 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002222{
2223 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002224 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002225 struct mii_bus *bus;
2226 int err;
2227
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002228 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002229 if (!bus)
2230 return -ENOMEM;
2231
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002232 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002233 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002234 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002235 INIT_LIST_HEAD(&mdio_bus->list);
2236 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002237
Andrew Lunnb516d452016-06-04 21:17:06 +02002238 if (np) {
2239 bus->name = np->full_name;
2240 snprintf(bus->id, MII_BUS_ID_SIZE, "%s", np->full_name);
2241 } else {
2242 bus->name = "mv88e6xxx SMI";
2243 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2244 }
2245
2246 bus->read = mv88e6xxx_mdio_read;
2247 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002248 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002249
Andrew Lunna3c53be52017-01-24 14:53:50 +01002250 if (np)
2251 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002252 else
2253 err = mdiobus_register(bus);
2254 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002255 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002256 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002257 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002258
2259 if (external)
2260 list_add_tail(&mdio_bus->list, &chip->mdios);
2261 else
2262 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002263
2264 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002265}
2266
Andrew Lunna3c53be52017-01-24 14:53:50 +01002267static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2268 { .compatible = "marvell,mv88e6xxx-mdio-external",
2269 .data = (void *)true },
2270 { },
2271};
2272
2273static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2274 struct device_node *np)
2275{
2276 const struct of_device_id *match;
2277 struct device_node *child;
2278 int err;
2279
2280 /* Always register one mdio bus for the internal/default mdio
2281 * bus. This maybe represented in the device tree, but is
2282 * optional.
2283 */
2284 child = of_get_child_by_name(np, "mdio");
2285 err = mv88e6xxx_mdio_register(chip, child, false);
2286 if (err)
2287 return err;
2288
2289 /* Walk the device tree, and see if there are any other nodes
2290 * which say they are compatible with the external mdio
2291 * bus.
2292 */
2293 for_each_available_child_of_node(np, child) {
2294 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2295 if (match) {
2296 err = mv88e6xxx_mdio_register(chip, child, true);
2297 if (err)
2298 return err;
2299 }
2300 }
2301
2302 return 0;
2303}
2304
2305static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
Andrew Lunnb516d452016-06-04 21:17:06 +02002306
2307{
Andrew Lunna3c53be52017-01-24 14:53:50 +01002308 struct mv88e6xxx_mdio_bus *mdio_bus;
2309 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002310
Andrew Lunna3c53be52017-01-24 14:53:50 +01002311 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2312 bus = mdio_bus->bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002313
Andrew Lunna3c53be52017-01-24 14:53:50 +01002314 mdiobus_unregister(bus);
2315 }
Andrew Lunnb516d452016-06-04 21:17:06 +02002316}
2317
Vivien Didelot855b1932016-07-20 18:18:35 -04002318static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2319{
Vivien Didelot04bed142016-08-31 18:06:13 -04002320 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002321
2322 return chip->eeprom_len;
2323}
2324
Vivien Didelot855b1932016-07-20 18:18:35 -04002325static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2326 struct ethtool_eeprom *eeprom, u8 *data)
2327{
Vivien Didelot04bed142016-08-31 18:06:13 -04002328 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002329 int err;
2330
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002331 if (!chip->info->ops->get_eeprom)
2332 return -EOPNOTSUPP;
2333
Vivien Didelot855b1932016-07-20 18:18:35 -04002334 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002335 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002336 mutex_unlock(&chip->reg_lock);
2337
2338 if (err)
2339 return err;
2340
2341 eeprom->magic = 0xc3ec4951;
2342
2343 return 0;
2344}
2345
Vivien Didelot855b1932016-07-20 18:18:35 -04002346static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2347 struct ethtool_eeprom *eeprom, u8 *data)
2348{
Vivien Didelot04bed142016-08-31 18:06:13 -04002349 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002350 int err;
2351
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002352 if (!chip->info->ops->set_eeprom)
2353 return -EOPNOTSUPP;
2354
Vivien Didelot855b1932016-07-20 18:18:35 -04002355 if (eeprom->magic != 0xc3ec4951)
2356 return -EINVAL;
2357
2358 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002359 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002360 mutex_unlock(&chip->reg_lock);
2361
2362 return err;
2363}
2364
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002365static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002366 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002367 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002368 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002369 .phy_read = mv88e6185_phy_ppu_read,
2370 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002371 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002372 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002373 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002374 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002375 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002376 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002377 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002378 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002379 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002380 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002381 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002382 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002383 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2384 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002385 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002386 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2387 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002388 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002389 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002390 .ppu_enable = mv88e6185_g1_ppu_enable,
2391 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002392 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002393 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002394 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002395};
2396
2397static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002398 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002399 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002400 .phy_read = mv88e6185_phy_ppu_read,
2401 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002402 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002403 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002404 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002405 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002406 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002407 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002408 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002409 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2410 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002411 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002412 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002413 .ppu_enable = mv88e6185_g1_ppu_enable,
2414 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002415 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002416 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002417 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002418};
2419
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002420static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002421 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002422 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002423 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2424 .phy_read = mv88e6xxx_g2_smi_phy_read,
2425 .phy_write = mv88e6xxx_g2_smi_phy_write,
2426 .port_set_link = mv88e6xxx_port_set_link,
2427 .port_set_duplex = mv88e6xxx_port_set_duplex,
2428 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002429 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002430 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002431 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002432 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002433 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002434 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002435 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002436 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002437 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002438 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
2439 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2440 .stats_get_strings = mv88e6095_stats_get_strings,
2441 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002442 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2443 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002444 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002445 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002446 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002447 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002448 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002449};
2450
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002451static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002452 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002453 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002454 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002455 .phy_read = mv88e6xxx_g2_smi_phy_read,
2456 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002457 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002458 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002459 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002460 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002461 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002462 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002463 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002464 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002465 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2466 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002467 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002468 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2469 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002470 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002471 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002472 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002473 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002474 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002475};
2476
2477static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002478 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002479 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002480 .phy_read = mv88e6185_phy_ppu_read,
2481 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002482 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002483 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002484 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002485 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002486 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002487 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002488 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002489 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002490 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002491 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002492 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002493 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002494 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2495 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002496 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002497 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2498 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002499 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002500 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002501 .ppu_enable = mv88e6185_g1_ppu_enable,
2502 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002503 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002504 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002505 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002506};
2507
Vivien Didelot990e27b2017-03-28 13:50:32 -04002508static const struct mv88e6xxx_ops mv88e6141_ops = {
2509 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002510 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002511 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2512 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2513 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2514 .phy_read = mv88e6xxx_g2_smi_phy_read,
2515 .phy_write = mv88e6xxx_g2_smi_phy_write,
2516 .port_set_link = mv88e6xxx_port_set_link,
2517 .port_set_duplex = mv88e6xxx_port_set_duplex,
2518 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2519 .port_set_speed = mv88e6390_port_set_speed,
2520 .port_tag_remap = mv88e6095_port_tag_remap,
2521 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2522 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2523 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002524 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002525 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002526 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002527 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2528 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2529 .stats_snapshot = mv88e6390_g1_stats_snapshot,
2530 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2531 .stats_get_strings = mv88e6320_stats_get_strings,
2532 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002533 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2534 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002535 .watchdog_ops = &mv88e6390_watchdog_ops,
2536 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
2537 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002538 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002539 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002540};
2541
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002542static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002543 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002544 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002545 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002546 .phy_read = mv88e6xxx_g2_smi_phy_read,
2547 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002548 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002549 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002550 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002551 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002552 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002553 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002554 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002555 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002556 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002557 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002558 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002559 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002560 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002561 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2562 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002563 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002564 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2565 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002566 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002567 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002568 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002569 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002570 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002571};
2572
2573static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002574 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002575 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002576 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002577 .phy_read = mv88e6165_phy_read,
2578 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002579 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002580 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002581 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002582 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002583 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002584 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002585 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2586 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002587 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002588 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2589 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002590 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002591 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002592 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002593 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002594 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002595};
2596
2597static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002598 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002599 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002600 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002601 .phy_read = mv88e6xxx_g2_smi_phy_read,
2602 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002603 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002604 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002605 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002606 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002607 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002608 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002609 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002610 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002611 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002612 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002613 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002614 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002615 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002616 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002617 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2618 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002619 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002620 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2621 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002622 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002623 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002624 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002625 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002626 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002627};
2628
2629static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002630 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002631 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002632 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2633 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002634 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002635 .phy_read = mv88e6xxx_g2_smi_phy_read,
2636 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002637 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002638 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002639 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002640 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002641 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002642 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002643 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002644 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002645 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002646 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002647 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002648 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002649 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002650 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002651 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2652 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002653 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002654 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2655 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002656 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002657 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002658 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002659 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002660 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002661 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002662};
2663
2664static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002665 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002666 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002667 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002668 .phy_read = mv88e6xxx_g2_smi_phy_read,
2669 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002670 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002671 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002672 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002673 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002674 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002675 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002676 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002677 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002678 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002679 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002680 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002681 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002682 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002683 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002684 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2685 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002686 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002687 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2688 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002689 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002690 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002691 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002692 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002693 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002694};
2695
2696static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002697 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002698 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002699 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2700 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002701 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002702 .phy_read = mv88e6xxx_g2_smi_phy_read,
2703 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002704 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002705 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002706 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002707 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002708 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002709 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002710 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002711 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002712 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002713 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002714 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002715 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002716 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002717 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002718 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2719 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002720 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002721 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2722 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002723 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002724 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002725 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002726 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002727 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002728 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002729};
2730
2731static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002732 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002733 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002734 .phy_read = mv88e6185_phy_ppu_read,
2735 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002736 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002737 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002738 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002739 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002740 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002741 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002742 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002743 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002744 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2745 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002746 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002747 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2748 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002749 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002750 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002751 .ppu_enable = mv88e6185_g1_ppu_enable,
2752 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002753 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002754 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002755 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002756};
2757
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002758static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002759 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002760 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002761 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2762 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002763 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2764 .phy_read = mv88e6xxx_g2_smi_phy_read,
2765 .phy_write = mv88e6xxx_g2_smi_phy_write,
2766 .port_set_link = mv88e6xxx_port_set_link,
2767 .port_set_duplex = mv88e6xxx_port_set_duplex,
2768 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2769 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002770 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002771 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002772 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002773 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002774 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002775 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002776 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002777 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002778 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002779 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2780 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002781 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002782 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2783 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002784 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002785 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002786 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002787 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2788 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002789 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002790};
2791
2792static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002793 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002794 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002795 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2796 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002797 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2798 .phy_read = mv88e6xxx_g2_smi_phy_read,
2799 .phy_write = mv88e6xxx_g2_smi_phy_write,
2800 .port_set_link = mv88e6xxx_port_set_link,
2801 .port_set_duplex = mv88e6xxx_port_set_duplex,
2802 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2803 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002804 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002805 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002806 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002807 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002808 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002809 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002810 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002811 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002812 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002813 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2814 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002815 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002816 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2817 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002818 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002819 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002820 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002821 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2822 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002823 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002824};
2825
2826static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002827 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002828 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002829 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2830 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002831 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2832 .phy_read = mv88e6xxx_g2_smi_phy_read,
2833 .phy_write = mv88e6xxx_g2_smi_phy_write,
2834 .port_set_link = mv88e6xxx_port_set_link,
2835 .port_set_duplex = mv88e6xxx_port_set_duplex,
2836 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2837 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002838 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002839 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002840 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002841 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002842 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002843 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002844 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002845 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002846 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002847 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2848 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002849 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002850 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2851 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002852 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002853 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002854 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002855 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2856 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002857 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002858};
2859
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002860static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002861 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002862 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002863 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2864 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002865 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002866 .phy_read = mv88e6xxx_g2_smi_phy_read,
2867 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002868 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002869 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002870 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002871 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002872 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002873 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002874 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002875 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002876 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002877 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002878 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002879 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002880 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002881 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002882 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2883 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002884 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002885 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2886 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002887 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002888 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002889 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002890 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002891 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002892 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002893};
2894
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002895static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002896 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002897 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002898 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2899 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002900 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2901 .phy_read = mv88e6xxx_g2_smi_phy_read,
2902 .phy_write = mv88e6xxx_g2_smi_phy_write,
2903 .port_set_link = mv88e6xxx_port_set_link,
2904 .port_set_duplex = mv88e6xxx_port_set_duplex,
2905 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2906 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002907 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002908 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002909 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002910 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002911 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002912 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002913 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002914 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002915 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002916 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002917 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2918 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002919 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002920 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2921 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002922 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002923 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002924 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002925 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2926 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002927 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002928};
2929
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002930static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002931 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002932 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002933 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2934 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002935 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002936 .phy_read = mv88e6xxx_g2_smi_phy_read,
2937 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002938 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002939 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002940 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002941 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002942 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002943 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002944 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002945 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002946 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002947 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002948 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002949 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002950 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002951 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2952 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002953 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002954 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2955 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002956 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002957 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002958 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002959 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002960};
2961
2962static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04002963 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002964 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002965 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2966 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002967 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002968 .phy_read = mv88e6xxx_g2_smi_phy_read,
2969 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002970 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002971 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002972 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002973 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002974 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002975 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002976 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002977 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002978 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002979 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002980 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002981 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002982 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002983 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2984 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002985 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002986 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2987 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002988 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002989 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002990 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002991};
2992
Vivien Didelot16e329a2017-03-28 13:50:33 -04002993static const struct mv88e6xxx_ops mv88e6341_ops = {
2994 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002995 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002996 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2997 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2998 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2999 .phy_read = mv88e6xxx_g2_smi_phy_read,
3000 .phy_write = mv88e6xxx_g2_smi_phy_write,
3001 .port_set_link = mv88e6xxx_port_set_link,
3002 .port_set_duplex = mv88e6xxx_port_set_duplex,
3003 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3004 .port_set_speed = mv88e6390_port_set_speed,
3005 .port_tag_remap = mv88e6095_port_tag_remap,
3006 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3007 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3008 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003009 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003010 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003011 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003012 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3013 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3014 .stats_snapshot = mv88e6390_g1_stats_snapshot,
3015 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3016 .stats_get_strings = mv88e6320_stats_get_strings,
3017 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003018 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3019 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003020 .watchdog_ops = &mv88e6390_watchdog_ops,
3021 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
3022 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003023 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003024 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003025};
3026
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003027static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003028 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003029 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003030 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003031 .phy_read = mv88e6xxx_g2_smi_phy_read,
3032 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003033 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003034 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003035 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003036 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003037 .port_tag_remap = mv88e6095_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 = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003044 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003045 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003046 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01003047 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3048 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003049 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003050 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3051 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003052 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003053 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003054 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003055 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003056 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003057};
3058
3059static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003060 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003061 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003062 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003063 .phy_read = mv88e6xxx_g2_smi_phy_read,
3064 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003065 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003066 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003067 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003068 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003069 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003070 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003071 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003072 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003073 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003074 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003075 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003076 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003077 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003078 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01003079 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3080 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003081 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003082 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3083 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003084 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003085 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003086 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003087 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003088 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003089};
3090
3091static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003092 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003093 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003094 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3095 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003096 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003097 .phy_read = mv88e6xxx_g2_smi_phy_read,
3098 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003099 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003100 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003101 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003102 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003103 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003104 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003105 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003106 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003107 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003108 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003109 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003110 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003111 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003112 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01003113 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3114 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003115 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003116 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3117 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003118 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003119 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003120 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003121 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003122 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003123 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003124};
3125
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003126static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003127 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003128 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003129 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3130 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003131 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3132 .phy_read = mv88e6xxx_g2_smi_phy_read,
3133 .phy_write = mv88e6xxx_g2_smi_phy_write,
3134 .port_set_link = mv88e6xxx_port_set_link,
3135 .port_set_duplex = mv88e6xxx_port_set_duplex,
3136 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3137 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003138 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003139 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003140 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003141 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003142 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003143 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003144 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003145 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003146 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003147 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003148 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003149 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003150 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3151 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003152 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003153 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3154 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003155 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003156 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003157 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003158 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3159 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003160 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003161};
3162
3163static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003164 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003165 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003166 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3167 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003168 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3169 .phy_read = mv88e6xxx_g2_smi_phy_read,
3170 .phy_write = mv88e6xxx_g2_smi_phy_write,
3171 .port_set_link = mv88e6xxx_port_set_link,
3172 .port_set_duplex = mv88e6xxx_port_set_duplex,
3173 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3174 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003175 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003176 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003177 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003178 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003179 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003180 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003181 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003182 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003183 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003184 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003185 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003186 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3187 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003188 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003189 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3190 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003191 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003192 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003193 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003194 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3195 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003196 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003197};
3198
Vivien Didelotf81ec902016-05-09 13:22:58 -04003199static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3200 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003201 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003202 .family = MV88E6XXX_FAMILY_6097,
3203 .name = "Marvell 88E6085",
3204 .num_databases = 4096,
3205 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003206 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003207 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003208 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003209 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003210 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003211 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003212 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003213 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003214 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003215 .flags = MV88E6XXX_FLAGS_FAMILY_6097,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003216 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003217 },
3218
3219 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003220 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003221 .family = MV88E6XXX_FAMILY_6095,
3222 .name = "Marvell 88E6095/88E6095F",
3223 .num_databases = 256,
3224 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003225 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003226 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003227 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003228 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003229 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003230 .atu_move_port_mask = 0xf,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003231 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003232 .flags = MV88E6XXX_FLAGS_FAMILY_6095,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003233 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003234 },
3235
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003236 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003237 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003238 .family = MV88E6XXX_FAMILY_6097,
3239 .name = "Marvell 88E6097/88E6097F",
3240 .num_databases = 4096,
3241 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003242 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003243 .port_base_addr = 0x10,
3244 .global1_addr = 0x1b,
3245 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003246 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003247 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003248 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003249 .pvt = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003250 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003251 .flags = MV88E6XXX_FLAGS_FAMILY_6097,
3252 .ops = &mv88e6097_ops,
3253 },
3254
Vivien Didelotf81ec902016-05-09 13:22:58 -04003255 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003256 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003257 .family = MV88E6XXX_FAMILY_6165,
3258 .name = "Marvell 88E6123",
3259 .num_databases = 4096,
3260 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003261 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003262 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003263 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003264 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003265 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003266 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003267 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003268 .pvt = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003269 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003270 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003271 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003272 },
3273
3274 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003275 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003276 .family = MV88E6XXX_FAMILY_6185,
3277 .name = "Marvell 88E6131",
3278 .num_databases = 256,
3279 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003280 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003281 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003282 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003283 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003284 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003285 .atu_move_port_mask = 0xf,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003286 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003287 .flags = MV88E6XXX_FLAGS_FAMILY_6185,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003288 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003289 },
3290
Vivien Didelot990e27b2017-03-28 13:50:32 -04003291 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003292 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003293 .family = MV88E6XXX_FAMILY_6341,
3294 .name = "Marvell 88E6341",
3295 .num_databases = 4096,
3296 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003297 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003298 .port_base_addr = 0x10,
3299 .global1_addr = 0x1b,
3300 .age_time_coeff = 3750,
3301 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003302 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003303 .pvt = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003304 .tag_protocol = DSA_TAG_PROTO_EDSA,
3305 .flags = MV88E6XXX_FLAGS_FAMILY_6341,
3306 .ops = &mv88e6141_ops,
3307 },
3308
Vivien Didelotf81ec902016-05-09 13:22:58 -04003309 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003310 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003311 .family = MV88E6XXX_FAMILY_6165,
3312 .name = "Marvell 88E6161",
3313 .num_databases = 4096,
3314 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003315 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003316 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003317 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003318 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003319 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003320 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003321 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003322 .pvt = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003323 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003324 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003325 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003326 },
3327
3328 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003329 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003330 .family = MV88E6XXX_FAMILY_6165,
3331 .name = "Marvell 88E6165",
3332 .num_databases = 4096,
3333 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003334 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003335 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003336 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003337 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003338 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003339 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003340 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003341 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003342 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003343 .flags = MV88E6XXX_FLAGS_FAMILY_6165,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003344 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003345 },
3346
3347 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003348 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003349 .family = MV88E6XXX_FAMILY_6351,
3350 .name = "Marvell 88E6171",
3351 .num_databases = 4096,
3352 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003353 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003354 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003355 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003356 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003357 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003358 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003359 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003360 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003361 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003362 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003363 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003364 },
3365
3366 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003367 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003368 .family = MV88E6XXX_FAMILY_6352,
3369 .name = "Marvell 88E6172",
3370 .num_databases = 4096,
3371 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003372 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003373 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003374 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003375 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003376 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003377 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003378 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003379 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003380 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003381 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003382 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003383 },
3384
3385 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003386 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003387 .family = MV88E6XXX_FAMILY_6351,
3388 .name = "Marvell 88E6175",
3389 .num_databases = 4096,
3390 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003391 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003392 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003393 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003394 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003395 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003396 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003397 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003398 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003399 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003400 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003401 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003402 },
3403
3404 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003405 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003406 .family = MV88E6XXX_FAMILY_6352,
3407 .name = "Marvell 88E6176",
3408 .num_databases = 4096,
3409 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003410 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003411 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003412 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003413 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003414 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003415 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003416 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003417 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003418 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003419 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003420 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003421 },
3422
3423 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003424 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003425 .family = MV88E6XXX_FAMILY_6185,
3426 .name = "Marvell 88E6185",
3427 .num_databases = 256,
3428 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003429 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003430 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003431 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003432 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003433 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003434 .atu_move_port_mask = 0xf,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003435 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003436 .flags = MV88E6XXX_FLAGS_FAMILY_6185,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003437 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003438 },
3439
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003440 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003441 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003442 .family = MV88E6XXX_FAMILY_6390,
3443 .name = "Marvell 88E6190",
3444 .num_databases = 4096,
3445 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003446 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003447 .port_base_addr = 0x0,
3448 .global1_addr = 0x1b,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003449 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003450 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003451 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003452 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003453 .pvt = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003454 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003455 .flags = MV88E6XXX_FLAGS_FAMILY_6390,
3456 .ops = &mv88e6190_ops,
3457 },
3458
3459 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003460 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003461 .family = MV88E6XXX_FAMILY_6390,
3462 .name = "Marvell 88E6190X",
3463 .num_databases = 4096,
3464 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003465 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003466 .port_base_addr = 0x0,
3467 .global1_addr = 0x1b,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003468 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003469 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003470 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003471 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003472 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003473 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003474 .flags = MV88E6XXX_FLAGS_FAMILY_6390,
3475 .ops = &mv88e6190x_ops,
3476 },
3477
3478 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003479 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003480 .family = MV88E6XXX_FAMILY_6390,
3481 .name = "Marvell 88E6191",
3482 .num_databases = 4096,
3483 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003484 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003485 .port_base_addr = 0x0,
3486 .global1_addr = 0x1b,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003487 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003488 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003489 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003490 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003491 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003492 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003493 .flags = MV88E6XXX_FLAGS_FAMILY_6390,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003494 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003495 },
3496
Vivien Didelotf81ec902016-05-09 13:22:58 -04003497 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003498 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003499 .family = MV88E6XXX_FAMILY_6352,
3500 .name = "Marvell 88E6240",
3501 .num_databases = 4096,
3502 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003503 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003504 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003505 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003506 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003507 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003508 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003509 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003510 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003511 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003512 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003513 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003514 },
3515
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003516 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003517 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003518 .family = MV88E6XXX_FAMILY_6390,
3519 .name = "Marvell 88E6290",
3520 .num_databases = 4096,
3521 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003522 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003523 .port_base_addr = 0x0,
3524 .global1_addr = 0x1b,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003525 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003526 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003527 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003528 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003529 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003530 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003531 .flags = MV88E6XXX_FLAGS_FAMILY_6390,
3532 .ops = &mv88e6290_ops,
3533 },
3534
Vivien Didelotf81ec902016-05-09 13:22:58 -04003535 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003536 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003537 .family = MV88E6XXX_FAMILY_6320,
3538 .name = "Marvell 88E6320",
3539 .num_databases = 4096,
3540 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003541 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003542 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003543 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003544 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003545 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003546 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003547 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003548 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003549 .flags = MV88E6XXX_FLAGS_FAMILY_6320,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003550 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003551 },
3552
3553 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003554 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003555 .family = MV88E6XXX_FAMILY_6320,
3556 .name = "Marvell 88E6321",
3557 .num_databases = 4096,
3558 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003559 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003560 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003561 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003562 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003563 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003564 .atu_move_port_mask = 0xf,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003565 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003566 .flags = MV88E6XXX_FLAGS_FAMILY_6320,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003567 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003568 },
3569
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003570 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003571 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003572 .family = MV88E6XXX_FAMILY_6341,
3573 .name = "Marvell 88E6341",
3574 .num_databases = 4096,
3575 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003576 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003577 .port_base_addr = 0x10,
3578 .global1_addr = 0x1b,
3579 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003580 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003581 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003582 .pvt = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003583 .tag_protocol = DSA_TAG_PROTO_EDSA,
3584 .flags = MV88E6XXX_FLAGS_FAMILY_6341,
3585 .ops = &mv88e6341_ops,
3586 },
3587
Vivien Didelotf81ec902016-05-09 13:22:58 -04003588 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003589 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003590 .family = MV88E6XXX_FAMILY_6351,
3591 .name = "Marvell 88E6350",
3592 .num_databases = 4096,
3593 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003594 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003595 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003596 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003597 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003598 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003599 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003600 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003601 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003602 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003603 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003604 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003605 },
3606
3607 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003608 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003609 .family = MV88E6XXX_FAMILY_6351,
3610 .name = "Marvell 88E6351",
3611 .num_databases = 4096,
3612 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003613 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003614 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003615 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003616 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003617 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003618 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003619 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003620 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003621 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003622 .flags = MV88E6XXX_FLAGS_FAMILY_6351,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003623 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003624 },
3625
3626 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003627 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003628 .family = MV88E6XXX_FAMILY_6352,
3629 .name = "Marvell 88E6352",
3630 .num_databases = 4096,
3631 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003632 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003633 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003634 .global1_addr = 0x1b,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003635 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003636 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003637 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003638 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003639 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003640 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003641 .flags = MV88E6XXX_FLAGS_FAMILY_6352,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003642 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003643 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003644 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003645 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003646 .family = MV88E6XXX_FAMILY_6390,
3647 .name = "Marvell 88E6390",
3648 .num_databases = 4096,
3649 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003650 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003651 .port_base_addr = 0x0,
3652 .global1_addr = 0x1b,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003653 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003654 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003655 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003656 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003657 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003658 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003659 .flags = MV88E6XXX_FLAGS_FAMILY_6390,
3660 .ops = &mv88e6390_ops,
3661 },
3662 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003663 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003664 .family = MV88E6XXX_FAMILY_6390,
3665 .name = "Marvell 88E6390X",
3666 .num_databases = 4096,
3667 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003668 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003669 .port_base_addr = 0x0,
3670 .global1_addr = 0x1b,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003671 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003672 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003673 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003674 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003675 .pvt = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003676 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003677 .flags = MV88E6XXX_FLAGS_FAMILY_6390,
3678 .ops = &mv88e6390x_ops,
3679 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003680};
3681
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003682static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003683{
Vivien Didelota439c062016-04-17 13:23:58 -04003684 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003685
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003686 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3687 if (mv88e6xxx_table[i].prod_num == prod_num)
3688 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003689
Vivien Didelotb9b37712015-10-30 19:39:48 -04003690 return NULL;
3691}
3692
Vivien Didelotfad09c72016-06-21 12:28:20 -04003693static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003694{
3695 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003696 unsigned int prod_num, rev;
3697 u16 id;
3698 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003699
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003700 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003701 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003702 mutex_unlock(&chip->reg_lock);
3703 if (err)
3704 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003705
Vivien Didelot107fcc12017-06-12 12:37:36 -04003706 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3707 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003708
3709 info = mv88e6xxx_lookup_info(prod_num);
3710 if (!info)
3711 return -ENODEV;
3712
Vivien Didelotcaac8542016-06-20 13:14:09 -04003713 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003714 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003715
Vivien Didelotca070c12016-09-02 14:45:34 -04003716 err = mv88e6xxx_g2_require(chip);
3717 if (err)
3718 return err;
3719
Vivien Didelotfad09c72016-06-21 12:28:20 -04003720 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3721 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003722
3723 return 0;
3724}
3725
Vivien Didelotfad09c72016-06-21 12:28:20 -04003726static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003727{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003728 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003729
Vivien Didelotfad09c72016-06-21 12:28:20 -04003730 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3731 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003732 return NULL;
3733
Vivien Didelotfad09c72016-06-21 12:28:20 -04003734 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003735
Vivien Didelotfad09c72016-06-21 12:28:20 -04003736 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003737 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003738
Vivien Didelotfad09c72016-06-21 12:28:20 -04003739 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003740}
3741
Vivien Didelotfad09c72016-06-21 12:28:20 -04003742static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003743 struct mii_bus *bus, int sw_addr)
3744{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003745 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003746 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelota0ffff22016-08-15 17:18:58 -04003747 else if (mv88e6xxx_has(chip, MV88E6XXX_FLAGS_MULTI_CHIP))
Vivien Didelotfad09c72016-06-21 12:28:20 -04003748 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003749 else
3750 return -EINVAL;
3751
Vivien Didelotfad09c72016-06-21 12:28:20 -04003752 chip->bus = bus;
3753 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003754
3755 return 0;
3756}
3757
Andrew Lunn7b314362016-08-22 16:01:01 +02003758static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds)
3759{
Vivien Didelot04bed142016-08-31 18:06:13 -04003760 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003761
Andrew Lunn443d5a12016-12-03 04:35:18 +01003762 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003763}
3764
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003765static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3766 struct device *host_dev, int sw_addr,
3767 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003768{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003769 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003770 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003771 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003772
Vivien Didelota439c062016-04-17 13:23:58 -04003773 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003774 if (!bus)
3775 return NULL;
3776
Vivien Didelotfad09c72016-06-21 12:28:20 -04003777 chip = mv88e6xxx_alloc_chip(dsa_dev);
3778 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003779 return NULL;
3780
Vivien Didelotcaac8542016-06-20 13:14:09 -04003781 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003782 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003783
Vivien Didelotfad09c72016-06-21 12:28:20 -04003784 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003785 if (err)
3786 goto free;
3787
Vivien Didelotfad09c72016-06-21 12:28:20 -04003788 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003789 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003790 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003791
Andrew Lunndc30c352016-10-16 19:56:49 +02003792 mutex_lock(&chip->reg_lock);
3793 err = mv88e6xxx_switch_reset(chip);
3794 mutex_unlock(&chip->reg_lock);
3795 if (err)
3796 goto free;
3797
Vivien Didelote57e5e72016-08-15 17:19:00 -04003798 mv88e6xxx_phy_init(chip);
3799
Andrew Lunna3c53be52017-01-24 14:53:50 +01003800 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003801 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003802 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003803
Vivien Didelotfad09c72016-06-21 12:28:20 -04003804 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003805
Vivien Didelotfad09c72016-06-21 12:28:20 -04003806 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003807free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003808 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003809
3810 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003811}
3812
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003813static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
3814 const struct switchdev_obj_port_mdb *mdb,
3815 struct switchdev_trans *trans)
3816{
3817 /* We don't need any dynamic resource from the kernel (yet),
3818 * so skip the prepare phase.
3819 */
3820
3821 return 0;
3822}
3823
3824static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
3825 const struct switchdev_obj_port_mdb *mdb,
3826 struct switchdev_trans *trans)
3827{
Vivien Didelot04bed142016-08-31 18:06:13 -04003828 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003829
3830 mutex_lock(&chip->reg_lock);
3831 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003832 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003833 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3834 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003835 mutex_unlock(&chip->reg_lock);
3836}
3837
3838static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3839 const struct switchdev_obj_port_mdb *mdb)
3840{
Vivien Didelot04bed142016-08-31 18:06:13 -04003841 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003842 int err;
3843
3844 mutex_lock(&chip->reg_lock);
3845 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003846 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003847 mutex_unlock(&chip->reg_lock);
3848
3849 return err;
3850}
3851
3852static int mv88e6xxx_port_mdb_dump(struct dsa_switch *ds, int port,
3853 struct switchdev_obj_port_mdb *mdb,
Vivien Didelot438ff532017-05-17 15:46:05 -04003854 switchdev_obj_dump_cb_t *cb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003855{
Vivien Didelot04bed142016-08-31 18:06:13 -04003856 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003857 int err;
3858
3859 mutex_lock(&chip->reg_lock);
3860 err = mv88e6xxx_port_db_dump(chip, port, &mdb->obj, cb);
3861 mutex_unlock(&chip->reg_lock);
3862
3863 return err;
3864}
3865
Florian Fainellia82f67a2017-01-08 14:52:08 -08003866static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003867 .probe = mv88e6xxx_drv_probe,
Andrew Lunn7b314362016-08-22 16:01:01 +02003868 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003869 .setup = mv88e6xxx_setup,
3870 .set_addr = mv88e6xxx_set_addr,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003871 .adjust_link = mv88e6xxx_adjust_link,
3872 .get_strings = mv88e6xxx_get_strings,
3873 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3874 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003875 .port_enable = mv88e6xxx_port_enable,
3876 .port_disable = mv88e6xxx_port_disable,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003877 .set_eee = mv88e6xxx_set_eee,
3878 .get_eee = mv88e6xxx_get_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003879 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003880 .get_eeprom = mv88e6xxx_get_eeprom,
3881 .set_eeprom = mv88e6xxx_set_eeprom,
3882 .get_regs_len = mv88e6xxx_get_regs_len,
3883 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003884 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003885 .port_bridge_join = mv88e6xxx_port_bridge_join,
3886 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3887 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04003888 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003889 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3890 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3891 .port_vlan_add = mv88e6xxx_port_vlan_add,
3892 .port_vlan_del = mv88e6xxx_port_vlan_del,
3893 .port_vlan_dump = mv88e6xxx_port_vlan_dump,
3894 .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
3895 .port_fdb_add = mv88e6xxx_port_fdb_add,
3896 .port_fdb_del = mv88e6xxx_port_fdb_del,
3897 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003898 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
3899 .port_mdb_add = mv88e6xxx_port_mdb_add,
3900 .port_mdb_del = mv88e6xxx_port_mdb_del,
3901 .port_mdb_dump = mv88e6xxx_port_mdb_dump,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04003902 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
3903 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003904};
3905
Florian Fainelliab3d4082017-01-08 14:52:07 -08003906static struct dsa_switch_driver mv88e6xxx_switch_drv = {
3907 .ops = &mv88e6xxx_switch_ops,
3908};
3909
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003910static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003911{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003912 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003913 struct dsa_switch *ds;
3914
Vivien Didelot73b12042017-03-30 17:37:10 -04003915 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003916 if (!ds)
3917 return -ENOMEM;
3918
Vivien Didelotfad09c72016-06-21 12:28:20 -04003919 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04003920 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04003921 ds->ageing_time_min = chip->info->age_time_coeff;
3922 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003923
3924 dev_set_drvdata(dev, ds);
3925
Vivien Didelot23c9ee42017-05-26 18:12:51 -04003926 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003927}
3928
Vivien Didelotfad09c72016-06-21 12:28:20 -04003929static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003930{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003931 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003932}
3933
Vivien Didelot57d32312016-06-20 13:13:58 -04003934static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003935{
3936 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003937 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003938 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003939 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003940 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02003941 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003942
Vivien Didelotcaac8542016-06-20 13:14:09 -04003943 compat_info = of_device_get_match_data(dev);
3944 if (!compat_info)
3945 return -EINVAL;
3946
Vivien Didelotfad09c72016-06-21 12:28:20 -04003947 chip = mv88e6xxx_alloc_chip(dev);
3948 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003949 return -ENOMEM;
3950
Vivien Didelotfad09c72016-06-21 12:28:20 -04003951 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003952
Vivien Didelotfad09c72016-06-21 12:28:20 -04003953 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003954 if (err)
3955 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003956
Andrew Lunnb4308f02016-11-21 23:26:55 +01003957 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
3958 if (IS_ERR(chip->reset))
3959 return PTR_ERR(chip->reset);
3960
Vivien Didelotfad09c72016-06-21 12:28:20 -04003961 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003962 if (err)
3963 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003964
Vivien Didelote57e5e72016-08-15 17:19:00 -04003965 mv88e6xxx_phy_init(chip);
3966
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003967 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003968 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04003969 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003970
Andrew Lunndc30c352016-10-16 19:56:49 +02003971 mutex_lock(&chip->reg_lock);
3972 err = mv88e6xxx_switch_reset(chip);
3973 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02003974 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02003975 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02003976
Andrew Lunndc30c352016-10-16 19:56:49 +02003977 chip->irq = of_irq_get(np, 0);
3978 if (chip->irq == -EPROBE_DEFER) {
3979 err = chip->irq;
3980 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02003981 }
3982
Andrew Lunndc30c352016-10-16 19:56:49 +02003983 if (chip->irq > 0) {
3984 /* Has to be performed before the MDIO bus is created,
3985 * because the PHYs will link there interrupts to these
3986 * interrupt controllers
3987 */
3988 mutex_lock(&chip->reg_lock);
3989 err = mv88e6xxx_g1_irq_setup(chip);
3990 mutex_unlock(&chip->reg_lock);
3991
3992 if (err)
3993 goto out;
3994
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003995 if (chip->info->g2_irqs > 0) {
Andrew Lunndc30c352016-10-16 19:56:49 +02003996 err = mv88e6xxx_g2_irq_setup(chip);
3997 if (err)
3998 goto out_g1_irq;
3999 }
4000 }
4001
Andrew Lunna3c53be52017-01-24 14:53:50 +01004002 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004003 if (err)
4004 goto out_g2_irq;
4005
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004006 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004007 if (err)
4008 goto out_mdio;
4009
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004010 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004011
4012out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004013 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004014out_g2_irq:
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004015 if (chip->info->g2_irqs > 0 && chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004016 mv88e6xxx_g2_irq_free(chip);
4017out_g1_irq:
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004018 if (chip->irq > 0) {
4019 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004020 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004021 mutex_unlock(&chip->reg_lock);
4022 }
Andrew Lunndc30c352016-10-16 19:56:49 +02004023out:
4024 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004025}
4026
4027static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4028{
4029 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004030 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004031
Andrew Lunn930188c2016-08-22 16:01:03 +02004032 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004033 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004034 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004035
Andrew Lunn467126442016-11-20 20:14:15 +01004036 if (chip->irq > 0) {
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004037 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004038 mv88e6xxx_g2_irq_free(chip);
4039 mv88e6xxx_g1_irq_free(chip);
4040 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004041}
4042
4043static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004044 {
4045 .compatible = "marvell,mv88e6085",
4046 .data = &mv88e6xxx_table[MV88E6085],
4047 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004048 {
4049 .compatible = "marvell,mv88e6190",
4050 .data = &mv88e6xxx_table[MV88E6190],
4051 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004052 { /* sentinel */ },
4053};
4054
4055MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4056
4057static struct mdio_driver mv88e6xxx_driver = {
4058 .probe = mv88e6xxx_probe,
4059 .remove = mv88e6xxx_remove,
4060 .mdiodrv.driver = {
4061 .name = "mv88e6085",
4062 .of_match_table = mv88e6xxx_of_match,
4063 },
4064};
4065
Ben Hutchings98e67302011-11-25 14:36:19 +00004066static int __init mv88e6xxx_init(void)
4067{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004068 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004069 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004070}
4071module_init(mv88e6xxx_init);
4072
4073static void __exit mv88e6xxx_cleanup(void)
4074{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004075 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004076 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004077}
4078module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004079
4080MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4081MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4082MODULE_LICENSE("GPL");