blob: 521738c4cd171e7aadcf07f26195241a9d133cd7 [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 Didelot08f50062017-08-01 16:32:41 -0400813static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
814 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800815{
Vivien Didelot5480db62017-08-01 16:32:40 -0400816 /* Nothing to do on the port's MAC */
817 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800818}
819
Vivien Didelot08f50062017-08-01 16:32:41 -0400820static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
821 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800822{
Vivien Didelot5480db62017-08-01 16:32:40 -0400823 /* Nothing to do on the port's MAC */
824 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800825}
826
Vivien Didelote5887a22017-03-30 17:37:11 -0400827static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700828{
Vivien Didelote5887a22017-03-30 17:37:11 -0400829 struct dsa_switch *ds = NULL;
830 struct net_device *br;
831 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500832 int i;
833
Vivien Didelote5887a22017-03-30 17:37:11 -0400834 if (dev < DSA_MAX_SWITCHES)
835 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500836
Vivien Didelote5887a22017-03-30 17:37:11 -0400837 /* Prevent frames from unknown switch or port */
838 if (!ds || port >= ds->num_ports)
839 return 0;
840
841 /* Frames from DSA links and CPU ports can egress any local port */
842 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
843 return mv88e6xxx_port_mask(chip);
844
845 br = ds->ports[port].bridge_dev;
846 pvlan = 0;
847
848 /* Frames from user ports can egress any local DSA links and CPU ports,
849 * as well as any local member of their bridge group.
850 */
851 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
852 if (dsa_is_cpu_port(chip->ds, i) ||
853 dsa_is_dsa_port(chip->ds, i) ||
854 (br && chip->ds->ports[i].bridge_dev == br))
855 pvlan |= BIT(i);
856
857 return pvlan;
858}
859
Vivien Didelot240ea3e2017-03-30 17:37:12 -0400860static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -0400861{
862 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500863
864 /* prevent frames from going back out of the port they came in on */
865 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700866
Vivien Didelot5a7921f2016-11-04 03:23:28 +0100867 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700868}
869
Vivien Didelotf81ec902016-05-09 13:22:58 -0400870static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
871 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700872{
Vivien Didelot04bed142016-08-31 18:06:13 -0400873 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -0400874 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700875
Vivien Didelotfad09c72016-06-21 12:28:20 -0400876 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -0400877 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400878 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -0400879
880 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400881 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700882}
883
Vivien Didelot9e907d72017-07-17 13:03:43 -0400884static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
885{
886 if (chip->info->ops->pot_clear)
887 return chip->info->ops->pot_clear(chip);
888
889 return 0;
890}
891
Vivien Didelot51c901a2017-07-17 13:03:41 -0400892static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
893{
894 if (chip->info->ops->mgmt_rsvd2cpu)
895 return chip->info->ops->mgmt_rsvd2cpu(chip);
896
897 return 0;
898}
899
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500900static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
901{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500902 int err;
903
Vivien Didelotdaefc942017-03-11 16:12:54 -0500904 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
905 if (err)
906 return err;
907
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500908 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
909 if (err)
910 return err;
911
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500912 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
913}
914
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400915static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
916{
917 int port;
918 int err;
919
920 if (!chip->info->ops->irl_init_all)
921 return 0;
922
923 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
924 /* Disable ingress rate limiting by resetting all per port
925 * ingress rate limit resources to their initial state.
926 */
927 err = chip->info->ops->irl_init_all(chip, port);
928 if (err)
929 return err;
930 }
931
932 return 0;
933}
934
Vivien Didelot17a15942017-03-30 17:37:09 -0400935static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
936{
937 u16 pvlan = 0;
938
939 if (!mv88e6xxx_has_pvt(chip))
940 return -EOPNOTSUPP;
941
942 /* Skip the local source device, which uses in-chip port VLAN */
943 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -0400944 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -0400945
946 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
947}
948
Vivien Didelot81228992017-03-30 17:37:08 -0400949static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
950{
Vivien Didelot17a15942017-03-30 17:37:09 -0400951 int dev, port;
952 int err;
953
Vivien Didelot81228992017-03-30 17:37:08 -0400954 if (!mv88e6xxx_has_pvt(chip))
955 return 0;
956
957 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
958 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
959 */
Vivien Didelot17a15942017-03-30 17:37:09 -0400960 err = mv88e6xxx_g2_misc_4_bit_port(chip);
961 if (err)
962 return err;
963
964 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
965 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
966 err = mv88e6xxx_pvt_map(chip, dev, port);
967 if (err)
968 return err;
969 }
970 }
971
972 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -0400973}
974
Vivien Didelot749efcb2016-09-22 16:49:24 -0400975static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
976{
977 struct mv88e6xxx_chip *chip = ds->priv;
978 int err;
979
980 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -0500981 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400982 mutex_unlock(&chip->reg_lock);
983
984 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400985 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400986}
987
Vivien Didelotb486d7c2017-05-01 14:05:13 -0400988static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
989{
990 if (!chip->info->max_vid)
991 return 0;
992
993 return mv88e6xxx_g1_vtu_flush(chip);
994}
995
Vivien Didelotf1394b782017-05-01 14:05:22 -0400996static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
997 struct mv88e6xxx_vtu_entry *entry)
998{
999 if (!chip->info->ops->vtu_getnext)
1000 return -EOPNOTSUPP;
1001
1002 return chip->info->ops->vtu_getnext(chip, entry);
1003}
1004
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001005static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1006 struct mv88e6xxx_vtu_entry *entry)
1007{
1008 if (!chip->info->ops->vtu_loadpurge)
1009 return -EOPNOTSUPP;
1010
1011 return chip->info->ops->vtu_loadpurge(chip, entry);
1012}
1013
Vivien Didelotf81ec902016-05-09 13:22:58 -04001014static int mv88e6xxx_port_vlan_dump(struct dsa_switch *ds, int port,
1015 struct switchdev_obj_port_vlan *vlan,
Vivien Didelot438ff532017-05-17 15:46:05 -04001016 switchdev_obj_dump_cb_t *cb)
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001017{
Vivien Didelot04bed142016-08-31 18:06:13 -04001018 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001019 struct mv88e6xxx_vtu_entry next = {
1020 .vid = chip->info->max_vid,
1021 };
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001022 u16 pvid;
1023 int err;
1024
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001025 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001026 return -EOPNOTSUPP;
1027
Vivien Didelotfad09c72016-06-21 12:28:20 -04001028 mutex_lock(&chip->reg_lock);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001029
Vivien Didelot77064f32016-11-04 03:23:30 +01001030 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001031 if (err)
1032 goto unlock;
1033
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001034 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001035 err = mv88e6xxx_vtu_getnext(chip, &next);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001036 if (err)
1037 break;
1038
1039 if (!next.valid)
1040 break;
1041
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001042 if (next.member[port] ==
1043 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001044 continue;
1045
1046 /* reinit and dump this VLAN obj */
Vivien Didelot57d32312016-06-20 13:13:58 -04001047 vlan->vid_begin = next.vid;
1048 vlan->vid_end = next.vid;
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001049 vlan->flags = 0;
1050
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001051 if (next.member[port] ==
1052 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED)
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001053 vlan->flags |= BRIDGE_VLAN_INFO_UNTAGGED;
1054
1055 if (next.vid == pvid)
1056 vlan->flags |= BRIDGE_VLAN_INFO_PVID;
1057
1058 err = cb(&vlan->obj);
1059 if (err)
1060 break;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001061 } while (next.vid < chip->info->max_vid);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001062
1063unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001064 mutex_unlock(&chip->reg_lock);
Vivien Didelotceff5ef2016-02-23 12:13:55 -05001065
1066 return err;
1067}
1068
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001069static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001070{
1071 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001072 struct mv88e6xxx_vtu_entry vlan = {
1073 .vid = chip->info->max_vid,
1074 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001075 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001076
1077 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1078
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001079 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001080 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001081 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001082 if (err)
1083 return err;
1084
1085 set_bit(*fid, fid_bitmap);
1086 }
1087
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001088 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001089 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001090 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001091 if (err)
1092 return err;
1093
1094 if (!vlan.valid)
1095 break;
1096
1097 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001098 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001099
1100 /* The reset value 0x000 is used to indicate that multiple address
1101 * databases are not needed. Return the next positive available.
1102 */
1103 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001104 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001105 return -ENOSPC;
1106
1107 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001108 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001109}
1110
Vivien Didelot567aa592017-05-01 14:05:25 -04001111static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1112 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001113{
1114 int err;
1115
1116 if (!vid)
1117 return -EINVAL;
1118
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001119 entry->vid = vid - 1;
1120 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001121
Vivien Didelotf1394b782017-05-01 14:05:22 -04001122 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001123 if (err)
1124 return err;
1125
Vivien Didelot567aa592017-05-01 14:05:25 -04001126 if (entry->vid == vid && entry->valid)
1127 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001128
Vivien Didelot567aa592017-05-01 14:05:25 -04001129 if (new) {
1130 int i;
1131
1132 /* Initialize a fresh VLAN entry */
1133 memset(entry, 0, sizeof(*entry));
1134 entry->valid = true;
1135 entry->vid = vid;
1136
Vivien Didelot553a7682017-06-07 18:12:16 -04001137 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001138 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001139 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001140 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001141
1142 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001143 }
1144
Vivien Didelot567aa592017-05-01 14:05:25 -04001145 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1146 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001147}
1148
Vivien Didelotda9c3592016-02-12 12:09:40 -05001149static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1150 u16 vid_begin, u16 vid_end)
1151{
Vivien Didelot04bed142016-08-31 18:06:13 -04001152 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001153 struct mv88e6xxx_vtu_entry vlan = {
1154 .vid = vid_begin - 1,
1155 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001156 int i, err;
1157
1158 if (!vid_begin)
1159 return -EOPNOTSUPP;
1160
Vivien Didelotfad09c72016-06-21 12:28:20 -04001161 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001162
Vivien Didelotda9c3592016-02-12 12:09:40 -05001163 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001164 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001165 if (err)
1166 goto unlock;
1167
1168 if (!vlan.valid)
1169 break;
1170
1171 if (vlan.vid > vid_end)
1172 break;
1173
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001174 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001175 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1176 continue;
1177
Andrew Lunn66e28092016-12-11 21:07:19 +01001178 if (!ds->ports[port].netdev)
1179 continue;
1180
Vivien Didelotbd00e052017-05-01 14:05:11 -04001181 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001182 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001183 continue;
1184
Vivien Didelotfae8a252017-01-27 15:29:42 -05001185 if (ds->ports[i].bridge_dev ==
1186 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001187 break; /* same bridge, check next VLAN */
1188
Vivien Didelotfae8a252017-01-27 15:29:42 -05001189 if (!ds->ports[i].bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001190 continue;
1191
Vivien Didelot774439e52017-06-08 18:34:08 -04001192 dev_err(ds->dev, "p%d: hw VLAN %d already used by %s\n",
1193 port, vlan.vid,
1194 netdev_name(ds->ports[i].bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001195 err = -EOPNOTSUPP;
1196 goto unlock;
1197 }
1198 } while (vlan.vid < vid_end);
1199
1200unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001201 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001202
1203 return err;
1204}
1205
Vivien Didelotf81ec902016-05-09 13:22:58 -04001206static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1207 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001208{
Vivien Didelot04bed142016-08-31 18:06:13 -04001209 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001210 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1211 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001212 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001213
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001214 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001215 return -EOPNOTSUPP;
1216
Vivien Didelotfad09c72016-06-21 12:28:20 -04001217 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001218 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001219 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001220
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001221 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001222}
1223
Vivien Didelot57d32312016-06-20 13:13:58 -04001224static int
1225mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
1226 const struct switchdev_obj_port_vlan *vlan,
1227 struct switchdev_trans *trans)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001228{
Vivien Didelot04bed142016-08-31 18:06:13 -04001229 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001230 int err;
1231
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001232 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001233 return -EOPNOTSUPP;
1234
Vivien Didelotda9c3592016-02-12 12:09:40 -05001235 /* If the requested port doesn't belong to the same bridge as the VLAN
1236 * members, do not support it (yet) and fallback to software VLAN.
1237 */
1238 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1239 vlan->vid_end);
1240 if (err)
1241 return err;
1242
Vivien Didelot76e398a2015-11-01 12:33:55 -05001243 /* We don't need any dynamic resource from the kernel (yet),
1244 * so skip the prepare phase.
1245 */
1246 return 0;
1247}
1248
Vivien Didelotfad09c72016-06-21 12:28:20 -04001249static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001250 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001251{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001252 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001253 int err;
1254
Vivien Didelot567aa592017-05-01 14:05:25 -04001255 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001256 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001257 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001258
Vivien Didelotc91498e2017-06-07 18:12:13 -04001259 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001260
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001261 return mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001262}
1263
Vivien Didelotf81ec902016-05-09 13:22:58 -04001264static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
1265 const struct switchdev_obj_port_vlan *vlan,
1266 struct switchdev_trans *trans)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001267{
Vivien Didelot04bed142016-08-31 18:06:13 -04001268 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001269 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1270 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001271 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001272 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001273
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001274 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001275 return;
1276
Vivien Didelotc91498e2017-06-07 18:12:13 -04001277 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001278 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001279 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001280 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001281 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001282 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001283
Vivien Didelotfad09c72016-06-21 12:28:20 -04001284 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001285
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001286 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001287 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001288 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1289 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001290
Vivien Didelot77064f32016-11-04 03:23:30 +01001291 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001292 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1293 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001294
Vivien Didelotfad09c72016-06-21 12:28:20 -04001295 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001296}
1297
Vivien Didelotfad09c72016-06-21 12:28:20 -04001298static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001299 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001300{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001301 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001302 int i, err;
1303
Vivien Didelot567aa592017-05-01 14:05:25 -04001304 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001305 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001306 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001307
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001308 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001309 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001310 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001311
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001312 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001313
1314 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001315 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001316 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001317 if (vlan.member[i] !=
1318 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001319 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001320 break;
1321 }
1322 }
1323
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001324 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001325 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001326 return err;
1327
Vivien Didelote606ca32017-03-11 16:12:55 -05001328 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001329}
1330
Vivien Didelotf81ec902016-05-09 13:22:58 -04001331static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1332 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001333{
Vivien Didelot04bed142016-08-31 18:06:13 -04001334 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001335 u16 pvid, vid;
1336 int err = 0;
1337
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001338 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001339 return -EOPNOTSUPP;
1340
Vivien Didelotfad09c72016-06-21 12:28:20 -04001341 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001342
Vivien Didelot77064f32016-11-04 03:23:30 +01001343 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001344 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001345 goto unlock;
1346
Vivien Didelot76e398a2015-11-01 12:33:55 -05001347 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001348 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001349 if (err)
1350 goto unlock;
1351
1352 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001353 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001354 if (err)
1355 goto unlock;
1356 }
1357 }
1358
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001359unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001360 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001361
1362 return err;
1363}
1364
Vivien Didelot83dabd12016-08-31 11:50:04 -04001365static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1366 const unsigned char *addr, u16 vid,
1367 u8 state)
Vivien Didelotfd231c82015-08-10 09:09:50 -04001368{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001369 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot88472932016-09-19 19:56:11 -04001370 struct mv88e6xxx_atu_entry entry;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001371 int err;
Vivien Didelotfd231c82015-08-10 09:09:50 -04001372
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001373 /* Null VLAN ID corresponds to the port private database */
1374 if (vid == 0)
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001375 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001376 else
Vivien Didelot567aa592017-05-01 14:05:25 -04001377 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001378 if (err)
1379 return err;
1380
Vivien Didelot27c0e602017-06-15 12:14:01 -04001381 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001382 ether_addr_copy(entry.mac, addr);
1383 eth_addr_dec(entry.mac);
1384
1385 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
Vivien Didelot88472932016-09-19 19:56:11 -04001386 if (err)
1387 return err;
1388
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001389 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelot27c0e602017-06-15 12:14:01 -04001390 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001391 !ether_addr_equal(entry.mac, addr)) {
1392 memset(&entry, 0, sizeof(entry));
1393 ether_addr_copy(entry.mac, addr);
1394 }
1395
Vivien Didelot88472932016-09-19 19:56:11 -04001396 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelot27c0e602017-06-15 12:14:01 -04001397 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001398 entry.portvec &= ~BIT(port);
1399 if (!entry.portvec)
Vivien Didelot27c0e602017-06-15 12:14:01 -04001400 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelot88472932016-09-19 19:56:11 -04001401 } else {
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001402 entry.portvec |= BIT(port);
Vivien Didelot88472932016-09-19 19:56:11 -04001403 entry.state = state;
Vivien Didelotfd231c82015-08-10 09:09:50 -04001404 }
1405
Vivien Didelot9c13c022017-03-11 16:12:52 -05001406 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001407}
1408
Vivien Didelotf81ec902016-05-09 13:22:58 -04001409static int mv88e6xxx_port_fdb_prepare(struct dsa_switch *ds, int port,
1410 const struct switchdev_obj_port_fdb *fdb,
1411 struct switchdev_trans *trans)
Vivien Didelot146a3202015-10-08 11:35:12 -04001412{
1413 /* We don't need any dynamic resource from the kernel (yet),
1414 * so skip the prepare phase.
1415 */
1416 return 0;
1417}
1418
Vivien Didelotf81ec902016-05-09 13:22:58 -04001419static void mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1420 const struct switchdev_obj_port_fdb *fdb,
1421 struct switchdev_trans *trans)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001422{
Vivien Didelot04bed142016-08-31 18:06:13 -04001423 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot6630e232015-08-06 01:44:07 -04001424
Vivien Didelotfad09c72016-06-21 12:28:20 -04001425 mutex_lock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001426 if (mv88e6xxx_port_db_load_purge(chip, port, fdb->addr, fdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001427 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04001428 dev_err(ds->dev, "p%d: failed to load unicast MAC address\n",
1429 port);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001430 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001431}
1432
Vivien Didelotf81ec902016-05-09 13:22:58 -04001433static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
1434 const struct switchdev_obj_port_fdb *fdb)
David S. Millercdf09692015-08-11 12:00:37 -07001435{
Vivien Didelot04bed142016-08-31 18:06:13 -04001436 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001437 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001438
Vivien Didelotfad09c72016-06-21 12:28:20 -04001439 mutex_lock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001440 err = mv88e6xxx_port_db_load_purge(chip, port, fdb->addr, fdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001441 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001442 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001443
Vivien Didelot83dabd12016-08-31 11:50:04 -04001444 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001445}
1446
Vivien Didelot83dabd12016-08-31 11:50:04 -04001447static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1448 u16 fid, u16 vid, int port,
1449 struct switchdev_obj *obj,
Vivien Didelot438ff532017-05-17 15:46:05 -04001450 switchdev_obj_dump_cb_t *cb)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001451{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001452 struct mv88e6xxx_atu_entry addr;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001453 int err;
1454
Vivien Didelot27c0e602017-06-15 12:14:01 -04001455 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001456 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001457
1458 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001459 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001460 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001461 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001462
Vivien Didelot27c0e602017-06-15 12:14:01 -04001463 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001464 break;
1465
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001466 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001467 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001468
Vivien Didelot83dabd12016-08-31 11:50:04 -04001469 if (obj->id == SWITCHDEV_OBJ_ID_PORT_FDB) {
1470 struct switchdev_obj_port_fdb *fdb;
1471
1472 if (!is_unicast_ether_addr(addr.mac))
1473 continue;
1474
1475 fdb = SWITCHDEV_OBJ_PORT_FDB(obj);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001476 fdb->vid = vid;
1477 ether_addr_copy(fdb->addr, addr.mac);
Vivien Didelot27c0e602017-06-15 12:14:01 -04001478 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001479 fdb->ndm_state = NUD_NOARP;
1480 else
1481 fdb->ndm_state = NUD_REACHABLE;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04001482 } else if (obj->id == SWITCHDEV_OBJ_ID_PORT_MDB) {
1483 struct switchdev_obj_port_mdb *mdb;
1484
1485 if (!is_multicast_ether_addr(addr.mac))
1486 continue;
1487
1488 mdb = SWITCHDEV_OBJ_PORT_MDB(obj);
1489 mdb->vid = vid;
1490 ether_addr_copy(mdb->addr, addr.mac);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001491 } else {
1492 return -EOPNOTSUPP;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001493 }
Vivien Didelot83dabd12016-08-31 11:50:04 -04001494
1495 err = cb(obj);
1496 if (err)
1497 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001498 } while (!is_broadcast_ether_addr(addr.mac));
1499
1500 return err;
1501}
1502
Vivien Didelot83dabd12016-08-31 11:50:04 -04001503static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
1504 struct switchdev_obj *obj,
Vivien Didelot438ff532017-05-17 15:46:05 -04001505 switchdev_obj_dump_cb_t *cb)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001506{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001507 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001508 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001509 };
1510 u16 fid;
1511 int err;
1512
1513 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001514 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001515 if (err)
1516 return err;
1517
1518 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, obj, cb);
1519 if (err)
1520 return err;
1521
1522 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001523 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001524 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001525 if (err)
1526 return err;
1527
1528 if (!vlan.valid)
1529 break;
1530
1531 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
1532 obj, cb);
1533 if (err)
1534 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001535 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001536
1537 return err;
1538}
1539
Vivien Didelotf81ec902016-05-09 13:22:58 -04001540static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
1541 struct switchdev_obj_port_fdb *fdb,
Vivien Didelot438ff532017-05-17 15:46:05 -04001542 switchdev_obj_dump_cb_t *cb)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001543{
Vivien Didelot04bed142016-08-31 18:06:13 -04001544 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001545 int err;
1546
Vivien Didelotfad09c72016-06-21 12:28:20 -04001547 mutex_lock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001548 err = mv88e6xxx_port_db_dump(chip, port, &fdb->obj, cb);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001549 mutex_unlock(&chip->reg_lock);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001550
1551 return err;
1552}
1553
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001554static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1555 struct net_device *br)
1556{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001557 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001558 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001559 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001560 int err;
1561
1562 /* Remap the Port VLAN of each local bridge group member */
1563 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1564 if (chip->ds->ports[port].bridge_dev == br) {
1565 err = mv88e6xxx_port_vlan_map(chip, port);
1566 if (err)
1567 return err;
1568 }
1569 }
1570
Vivien Didelote96a6e02017-03-30 17:37:13 -04001571 if (!mv88e6xxx_has_pvt(chip))
1572 return 0;
1573
1574 /* Remap the Port VLAN of each cross-chip bridge group member */
1575 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1576 ds = chip->ds->dst->ds[dev];
1577 if (!ds)
1578 break;
1579
1580 for (port = 0; port < ds->num_ports; ++port) {
1581 if (ds->ports[port].bridge_dev == br) {
1582 err = mv88e6xxx_pvt_map(chip, dev, port);
1583 if (err)
1584 return err;
1585 }
1586 }
1587 }
1588
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001589 return 0;
1590}
1591
Vivien Didelotf81ec902016-05-09 13:22:58 -04001592static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001593 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001594{
Vivien Didelot04bed142016-08-31 18:06:13 -04001595 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001596 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001597
Vivien Didelotfad09c72016-06-21 12:28:20 -04001598 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001599 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001600 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001601
Vivien Didelot466dfa02016-02-26 13:16:05 -05001602 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001603}
1604
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001605static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1606 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001607{
Vivien Didelot04bed142016-08-31 18:06:13 -04001608 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001609
Vivien Didelotfad09c72016-06-21 12:28:20 -04001610 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001611 if (mv88e6xxx_bridge_map(chip, br) ||
1612 mv88e6xxx_port_vlan_map(chip, port))
1613 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001614 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001615}
1616
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001617static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1618 int port, struct net_device *br)
1619{
1620 struct mv88e6xxx_chip *chip = ds->priv;
1621 int err;
1622
1623 if (!mv88e6xxx_has_pvt(chip))
1624 return 0;
1625
1626 mutex_lock(&chip->reg_lock);
1627 err = mv88e6xxx_pvt_map(chip, dev, port);
1628 mutex_unlock(&chip->reg_lock);
1629
1630 return err;
1631}
1632
1633static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1634 int port, struct net_device *br)
1635{
1636 struct mv88e6xxx_chip *chip = ds->priv;
1637
1638 if (!mv88e6xxx_has_pvt(chip))
1639 return;
1640
1641 mutex_lock(&chip->reg_lock);
1642 if (mv88e6xxx_pvt_map(chip, dev, port))
1643 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1644 mutex_unlock(&chip->reg_lock);
1645}
1646
Vivien Didelot17e708b2016-12-05 17:30:27 -05001647static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1648{
1649 if (chip->info->ops->reset)
1650 return chip->info->ops->reset(chip);
1651
1652 return 0;
1653}
1654
Vivien Didelot309eca62016-12-05 17:30:26 -05001655static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1656{
1657 struct gpio_desc *gpiod = chip->reset;
1658
1659 /* If there is a GPIO connected to the reset pin, toggle it */
1660 if (gpiod) {
1661 gpiod_set_value_cansleep(gpiod, 1);
1662 usleep_range(10000, 20000);
1663 gpiod_set_value_cansleep(gpiod, 0);
1664 usleep_range(10000, 20000);
1665 }
1666}
1667
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001668static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1669{
1670 int i, err;
1671
1672 /* Set all ports to the Disabled state */
1673 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001674 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001675 if (err)
1676 return err;
1677 }
1678
1679 /* Wait for transmit queues to drain,
1680 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1681 */
1682 usleep_range(2000, 4000);
1683
1684 return 0;
1685}
1686
Vivien Didelotfad09c72016-06-21 12:28:20 -04001687static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001688{
Vivien Didelota935c052016-09-29 12:21:53 -04001689 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001690
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001691 err = mv88e6xxx_disable_ports(chip);
1692 if (err)
1693 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001694
Vivien Didelot309eca62016-12-05 17:30:26 -05001695 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001696
Vivien Didelot17e708b2016-12-05 17:30:27 -05001697 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001698}
1699
Vivien Didelot43145572017-03-11 16:12:59 -05001700static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001701 enum mv88e6xxx_frame_mode frame,
1702 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001703{
1704 int err;
1705
Vivien Didelot43145572017-03-11 16:12:59 -05001706 if (!chip->info->ops->port_set_frame_mode)
1707 return -EOPNOTSUPP;
1708
1709 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001710 if (err)
1711 return err;
1712
Vivien Didelot43145572017-03-11 16:12:59 -05001713 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1714 if (err)
1715 return err;
1716
1717 if (chip->info->ops->port_set_ether_type)
1718 return chip->info->ops->port_set_ether_type(chip, port, etype);
1719
1720 return 0;
1721}
1722
1723static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1724{
1725 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001726 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001727 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001728}
1729
1730static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1731{
1732 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001733 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001734 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001735}
1736
1737static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1738{
1739 return mv88e6xxx_set_port_mode(chip, port,
1740 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001741 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1742 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001743}
1744
1745static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1746{
1747 if (dsa_is_dsa_port(chip->ds, port))
1748 return mv88e6xxx_set_port_mode_dsa(chip, port);
1749
1750 if (dsa_is_normal_port(chip->ds, port))
1751 return mv88e6xxx_set_port_mode_normal(chip, port);
1752
1753 /* Setup CPU port mode depending on its supported tag format */
1754 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1755 return mv88e6xxx_set_port_mode_dsa(chip, port);
1756
1757 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1758 return mv88e6xxx_set_port_mode_edsa(chip, port);
1759
1760 return -EINVAL;
1761}
1762
Vivien Didelotea698f42017-03-11 16:12:50 -05001763static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1764{
1765 bool message = dsa_is_dsa_port(chip->ds, port);
1766
1767 return mv88e6xxx_port_set_message_port(chip, port, message);
1768}
1769
Vivien Didelot601aeed2017-03-11 16:13:00 -05001770static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1771{
1772 bool flood = port == dsa_upstream_port(chip->ds);
1773
1774 /* Upstream ports flood frames with unknown unicast or multicast DA */
1775 if (chip->info->ops->port_set_egress_floods)
1776 return chip->info->ops->port_set_egress_floods(chip, port,
1777 flood, flood);
1778
1779 return 0;
1780}
1781
Andrew Lunn6d917822017-05-26 01:03:21 +02001782static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1783 bool on)
1784{
Vivien Didelot523a8902017-05-26 18:02:42 -04001785 if (chip->info->ops->serdes_power)
1786 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001787
Vivien Didelot523a8902017-05-26 18:02:42 -04001788 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001789}
1790
Vivien Didelotfad09c72016-06-21 12:28:20 -04001791static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001792{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001793 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001794 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001795 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001796
Vivien Didelotd78343d2016-11-04 03:23:36 +01001797 /* MAC Forcing register: don't force link, speed, duplex or flow control
1798 * state to any particular values on physical ports, but force the CPU
1799 * port and all DSA ports to their maximum bandwidth and full duplex.
1800 */
1801 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1802 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1803 SPEED_MAX, DUPLEX_FULL,
1804 PHY_INTERFACE_MODE_NA);
1805 else
1806 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1807 SPEED_UNFORCED, DUPLEX_UNFORCED,
1808 PHY_INTERFACE_MODE_NA);
1809 if (err)
1810 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001811
1812 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1813 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1814 * tunneling, determine priority by looking at 802.1p and IP
1815 * priority fields (IP prio has precedence), and set STP state
1816 * to Forwarding.
1817 *
1818 * If this is the CPU link, use DSA or EDSA tagging depending
1819 * on which tagging mode was configured.
1820 *
1821 * If this is a link to another switch, use DSA tagging mode.
1822 *
1823 * If this is the upstream port for this switch, enable
1824 * forwarding of unknown unicasts and multicasts.
1825 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001826 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1827 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1828 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1829 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001830 if (err)
1831 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001832
Vivien Didelot601aeed2017-03-11 16:13:00 -05001833 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001834 if (err)
1835 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001836
Vivien Didelot601aeed2017-03-11 16:13:00 -05001837 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001838 if (err)
1839 return err;
1840
Andrew Lunn04aca992017-05-26 01:03:24 +02001841 /* Enable the SERDES interface for DSA and CPU ports. Normal
1842 * ports SERDES are enabled when the port is enabled, thus
1843 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001844 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001845 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1846 err = mv88e6xxx_serdes_power(chip, port, true);
1847 if (err)
1848 return err;
1849 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001850
Vivien Didelot8efdda42015-08-13 12:52:23 -04001851 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001852 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001853 * untagged frames on this port, do a destination address lookup on all
1854 * received packets as usual, disable ARP mirroring and don't send a
1855 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001856 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001857 err = mv88e6xxx_port_set_map_da(chip, port);
1858 if (err)
1859 return err;
1860
Andrew Lunn54d792f2015-05-06 01:09:47 +02001861 reg = 0;
Andrew Lunna23b2962017-02-04 20:15:28 +01001862 if (chip->info->ops->port_set_upstream_port) {
1863 err = chip->info->ops->port_set_upstream_port(
1864 chip, port, dsa_upstream_port(ds));
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001865 if (err)
1866 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001867 }
1868
Andrew Lunna23b2962017-02-04 20:15:28 +01001869 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001870 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001871 if (err)
1872 return err;
1873
Vivien Didelotcd782652017-06-08 18:34:13 -04001874 if (chip->info->ops->port_set_jumbo_size) {
1875 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001876 if (err)
1877 return err;
1878 }
1879
Andrew Lunn54d792f2015-05-06 01:09:47 +02001880 /* Port Association Vector: when learning source addresses
1881 * of packets, add the address to the address database using
1882 * a port bitmap that has only the bit for this port set and
1883 * the other bits clear.
1884 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001885 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001886 /* Disable learning for CPU port */
1887 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001888 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001889
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001890 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1891 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001892 if (err)
1893 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001894
1895 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001896 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1897 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001898 if (err)
1899 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001900
Vivien Didelot08984322017-06-08 18:34:12 -04001901 if (chip->info->ops->port_pause_limit) {
1902 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001903 if (err)
1904 return err;
1905 }
1906
Vivien Didelotc8c94892017-03-11 16:13:01 -05001907 if (chip->info->ops->port_disable_learn_limit) {
1908 err = chip->info->ops->port_disable_learn_limit(chip, port);
1909 if (err)
1910 return err;
1911 }
1912
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001913 if (chip->info->ops->port_disable_pri_override) {
1914 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001915 if (err)
1916 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001917 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001918
Andrew Lunnef0a7312016-12-03 04:35:16 +01001919 if (chip->info->ops->port_tag_remap) {
1920 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001921 if (err)
1922 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001923 }
1924
Andrew Lunnef70b112016-12-03 04:45:18 +01001925 if (chip->info->ops->port_egress_rate_limiting) {
1926 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001927 if (err)
1928 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001929 }
1930
Vivien Didelotea698f42017-03-11 16:12:50 -05001931 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001932 if (err)
1933 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001934
Vivien Didelot207afda2016-04-14 14:42:09 -04001935 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001936 * database, and allow bidirectional communication between the
1937 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001938 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001939 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001940 if (err)
1941 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001942
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001943 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001944 if (err)
1945 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001946
1947 /* Default VLAN ID and priority: don't set a default VLAN
1948 * ID, and set the default packet priority to zero.
1949 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04001950 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02001951}
1952
Andrew Lunn04aca992017-05-26 01:03:24 +02001953static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
1954 struct phy_device *phydev)
1955{
1956 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04001957 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02001958
1959 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001960 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02001961 mutex_unlock(&chip->reg_lock);
1962
1963 return err;
1964}
1965
1966static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
1967 struct phy_device *phydev)
1968{
1969 struct mv88e6xxx_chip *chip = ds->priv;
1970
1971 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001972 if (mv88e6xxx_serdes_power(chip, port, false))
1973 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02001974 mutex_unlock(&chip->reg_lock);
1975}
1976
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001977static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
1978 unsigned int ageing_time)
1979{
Vivien Didelot04bed142016-08-31 18:06:13 -04001980 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001981 int err;
1982
1983 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05001984 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001985 mutex_unlock(&chip->reg_lock);
1986
1987 return err;
1988}
1989
Vivien Didelot97299342016-07-18 20:45:30 -04001990static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04001991{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001992 struct dsa_switch *ds = chip->ds;
Vivien Didelotb0745e872016-05-09 13:22:53 -04001993 u32 upstream_port = dsa_upstream_port(ds);
Vivien Didelot08a01262016-05-09 13:22:50 -04001994 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04001995
Vivien Didelotfa8d1172017-06-08 18:34:11 -04001996 if (chip->info->ops->set_cpu_port) {
1997 err = chip->info->ops->set_cpu_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01001998 if (err)
1999 return err;
2000 }
2001
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002002 if (chip->info->ops->set_egress_port) {
2003 err = chip->info->ops->set_egress_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01002004 if (err)
2005 return err;
2006 }
Vivien Didelotb0745e872016-05-09 13:22:53 -04002007
Vivien Didelot50484ff2016-05-09 13:22:54 -04002008 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04002009 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
2010 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04002011 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04002012 if (err)
2013 return err;
2014
Vivien Didelot08a01262016-05-09 13:22:50 -04002015 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002016 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002017 if (err)
2018 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002019 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002020 if (err)
2021 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002022 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002023 if (err)
2024 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002025 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002026 if (err)
2027 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002028 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002029 if (err)
2030 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002031 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002032 if (err)
2033 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002034 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002035 if (err)
2036 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002037 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002038 if (err)
2039 return err;
2040
2041 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002042 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002043 if (err)
2044 return err;
2045
Andrew Lunnde2273872016-11-21 23:27:01 +01002046 /* Initialize the statistics unit */
2047 err = mv88e6xxx_stats_set_histogram(chip);
2048 if (err)
2049 return err;
2050
Vivien Didelot97299342016-07-18 20:45:30 -04002051 /* Clear the statistics counters for all ports */
Vivien Didelot57d1ef32017-06-15 12:14:05 -04002052 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_STATS_OP,
2053 MV88E6XXX_G1_STATS_OP_BUSY |
2054 MV88E6XXX_G1_STATS_OP_FLUSH_ALL);
Vivien Didelot97299342016-07-18 20:45:30 -04002055 if (err)
2056 return err;
2057
2058 /* Wait for the flush to complete. */
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +01002059 err = mv88e6xxx_g1_stats_wait(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002060 if (err)
2061 return err;
2062
2063 return 0;
2064}
2065
Vivien Didelotf81ec902016-05-09 13:22:58 -04002066static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002067{
Vivien Didelot04bed142016-08-31 18:06:13 -04002068 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002069 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002070 int i;
2071
Vivien Didelotfad09c72016-06-21 12:28:20 -04002072 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002073 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002074
Vivien Didelotfad09c72016-06-21 12:28:20 -04002075 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002076
Vivien Didelot97299342016-07-18 20:45:30 -04002077 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002078 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot97299342016-07-18 20:45:30 -04002079 err = mv88e6xxx_setup_port(chip, i);
2080 if (err)
2081 goto unlock;
2082 }
2083
2084 /* Setup Switch Global 1 Registers */
2085 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002086 if (err)
2087 goto unlock;
2088
Vivien Didelot97299342016-07-18 20:45:30 -04002089 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002090 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002091 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002092 if (err)
2093 goto unlock;
2094 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002095
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002096 err = mv88e6xxx_irl_setup(chip);
2097 if (err)
2098 goto unlock;
2099
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002100 err = mv88e6xxx_phy_setup(chip);
2101 if (err)
2102 goto unlock;
2103
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002104 err = mv88e6xxx_vtu_setup(chip);
2105 if (err)
2106 goto unlock;
2107
Vivien Didelot81228992017-03-30 17:37:08 -04002108 err = mv88e6xxx_pvt_setup(chip);
2109 if (err)
2110 goto unlock;
2111
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002112 err = mv88e6xxx_atu_setup(chip);
2113 if (err)
2114 goto unlock;
2115
Vivien Didelot9e907d72017-07-17 13:03:43 -04002116 err = mv88e6xxx_pot_setup(chip);
2117 if (err)
2118 goto unlock;
2119
Vivien Didelot51c901a2017-07-17 13:03:41 -04002120 err = mv88e6xxx_rsvd2cpu_setup(chip);
2121 if (err)
2122 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002123
Vivien Didelot6b17e862015-08-13 12:52:18 -04002124unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002125 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002126
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002127 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002128}
2129
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002130static int mv88e6xxx_set_addr(struct dsa_switch *ds, u8 *addr)
2131{
Vivien Didelot04bed142016-08-31 18:06:13 -04002132 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002133 int err;
2134
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002135 if (!chip->info->ops->set_switch_mac)
2136 return -EOPNOTSUPP;
2137
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002138 mutex_lock(&chip->reg_lock);
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002139 err = chip->info->ops->set_switch_mac(chip, addr);
Vivien Didelot3b4caa12016-07-18 20:45:34 -04002140 mutex_unlock(&chip->reg_lock);
2141
2142 return err;
2143}
2144
Vivien Didelote57e5e72016-08-15 17:19:00 -04002145static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002146{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002147 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2148 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002149 u16 val;
2150 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002151
Andrew Lunnee26a222017-01-24 14:53:48 +01002152 if (!chip->info->ops->phy_read)
2153 return -EOPNOTSUPP;
2154
Vivien Didelotfad09c72016-06-21 12:28:20 -04002155 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002156 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002157 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002158
Andrew Lunnda9f3302017-02-01 03:40:05 +01002159 if (reg == MII_PHYSID2) {
2160 /* Some internal PHYS don't have a model number. Use
2161 * the mv88e6390 family model number instead.
2162 */
2163 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002164 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002165 }
2166
Vivien Didelote57e5e72016-08-15 17:19:00 -04002167 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002168}
2169
Vivien Didelote57e5e72016-08-15 17:19:00 -04002170static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002171{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002172 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2173 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002174 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002175
Andrew Lunnee26a222017-01-24 14:53:48 +01002176 if (!chip->info->ops->phy_write)
2177 return -EOPNOTSUPP;
2178
Vivien Didelotfad09c72016-06-21 12:28:20 -04002179 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002180 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002181 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002182
2183 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002184}
2185
Vivien Didelotfad09c72016-06-21 12:28:20 -04002186static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002187 struct device_node *np,
2188 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002189{
2190 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002191 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002192 struct mii_bus *bus;
2193 int err;
2194
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002195 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002196 if (!bus)
2197 return -ENOMEM;
2198
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002199 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002200 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002201 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002202 INIT_LIST_HEAD(&mdio_bus->list);
2203 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002204
Andrew Lunnb516d452016-06-04 21:17:06 +02002205 if (np) {
2206 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002207 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002208 } else {
2209 bus->name = "mv88e6xxx SMI";
2210 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2211 }
2212
2213 bus->read = mv88e6xxx_mdio_read;
2214 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002215 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002216
Andrew Lunna3c53be52017-01-24 14:53:50 +01002217 if (np)
2218 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002219 else
2220 err = mdiobus_register(bus);
2221 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002222 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002223 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002224 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002225
2226 if (external)
2227 list_add_tail(&mdio_bus->list, &chip->mdios);
2228 else
2229 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002230
2231 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002232}
2233
Andrew Lunna3c53be52017-01-24 14:53:50 +01002234static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2235 { .compatible = "marvell,mv88e6xxx-mdio-external",
2236 .data = (void *)true },
2237 { },
2238};
2239
2240static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2241 struct device_node *np)
2242{
2243 const struct of_device_id *match;
2244 struct device_node *child;
2245 int err;
2246
2247 /* Always register one mdio bus for the internal/default mdio
2248 * bus. This maybe represented in the device tree, but is
2249 * optional.
2250 */
2251 child = of_get_child_by_name(np, "mdio");
2252 err = mv88e6xxx_mdio_register(chip, child, false);
2253 if (err)
2254 return err;
2255
2256 /* Walk the device tree, and see if there are any other nodes
2257 * which say they are compatible with the external mdio
2258 * bus.
2259 */
2260 for_each_available_child_of_node(np, child) {
2261 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2262 if (match) {
2263 err = mv88e6xxx_mdio_register(chip, child, true);
2264 if (err)
2265 return err;
2266 }
2267 }
2268
2269 return 0;
2270}
2271
2272static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
Andrew Lunnb516d452016-06-04 21:17:06 +02002273
2274{
Andrew Lunna3c53be52017-01-24 14:53:50 +01002275 struct mv88e6xxx_mdio_bus *mdio_bus;
2276 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002277
Andrew Lunna3c53be52017-01-24 14:53:50 +01002278 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2279 bus = mdio_bus->bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002280
Andrew Lunna3c53be52017-01-24 14:53:50 +01002281 mdiobus_unregister(bus);
2282 }
Andrew Lunnb516d452016-06-04 21:17:06 +02002283}
2284
Vivien Didelot855b1932016-07-20 18:18:35 -04002285static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2286{
Vivien Didelot04bed142016-08-31 18:06:13 -04002287 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002288
2289 return chip->eeprom_len;
2290}
2291
Vivien Didelot855b1932016-07-20 18:18:35 -04002292static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2293 struct ethtool_eeprom *eeprom, u8 *data)
2294{
Vivien Didelot04bed142016-08-31 18:06:13 -04002295 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002296 int err;
2297
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002298 if (!chip->info->ops->get_eeprom)
2299 return -EOPNOTSUPP;
2300
Vivien Didelot855b1932016-07-20 18:18:35 -04002301 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002302 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002303 mutex_unlock(&chip->reg_lock);
2304
2305 if (err)
2306 return err;
2307
2308 eeprom->magic = 0xc3ec4951;
2309
2310 return 0;
2311}
2312
Vivien Didelot855b1932016-07-20 18:18:35 -04002313static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2314 struct ethtool_eeprom *eeprom, u8 *data)
2315{
Vivien Didelot04bed142016-08-31 18:06:13 -04002316 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002317 int err;
2318
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002319 if (!chip->info->ops->set_eeprom)
2320 return -EOPNOTSUPP;
2321
Vivien Didelot855b1932016-07-20 18:18:35 -04002322 if (eeprom->magic != 0xc3ec4951)
2323 return -EINVAL;
2324
2325 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002326 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002327 mutex_unlock(&chip->reg_lock);
2328
2329 return err;
2330}
2331
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002332static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002333 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002334 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002335 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002336 .phy_read = mv88e6185_phy_ppu_read,
2337 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002338 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002339 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002340 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002341 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002342 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002343 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002344 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002345 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002346 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002347 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002348 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002349 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002350 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2351 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002352 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002353 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2354 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002355 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002356 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002357 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002358 .ppu_enable = mv88e6185_g1_ppu_enable,
2359 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002360 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002361 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002362 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002363};
2364
2365static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002366 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002367 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002368 .phy_read = mv88e6185_phy_ppu_read,
2369 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002370 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002371 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002372 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002373 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002374 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002375 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002376 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002377 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2378 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002379 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002380 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002381 .ppu_enable = mv88e6185_g1_ppu_enable,
2382 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002383 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002384 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002385 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002386};
2387
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002388static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002389 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002390 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002391 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2392 .phy_read = mv88e6xxx_g2_smi_phy_read,
2393 .phy_write = mv88e6xxx_g2_smi_phy_write,
2394 .port_set_link = mv88e6xxx_port_set_link,
2395 .port_set_duplex = mv88e6xxx_port_set_duplex,
2396 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002397 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002398 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002399 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002400 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002401 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002402 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002403 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002404 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002405 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002406 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
2407 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2408 .stats_get_strings = mv88e6095_stats_get_strings,
2409 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002410 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2411 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002412 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002413 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002414 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002415 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002416 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002417 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002418};
2419
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002420static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002421 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002422 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002423 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002424 .phy_read = mv88e6xxx_g2_smi_phy_read,
2425 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002426 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002427 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002428 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002429 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002430 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002431 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002432 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002433 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002434 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2435 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002436 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002437 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2438 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002439 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002440 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002441 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002442 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002443 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002444 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002445};
2446
2447static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002448 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002449 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002450 .phy_read = mv88e6185_phy_ppu_read,
2451 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002452 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002453 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002454 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002455 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002456 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002457 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002458 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002459 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002460 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002461 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002462 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002463 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002464 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2465 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002466 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002467 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2468 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002469 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002470 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002471 .ppu_enable = mv88e6185_g1_ppu_enable,
2472 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002473 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002474 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002475 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002476};
2477
Vivien Didelot990e27b2017-03-28 13:50:32 -04002478static const struct mv88e6xxx_ops mv88e6141_ops = {
2479 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002480 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002481 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2482 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2483 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2484 .phy_read = mv88e6xxx_g2_smi_phy_read,
2485 .phy_write = mv88e6xxx_g2_smi_phy_write,
2486 .port_set_link = mv88e6xxx_port_set_link,
2487 .port_set_duplex = mv88e6xxx_port_set_duplex,
2488 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2489 .port_set_speed = mv88e6390_port_set_speed,
2490 .port_tag_remap = mv88e6095_port_tag_remap,
2491 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2492 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2493 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002494 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002495 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002496 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002497 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2498 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2499 .stats_snapshot = mv88e6390_g1_stats_snapshot,
2500 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2501 .stats_get_strings = mv88e6320_stats_get_strings,
2502 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002503 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2504 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002505 .watchdog_ops = &mv88e6390_watchdog_ops,
2506 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002507 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002508 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002509 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002510 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002511};
2512
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002513static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002514 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002515 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002516 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002517 .phy_read = mv88e6xxx_g2_smi_phy_read,
2518 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002519 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002520 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002521 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002522 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002523 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002524 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002525 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002526 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002527 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002528 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002529 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002530 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002531 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002532 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2533 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002534 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002535 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2536 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002537 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002538 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002539 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002540 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002541 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002542 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002543};
2544
2545static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002546 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002547 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002548 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002549 .phy_read = mv88e6165_phy_read,
2550 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002551 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002552 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002553 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002554 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002555 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002556 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002557 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2558 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002559 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002560 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2561 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002562 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002563 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002564 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002565 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002566 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002567 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002568};
2569
2570static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002571 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002572 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002573 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002574 .phy_read = mv88e6xxx_g2_smi_phy_read,
2575 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002576 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002577 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002578 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002579 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002580 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002581 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002582 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002583 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002584 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002585 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002586 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002587 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002588 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002589 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002590 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2591 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002592 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002593 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2594 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002595 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002596 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002597 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002598 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002599 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002600 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002601};
2602
2603static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002604 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002605 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002606 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2607 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002608 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002609 .phy_read = mv88e6xxx_g2_smi_phy_read,
2610 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002611 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002612 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002613 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002614 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002615 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002616 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002617 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002618 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002619 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002620 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002621 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002622 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002623 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002624 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002625 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2626 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002627 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002628 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2629 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002630 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002631 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002632 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002633 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002634 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002635 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002636 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002637};
2638
2639static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002640 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002641 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002642 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002643 .phy_read = mv88e6xxx_g2_smi_phy_read,
2644 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002645 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002646 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002647 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002648 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002649 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002650 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002651 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002652 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002653 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002654 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002655 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002656 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002657 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002658 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002659 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2660 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002661 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002662 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2663 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002664 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002665 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002666 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002667 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002668 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002669 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002670};
2671
2672static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002673 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002674 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002675 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2676 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002677 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002678 .phy_read = mv88e6xxx_g2_smi_phy_read,
2679 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002680 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002681 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002682 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002683 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002684 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002685 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002686 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002687 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002688 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002689 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002690 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002691 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002692 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002693 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002694 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2695 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002696 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002697 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2698 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002699 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002700 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002701 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002702 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002703 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002704 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002705 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002706};
2707
2708static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002709 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002710 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002711 .phy_read = mv88e6185_phy_ppu_read,
2712 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002713 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002714 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002715 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002716 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002717 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002718 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002719 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002720 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002721 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2722 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002723 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002724 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2725 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002726 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002727 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002728 .ppu_enable = mv88e6185_g1_ppu_enable,
2729 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002730 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002731 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002732 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002733};
2734
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002735static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002736 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002737 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002738 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2739 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002740 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2741 .phy_read = mv88e6xxx_g2_smi_phy_read,
2742 .phy_write = mv88e6xxx_g2_smi_phy_write,
2743 .port_set_link = mv88e6xxx_port_set_link,
2744 .port_set_duplex = mv88e6xxx_port_set_duplex,
2745 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2746 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002747 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002748 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002749 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002750 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002751 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002752 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002753 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002754 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002755 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002756 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2757 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002758 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002759 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2760 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002761 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002762 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002763 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002764 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002765 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2766 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002767 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002768};
2769
2770static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002771 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002772 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002773 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2774 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002775 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2776 .phy_read = mv88e6xxx_g2_smi_phy_read,
2777 .phy_write = mv88e6xxx_g2_smi_phy_write,
2778 .port_set_link = mv88e6xxx_port_set_link,
2779 .port_set_duplex = mv88e6xxx_port_set_duplex,
2780 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2781 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002782 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002783 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002784 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002785 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002786 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002787 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002788 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002789 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002790 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002791 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2792 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002793 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002794 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2795 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002796 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002797 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002798 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002799 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002800 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2801 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002802 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002803};
2804
2805static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002806 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002807 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002808 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2809 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002810 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2811 .phy_read = mv88e6xxx_g2_smi_phy_read,
2812 .phy_write = mv88e6xxx_g2_smi_phy_write,
2813 .port_set_link = mv88e6xxx_port_set_link,
2814 .port_set_duplex = mv88e6xxx_port_set_duplex,
2815 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2816 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002817 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002818 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002819 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002820 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002821 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002822 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002823 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002824 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002825 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002826 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2827 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002828 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002829 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2830 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002831 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002832 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002833 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002834 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002835 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2836 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002837 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002838};
2839
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002840static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002841 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002842 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002843 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2844 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002845 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002846 .phy_read = mv88e6xxx_g2_smi_phy_read,
2847 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002848 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002849 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002850 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002851 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002852 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002853 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002854 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002855 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002856 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002857 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002858 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002859 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002860 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002861 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002862 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2863 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002864 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002865 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2866 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002867 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002868 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002869 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002870 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002871 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002872 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002873 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002874};
2875
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002876static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002877 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002878 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002879 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2880 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002881 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2882 .phy_read = mv88e6xxx_g2_smi_phy_read,
2883 .phy_write = mv88e6xxx_g2_smi_phy_write,
2884 .port_set_link = mv88e6xxx_port_set_link,
2885 .port_set_duplex = mv88e6xxx_port_set_duplex,
2886 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2887 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002888 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002889 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002890 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002891 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002892 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002893 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002894 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002895 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002896 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002897 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002898 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2899 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002900 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002901 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2902 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002903 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002904 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002905 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002906 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002907 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2908 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002909 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002910};
2911
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002912static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002913 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002914 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002915 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2916 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002917 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002918 .phy_read = mv88e6xxx_g2_smi_phy_read,
2919 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002920 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002921 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002922 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002923 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002924 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002925 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002926 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002927 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002928 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002929 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002930 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002931 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002932 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002933 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2934 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002935 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002936 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2937 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002938 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002939 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002940 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002941 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002942 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002943};
2944
2945static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04002946 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002947 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002948 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2949 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002950 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002951 .phy_read = mv88e6xxx_g2_smi_phy_read,
2952 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002953 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002954 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002955 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002956 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002957 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002958 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002959 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002960 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002961 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002962 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002963 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002964 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002965 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002966 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2967 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002968 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002969 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2970 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002971 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002972 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002973 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002974};
2975
Vivien Didelot16e329a2017-03-28 13:50:33 -04002976static const struct mv88e6xxx_ops mv88e6341_ops = {
2977 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002978 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002979 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2980 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2981 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2982 .phy_read = mv88e6xxx_g2_smi_phy_read,
2983 .phy_write = mv88e6xxx_g2_smi_phy_write,
2984 .port_set_link = mv88e6xxx_port_set_link,
2985 .port_set_duplex = mv88e6xxx_port_set_duplex,
2986 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2987 .port_set_speed = mv88e6390_port_set_speed,
2988 .port_tag_remap = mv88e6095_port_tag_remap,
2989 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2990 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2991 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002992 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002993 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002994 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002995 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2996 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2997 .stats_snapshot = mv88e6390_g1_stats_snapshot,
2998 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2999 .stats_get_strings = mv88e6320_stats_get_strings,
3000 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003001 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3002 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003003 .watchdog_ops = &mv88e6390_watchdog_ops,
3004 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003005 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003006 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003007 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003008 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003009};
3010
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003011static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003012 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003013 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003014 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003015 .phy_read = mv88e6xxx_g2_smi_phy_read,
3016 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003017 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003018 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003019 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003020 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003021 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003022 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003023 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003024 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003025 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003026 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003027 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003028 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003029 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003030 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01003031 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3032 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003033 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003034 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3035 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003036 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003037 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003038 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003039 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003040 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003041 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003042};
3043
3044static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003045 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003046 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003047 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003048 .phy_read = mv88e6xxx_g2_smi_phy_read,
3049 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003050 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003051 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003052 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003053 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003054 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003055 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003056 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003057 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003058 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003059 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003060 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003061 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003062 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003063 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01003064 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3065 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003066 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003067 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3068 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003069 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003070 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003071 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003072 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003073 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003074 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003075};
3076
3077static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003078 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003079 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003080 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3081 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003082 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003083 .phy_read = mv88e6xxx_g2_smi_phy_read,
3084 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003085 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003086 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003087 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003088 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003089 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003090 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003091 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003092 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003093 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003094 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003095 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003096 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003097 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003098 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01003099 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3100 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003101 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003102 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3103 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003104 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003105 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003106 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003107 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003108 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003109 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003110 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003111};
3112
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003113static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003114 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003115 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003116 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3117 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003118 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3119 .phy_read = mv88e6xxx_g2_smi_phy_read,
3120 .phy_write = mv88e6xxx_g2_smi_phy_write,
3121 .port_set_link = mv88e6xxx_port_set_link,
3122 .port_set_duplex = mv88e6xxx_port_set_duplex,
3123 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3124 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003125 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003126 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003127 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003128 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003129 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003130 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003131 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003132 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003133 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003134 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003135 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003136 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003137 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3138 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003139 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003140 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3141 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003142 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003143 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003144 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003145 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003146 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3147 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003148 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003149};
3150
3151static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003152 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003153 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003154 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3155 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003156 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3157 .phy_read = mv88e6xxx_g2_smi_phy_read,
3158 .phy_write = mv88e6xxx_g2_smi_phy_write,
3159 .port_set_link = mv88e6xxx_port_set_link,
3160 .port_set_duplex = mv88e6xxx_port_set_duplex,
3161 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3162 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003163 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003164 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003165 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003166 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003167 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003168 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003169 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003170 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003171 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003172 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003173 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003174 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003175 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3176 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003177 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003178 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3179 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003180 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003181 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003182 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003183 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003184 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3185 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003186 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003187};
3188
Vivien Didelotf81ec902016-05-09 13:22:58 -04003189static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3190 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003191 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003192 .family = MV88E6XXX_FAMILY_6097,
3193 .name = "Marvell 88E6085",
3194 .num_databases = 4096,
3195 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003196 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003197 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003198 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003199 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003200 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003201 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003202 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003203 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003204 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003205 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003206 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003207 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003208 },
3209
3210 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003211 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003212 .family = MV88E6XXX_FAMILY_6095,
3213 .name = "Marvell 88E6095/88E6095F",
3214 .num_databases = 256,
3215 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003216 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003217 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003218 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003219 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003220 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003221 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003222 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003223 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003224 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003225 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003226 },
3227
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003228 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003229 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003230 .family = MV88E6XXX_FAMILY_6097,
3231 .name = "Marvell 88E6097/88E6097F",
3232 .num_databases = 4096,
3233 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003234 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003235 .port_base_addr = 0x10,
3236 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003237 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003238 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003239 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003240 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003241 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003242 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003243 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003244 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003245 .ops = &mv88e6097_ops,
3246 },
3247
Vivien Didelotf81ec902016-05-09 13:22:58 -04003248 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003249 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003250 .family = MV88E6XXX_FAMILY_6165,
3251 .name = "Marvell 88E6123",
3252 .num_databases = 4096,
3253 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003254 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003255 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003256 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003257 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003258 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003259 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003260 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003261 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003262 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003263 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003264 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003265 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003266 },
3267
3268 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003269 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003270 .family = MV88E6XXX_FAMILY_6185,
3271 .name = "Marvell 88E6131",
3272 .num_databases = 256,
3273 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003274 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003275 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003276 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003277 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003278 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003279 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003280 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003281 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003282 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003283 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003284 },
3285
Vivien Didelot990e27b2017-03-28 13:50:32 -04003286 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003287 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003288 .family = MV88E6XXX_FAMILY_6341,
3289 .name = "Marvell 88E6341",
3290 .num_databases = 4096,
3291 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003292 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003293 .port_base_addr = 0x10,
3294 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003295 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003296 .age_time_coeff = 3750,
3297 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003298 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003299 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003300 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003301 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003302 .ops = &mv88e6141_ops,
3303 },
3304
Vivien Didelotf81ec902016-05-09 13:22:58 -04003305 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003306 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003307 .family = MV88E6XXX_FAMILY_6165,
3308 .name = "Marvell 88E6161",
3309 .num_databases = 4096,
3310 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003311 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003312 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003313 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003314 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003315 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003316 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003317 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003318 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003319 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003320 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003321 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003322 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003323 },
3324
3325 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003326 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003327 .family = MV88E6XXX_FAMILY_6165,
3328 .name = "Marvell 88E6165",
3329 .num_databases = 4096,
3330 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003331 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003332 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003333 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003334 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003335 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003336 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003337 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003338 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003339 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003340 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003341 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003342 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003343 },
3344
3345 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003346 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003347 .family = MV88E6XXX_FAMILY_6351,
3348 .name = "Marvell 88E6171",
3349 .num_databases = 4096,
3350 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003351 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003352 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003353 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003354 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003355 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003356 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003357 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003358 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003359 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003360 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003361 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003362 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003363 },
3364
3365 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003366 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003367 .family = MV88E6XXX_FAMILY_6352,
3368 .name = "Marvell 88E6172",
3369 .num_databases = 4096,
3370 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003371 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003372 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003373 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003374 .global2_addr = 0x1c,
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,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003380 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003381 .tag_protocol = DSA_TAG_PROTO_EDSA,
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 Didelot9069c132017-07-17 13:03:44 -04003394 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003395 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003396 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003397 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003398 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003399 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003400 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003401 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003402 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003403 },
3404
3405 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003406 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003407 .family = MV88E6XXX_FAMILY_6352,
3408 .name = "Marvell 88E6176",
3409 .num_databases = 4096,
3410 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003411 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003412 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003413 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003414 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003415 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003416 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003417 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003418 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003419 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003420 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003421 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003422 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003423 },
3424
3425 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003426 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003427 .family = MV88E6XXX_FAMILY_6185,
3428 .name = "Marvell 88E6185",
3429 .num_databases = 256,
3430 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003431 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003432 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003433 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003434 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003435 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003436 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003437 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003438 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003439 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003440 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003441 },
3442
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003443 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003444 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003445 .family = MV88E6XXX_FAMILY_6390,
3446 .name = "Marvell 88E6190",
3447 .num_databases = 4096,
3448 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003449 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003450 .port_base_addr = 0x0,
3451 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003452 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003453 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003454 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003455 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003456 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003457 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003458 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003459 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003460 .ops = &mv88e6190_ops,
3461 },
3462
3463 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003464 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003465 .family = MV88E6XXX_FAMILY_6390,
3466 .name = "Marvell 88E6190X",
3467 .num_databases = 4096,
3468 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003469 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003470 .port_base_addr = 0x0,
3471 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003472 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003473 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003474 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003475 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003476 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003477 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003478 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003479 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003480 .ops = &mv88e6190x_ops,
3481 },
3482
3483 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003484 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003485 .family = MV88E6XXX_FAMILY_6390,
3486 .name = "Marvell 88E6191",
3487 .num_databases = 4096,
3488 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003489 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003490 .port_base_addr = 0x0,
3491 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003492 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003493 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003494 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003495 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003496 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003497 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003498 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003499 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003500 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003501 },
3502
Vivien Didelotf81ec902016-05-09 13:22:58 -04003503 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003504 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003505 .family = MV88E6XXX_FAMILY_6352,
3506 .name = "Marvell 88E6240",
3507 .num_databases = 4096,
3508 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003509 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003510 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003511 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003512 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003513 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003514 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003515 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003516 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003517 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003518 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003519 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003520 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003521 },
3522
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003523 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003524 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003525 .family = MV88E6XXX_FAMILY_6390,
3526 .name = "Marvell 88E6290",
3527 .num_databases = 4096,
3528 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003529 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003530 .port_base_addr = 0x0,
3531 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003532 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003533 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003534 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003535 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003536 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003537 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003538 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003539 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003540 .ops = &mv88e6290_ops,
3541 },
3542
Vivien Didelotf81ec902016-05-09 13:22:58 -04003543 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003544 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003545 .family = MV88E6XXX_FAMILY_6320,
3546 .name = "Marvell 88E6320",
3547 .num_databases = 4096,
3548 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003549 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003550 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003551 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003552 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003553 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003554 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003555 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003556 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003557 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003558 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003559 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003560 },
3561
3562 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003563 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003564 .family = MV88E6XXX_FAMILY_6320,
3565 .name = "Marvell 88E6321",
3566 .num_databases = 4096,
3567 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003568 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003569 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003570 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003571 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003572 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003573 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003574 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003575 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003576 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003577 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003578 },
3579
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003580 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003581 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003582 .family = MV88E6XXX_FAMILY_6341,
3583 .name = "Marvell 88E6341",
3584 .num_databases = 4096,
3585 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003586 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003587 .port_base_addr = 0x10,
3588 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003589 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003590 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003591 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003592 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003593 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003594 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003595 .tag_protocol = DSA_TAG_PROTO_EDSA,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003596 .ops = &mv88e6341_ops,
3597 },
3598
Vivien Didelotf81ec902016-05-09 13:22:58 -04003599 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003600 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003601 .family = MV88E6XXX_FAMILY_6351,
3602 .name = "Marvell 88E6350",
3603 .num_databases = 4096,
3604 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003605 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003606 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003607 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003608 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003609 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003610 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003611 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003612 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003613 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003614 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003615 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003616 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003617 },
3618
3619 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003620 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003621 .family = MV88E6XXX_FAMILY_6351,
3622 .name = "Marvell 88E6351",
3623 .num_databases = 4096,
3624 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003625 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003626 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003627 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003628 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003629 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003630 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003631 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003632 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003633 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003634 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003635 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003636 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003637 },
3638
3639 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003640 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003641 .family = MV88E6XXX_FAMILY_6352,
3642 .name = "Marvell 88E6352",
3643 .num_databases = 4096,
3644 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003645 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003646 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003647 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003648 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003649 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003650 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003651 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003652 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003653 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003654 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003655 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003656 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003657 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003658 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003659 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003660 .family = MV88E6XXX_FAMILY_6390,
3661 .name = "Marvell 88E6390",
3662 .num_databases = 4096,
3663 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003664 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003665 .port_base_addr = 0x0,
3666 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003667 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003668 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003669 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003670 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003671 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003672 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003673 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003674 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003675 .ops = &mv88e6390_ops,
3676 },
3677 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003678 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003679 .family = MV88E6XXX_FAMILY_6390,
3680 .name = "Marvell 88E6390X",
3681 .num_databases = 4096,
3682 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003683 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003684 .port_base_addr = 0x0,
3685 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003686 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003687 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003688 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003689 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003690 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003691 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003692 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003693 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003694 .ops = &mv88e6390x_ops,
3695 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003696};
3697
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003698static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003699{
Vivien Didelota439c062016-04-17 13:23:58 -04003700 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003701
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003702 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3703 if (mv88e6xxx_table[i].prod_num == prod_num)
3704 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003705
Vivien Didelotb9b37712015-10-30 19:39:48 -04003706 return NULL;
3707}
3708
Vivien Didelotfad09c72016-06-21 12:28:20 -04003709static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003710{
3711 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003712 unsigned int prod_num, rev;
3713 u16 id;
3714 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003715
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003716 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003717 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003718 mutex_unlock(&chip->reg_lock);
3719 if (err)
3720 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003721
Vivien Didelot107fcc12017-06-12 12:37:36 -04003722 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3723 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003724
3725 info = mv88e6xxx_lookup_info(prod_num);
3726 if (!info)
3727 return -ENODEV;
3728
Vivien Didelotcaac8542016-06-20 13:14:09 -04003729 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003730 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003731
Vivien Didelotca070c12016-09-02 14:45:34 -04003732 err = mv88e6xxx_g2_require(chip);
3733 if (err)
3734 return err;
3735
Vivien Didelotfad09c72016-06-21 12:28:20 -04003736 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3737 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003738
3739 return 0;
3740}
3741
Vivien Didelotfad09c72016-06-21 12:28:20 -04003742static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003743{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003744 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003745
Vivien Didelotfad09c72016-06-21 12:28:20 -04003746 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3747 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003748 return NULL;
3749
Vivien Didelotfad09c72016-06-21 12:28:20 -04003750 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003751
Vivien Didelotfad09c72016-06-21 12:28:20 -04003752 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003753 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003754
Vivien Didelotfad09c72016-06-21 12:28:20 -04003755 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003756}
3757
Vivien Didelotfad09c72016-06-21 12:28:20 -04003758static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003759 struct mii_bus *bus, int sw_addr)
3760{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003761 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003762 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003763 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003764 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003765 else
3766 return -EINVAL;
3767
Vivien Didelotfad09c72016-06-21 12:28:20 -04003768 chip->bus = bus;
3769 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003770
3771 return 0;
3772}
3773
Andrew Lunn7b314362016-08-22 16:01:01 +02003774static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds)
3775{
Vivien Didelot04bed142016-08-31 18:06:13 -04003776 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003777
Andrew Lunn443d5a12016-12-03 04:35:18 +01003778 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003779}
3780
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003781static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3782 struct device *host_dev, int sw_addr,
3783 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003784{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003785 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003786 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003787 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003788
Vivien Didelota439c062016-04-17 13:23:58 -04003789 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003790 if (!bus)
3791 return NULL;
3792
Vivien Didelotfad09c72016-06-21 12:28:20 -04003793 chip = mv88e6xxx_alloc_chip(dsa_dev);
3794 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003795 return NULL;
3796
Vivien Didelotcaac8542016-06-20 13:14:09 -04003797 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003798 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003799
Vivien Didelotfad09c72016-06-21 12:28:20 -04003800 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003801 if (err)
3802 goto free;
3803
Vivien Didelotfad09c72016-06-21 12:28:20 -04003804 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003805 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003806 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003807
Andrew Lunndc30c352016-10-16 19:56:49 +02003808 mutex_lock(&chip->reg_lock);
3809 err = mv88e6xxx_switch_reset(chip);
3810 mutex_unlock(&chip->reg_lock);
3811 if (err)
3812 goto free;
3813
Vivien Didelote57e5e72016-08-15 17:19:00 -04003814 mv88e6xxx_phy_init(chip);
3815
Andrew Lunna3c53be52017-01-24 14:53:50 +01003816 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003817 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003818 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003819
Vivien Didelotfad09c72016-06-21 12:28:20 -04003820 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003821
Vivien Didelotfad09c72016-06-21 12:28:20 -04003822 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003823free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003824 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003825
3826 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003827}
3828
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003829static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
3830 const struct switchdev_obj_port_mdb *mdb,
3831 struct switchdev_trans *trans)
3832{
3833 /* We don't need any dynamic resource from the kernel (yet),
3834 * so skip the prepare phase.
3835 */
3836
3837 return 0;
3838}
3839
3840static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
3841 const struct switchdev_obj_port_mdb *mdb,
3842 struct switchdev_trans *trans)
3843{
Vivien Didelot04bed142016-08-31 18:06:13 -04003844 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003845
3846 mutex_lock(&chip->reg_lock);
3847 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003848 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003849 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3850 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003851 mutex_unlock(&chip->reg_lock);
3852}
3853
3854static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3855 const struct switchdev_obj_port_mdb *mdb)
3856{
Vivien Didelot04bed142016-08-31 18:06:13 -04003857 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003858 int err;
3859
3860 mutex_lock(&chip->reg_lock);
3861 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003862 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003863 mutex_unlock(&chip->reg_lock);
3864
3865 return err;
3866}
3867
3868static int mv88e6xxx_port_mdb_dump(struct dsa_switch *ds, int port,
3869 struct switchdev_obj_port_mdb *mdb,
Vivien Didelot438ff532017-05-17 15:46:05 -04003870 switchdev_obj_dump_cb_t *cb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003871{
Vivien Didelot04bed142016-08-31 18:06:13 -04003872 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003873 int err;
3874
3875 mutex_lock(&chip->reg_lock);
3876 err = mv88e6xxx_port_db_dump(chip, port, &mdb->obj, cb);
3877 mutex_unlock(&chip->reg_lock);
3878
3879 return err;
3880}
3881
Florian Fainellia82f67a2017-01-08 14:52:08 -08003882static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003883 .probe = mv88e6xxx_drv_probe,
Andrew Lunn7b314362016-08-22 16:01:01 +02003884 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003885 .setup = mv88e6xxx_setup,
3886 .set_addr = mv88e6xxx_set_addr,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003887 .adjust_link = mv88e6xxx_adjust_link,
3888 .get_strings = mv88e6xxx_get_strings,
3889 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3890 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003891 .port_enable = mv88e6xxx_port_enable,
3892 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04003893 .get_mac_eee = mv88e6xxx_get_mac_eee,
3894 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003895 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003896 .get_eeprom = mv88e6xxx_get_eeprom,
3897 .set_eeprom = mv88e6xxx_set_eeprom,
3898 .get_regs_len = mv88e6xxx_get_regs_len,
3899 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003900 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003901 .port_bridge_join = mv88e6xxx_port_bridge_join,
3902 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3903 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04003904 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003905 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3906 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3907 .port_vlan_add = mv88e6xxx_port_vlan_add,
3908 .port_vlan_del = mv88e6xxx_port_vlan_del,
3909 .port_vlan_dump = mv88e6xxx_port_vlan_dump,
3910 .port_fdb_prepare = mv88e6xxx_port_fdb_prepare,
3911 .port_fdb_add = mv88e6xxx_port_fdb_add,
3912 .port_fdb_del = mv88e6xxx_port_fdb_del,
3913 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003914 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
3915 .port_mdb_add = mv88e6xxx_port_mdb_add,
3916 .port_mdb_del = mv88e6xxx_port_mdb_del,
3917 .port_mdb_dump = mv88e6xxx_port_mdb_dump,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04003918 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
3919 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003920};
3921
Florian Fainelliab3d4082017-01-08 14:52:07 -08003922static struct dsa_switch_driver mv88e6xxx_switch_drv = {
3923 .ops = &mv88e6xxx_switch_ops,
3924};
3925
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003926static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003927{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003928 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003929 struct dsa_switch *ds;
3930
Vivien Didelot73b12042017-03-30 17:37:10 -04003931 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003932 if (!ds)
3933 return -ENOMEM;
3934
Vivien Didelotfad09c72016-06-21 12:28:20 -04003935 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04003936 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04003937 ds->ageing_time_min = chip->info->age_time_coeff;
3938 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003939
3940 dev_set_drvdata(dev, ds);
3941
Vivien Didelot23c9ee42017-05-26 18:12:51 -04003942 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003943}
3944
Vivien Didelotfad09c72016-06-21 12:28:20 -04003945static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003946{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003947 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003948}
3949
Vivien Didelot57d32312016-06-20 13:13:58 -04003950static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003951{
3952 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003953 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003954 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003955 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003956 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02003957 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003958
Vivien Didelotcaac8542016-06-20 13:14:09 -04003959 compat_info = of_device_get_match_data(dev);
3960 if (!compat_info)
3961 return -EINVAL;
3962
Vivien Didelotfad09c72016-06-21 12:28:20 -04003963 chip = mv88e6xxx_alloc_chip(dev);
3964 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003965 return -ENOMEM;
3966
Vivien Didelotfad09c72016-06-21 12:28:20 -04003967 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003968
Vivien Didelotfad09c72016-06-21 12:28:20 -04003969 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003970 if (err)
3971 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003972
Andrew Lunnb4308f02016-11-21 23:26:55 +01003973 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
3974 if (IS_ERR(chip->reset))
3975 return PTR_ERR(chip->reset);
3976
Vivien Didelotfad09c72016-06-21 12:28:20 -04003977 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003978 if (err)
3979 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003980
Vivien Didelote57e5e72016-08-15 17:19:00 -04003981 mv88e6xxx_phy_init(chip);
3982
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003983 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003984 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04003985 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003986
Andrew Lunndc30c352016-10-16 19:56:49 +02003987 mutex_lock(&chip->reg_lock);
3988 err = mv88e6xxx_switch_reset(chip);
3989 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02003990 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02003991 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02003992
Andrew Lunndc30c352016-10-16 19:56:49 +02003993 chip->irq = of_irq_get(np, 0);
3994 if (chip->irq == -EPROBE_DEFER) {
3995 err = chip->irq;
3996 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02003997 }
3998
Andrew Lunndc30c352016-10-16 19:56:49 +02003999 if (chip->irq > 0) {
4000 /* Has to be performed before the MDIO bus is created,
4001 * because the PHYs will link there interrupts to these
4002 * interrupt controllers
4003 */
4004 mutex_lock(&chip->reg_lock);
4005 err = mv88e6xxx_g1_irq_setup(chip);
4006 mutex_unlock(&chip->reg_lock);
4007
4008 if (err)
4009 goto out;
4010
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004011 if (chip->info->g2_irqs > 0) {
Andrew Lunndc30c352016-10-16 19:56:49 +02004012 err = mv88e6xxx_g2_irq_setup(chip);
4013 if (err)
4014 goto out_g1_irq;
4015 }
4016 }
4017
Andrew Lunna3c53be52017-01-24 14:53:50 +01004018 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004019 if (err)
4020 goto out_g2_irq;
4021
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004022 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004023 if (err)
4024 goto out_mdio;
4025
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004026 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004027
4028out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004029 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004030out_g2_irq:
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004031 if (chip->info->g2_irqs > 0 && chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004032 mv88e6xxx_g2_irq_free(chip);
4033out_g1_irq:
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004034 if (chip->irq > 0) {
4035 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004036 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004037 mutex_unlock(&chip->reg_lock);
4038 }
Andrew Lunndc30c352016-10-16 19:56:49 +02004039out:
4040 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004041}
4042
4043static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4044{
4045 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004046 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004047
Andrew Lunn930188c2016-08-22 16:01:03 +02004048 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004049 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004050 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004051
Andrew Lunn467126442016-11-20 20:14:15 +01004052 if (chip->irq > 0) {
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004053 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004054 mv88e6xxx_g2_irq_free(chip);
4055 mv88e6xxx_g1_irq_free(chip);
4056 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004057}
4058
4059static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004060 {
4061 .compatible = "marvell,mv88e6085",
4062 .data = &mv88e6xxx_table[MV88E6085],
4063 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004064 {
4065 .compatible = "marvell,mv88e6190",
4066 .data = &mv88e6xxx_table[MV88E6190],
4067 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004068 { /* sentinel */ },
4069};
4070
4071MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4072
4073static struct mdio_driver mv88e6xxx_driver = {
4074 .probe = mv88e6xxx_probe,
4075 .remove = mv88e6xxx_remove,
4076 .mdiodrv.driver = {
4077 .name = "mv88e6085",
4078 .of_match_table = mv88e6xxx_of_match,
4079 },
4080};
4081
Ben Hutchings98e67302011-11-25 14:36:19 +00004082static int __init mv88e6xxx_init(void)
4083{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004084 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004085 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004086}
4087module_init(mv88e6xxx_init);
4088
4089static void __exit mv88e6xxx_cleanup(void)
4090{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004091 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004092 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004093}
4094module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004095
4096MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4097MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4098MODULE_LICENSE("GPL");