blob: 77488b40ccebc9abdd10d52240a2faf86733d61a [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
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530310static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200311 .name = "mv88e6xxx-g1",
312 .irq_mask = mv88e6xxx_g1_irq_mask,
313 .irq_unmask = mv88e6xxx_g1_irq_unmask,
314 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
315 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
316};
317
318static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
319 unsigned int irq,
320 irq_hw_number_t hwirq)
321{
322 struct mv88e6xxx_chip *chip = d->host_data;
323
324 irq_set_chip_data(irq, d->host_data);
325 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
326 irq_set_noprobe(irq);
327
328 return 0;
329}
330
331static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
332 .map = mv88e6xxx_g1_irq_domain_map,
333 .xlate = irq_domain_xlate_twocell,
334};
335
336static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
337{
338 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100339 u16 mask;
340
Vivien Didelotd77f4322017-06-15 12:14:03 -0400341 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100342 mask |= GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400343 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100344
345 free_irq(chip->irq, chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200346
Andreas Färber5edef2f2016-11-27 23:26:28 +0100347 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100348 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200349 irq_dispose_mapping(virq);
350 }
351
Andrew Lunna3db3d32016-11-20 20:14:14 +0100352 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200353}
354
355static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
356{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100357 int err, irq, virq;
358 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200359
360 chip->g1_irq.nirqs = chip->info->g1_irqs;
361 chip->g1_irq.domain = irq_domain_add_simple(
362 NULL, chip->g1_irq.nirqs, 0,
363 &mv88e6xxx_g1_irq_domain_ops, chip);
364 if (!chip->g1_irq.domain)
365 return -ENOMEM;
366
367 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
368 irq_create_mapping(chip->g1_irq.domain, irq);
369
370 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
371 chip->g1_irq.masked = ~0;
372
Vivien Didelotd77f4322017-06-15 12:14:03 -0400373 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200374 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100375 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200376
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100377 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200378
Vivien Didelotd77f4322017-06-15 12:14:03 -0400379 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200380 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100381 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200382
383 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400384 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200385 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100386 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200387
388 err = request_threaded_irq(chip->irq, NULL,
389 mv88e6xxx_g1_irq_thread_fn,
390 IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
391 dev_name(chip->dev), chip);
392 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100393 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200394
395 return 0;
396
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100397out_disable:
398 mask |= GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400399 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100400
401out_mapping:
402 for (irq = 0; irq < 16; irq++) {
403 virq = irq_find_mapping(chip->g1_irq.domain, irq);
404 irq_dispose_mapping(virq);
405 }
406
407 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200408
409 return err;
410}
411
Vivien Didelotec561272016-09-02 14:45:33 -0400412int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400413{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200414 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400415
Andrew Lunn6441e6692016-08-19 00:01:55 +0200416 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400417 u16 val;
418 int err;
419
420 err = mv88e6xxx_read(chip, addr, reg, &val);
421 if (err)
422 return err;
423
424 if (!(val & mask))
425 return 0;
426
427 usleep_range(1000, 2000);
428 }
429
Andrew Lunn30853552016-08-19 00:01:57 +0200430 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400431 return -ETIMEDOUT;
432}
433
Vivien Didelotf22ab642016-07-18 20:45:31 -0400434/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400435int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400436{
437 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200438 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400439
440 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200441 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
442 if (err)
443 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400444
445 /* Set the Update bit to trigger a write operation */
446 val = BIT(15) | update;
447
448 return mv88e6xxx_write(chip, addr, reg, val);
449}
450
Vivien Didelotd78343d2016-11-04 03:23:36 +0100451static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
452 int link, int speed, int duplex,
453 phy_interface_t mode)
454{
455 int err;
456
457 if (!chip->info->ops->port_set_link)
458 return 0;
459
460 /* Port's MAC control must not be changed unless the link is down */
461 err = chip->info->ops->port_set_link(chip, port, 0);
462 if (err)
463 return err;
464
465 if (chip->info->ops->port_set_speed) {
466 err = chip->info->ops->port_set_speed(chip, port, speed);
467 if (err && err != -EOPNOTSUPP)
468 goto restore_link;
469 }
470
471 if (chip->info->ops->port_set_duplex) {
472 err = chip->info->ops->port_set_duplex(chip, port, duplex);
473 if (err && err != -EOPNOTSUPP)
474 goto restore_link;
475 }
476
477 if (chip->info->ops->port_set_rgmii_delay) {
478 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
479 if (err && err != -EOPNOTSUPP)
480 goto restore_link;
481 }
482
Andrew Lunnf39908d2017-02-04 20:02:50 +0100483 if (chip->info->ops->port_set_cmode) {
484 err = chip->info->ops->port_set_cmode(chip, port, mode);
485 if (err && err != -EOPNOTSUPP)
486 goto restore_link;
487 }
488
Vivien Didelotd78343d2016-11-04 03:23:36 +0100489 err = 0;
490restore_link:
491 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400492 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100493
494 return err;
495}
496
Andrew Lunndea87022015-08-31 15:56:47 +0200497/* We expect the switch to perform auto negotiation if there is a real
498 * phy. However, in the case of a fixed link phy, we force the port
499 * settings from the fixed link settings.
500 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400501static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
502 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200503{
Vivien Didelot04bed142016-08-31 18:06:13 -0400504 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200505 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200506
507 if (!phy_is_pseudo_fixed_link(phydev))
508 return;
509
Vivien Didelotfad09c72016-06-21 12:28:20 -0400510 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100511 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
512 phydev->duplex, phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400513 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100514
515 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400516 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200517}
518
Andrew Lunna605a0f2016-11-21 23:26:58 +0100519static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000520{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100521 if (!chip->info->ops->stats_snapshot)
522 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000523
Andrew Lunna605a0f2016-11-21 23:26:58 +0100524 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000525}
526
Andrew Lunne413e7e2015-04-02 04:06:38 +0200527static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100528 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
529 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
530 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
531 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
532 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
533 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
534 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
535 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
536 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
537 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
538 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
539 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
540 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
541 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
542 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
543 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
544 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
545 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
546 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
547 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
548 { "single", 4, 0x14, STATS_TYPE_BANK0, },
549 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
550 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
551 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
552 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
553 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
554 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
555 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
556 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
557 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
558 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
559 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
560 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
561 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
562 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
563 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
564 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
565 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
566 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
567 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
568 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
569 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
570 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
571 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
572 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
573 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
574 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
575 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
576 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
577 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
578 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
579 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
580 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
581 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
582 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
583 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
584 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
585 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
586 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200587};
588
Vivien Didelotfad09c72016-06-21 12:28:20 -0400589static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100590 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100591 int port, u16 bank1_select,
592 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200593{
Andrew Lunn80c46272015-06-20 18:42:30 +0200594 u32 low;
595 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100596 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200597 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200598 u64 value;
599
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100600 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100601 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200602 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
603 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200604 return UINT64_MAX;
605
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200606 low = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200607 if (s->sizeof_stat == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200608 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
609 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200610 return UINT64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200611 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200612 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100613 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100614 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100615 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100616 /* fall through */
617 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100618 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100619 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunn80c46272015-06-20 18:42:30 +0200620 if (s->sizeof_stat == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100621 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500622 break;
623 default:
624 return UINT64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200625 }
626 value = (((u64)high) << 16) | low;
627 return value;
628}
629
Andrew Lunndfafe442016-11-21 23:27:02 +0100630static void mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
631 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100632{
633 struct mv88e6xxx_hw_stat *stat;
634 int i, j;
635
636 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
637 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100638 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100639 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
640 ETH_GSTRING_LEN);
641 j++;
642 }
643 }
644}
645
Andrew Lunndfafe442016-11-21 23:27:02 +0100646static void mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
647 uint8_t *data)
648{
649 mv88e6xxx_stats_get_strings(chip, data,
650 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
651}
652
653static void mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
654 uint8_t *data)
655{
656 mv88e6xxx_stats_get_strings(chip, data,
657 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
658}
659
660static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
661 uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100662{
Vivien Didelot04bed142016-08-31 18:06:13 -0400663 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunndfafe442016-11-21 23:27:02 +0100664
665 if (chip->info->ops->stats_get_strings)
666 chip->info->ops->stats_get_strings(chip, data);
667}
668
669static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
670 int types)
671{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100672 struct mv88e6xxx_hw_stat *stat;
673 int i, j;
674
675 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
676 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100677 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100678 j++;
679 }
680 return j;
681}
682
Andrew Lunndfafe442016-11-21 23:27:02 +0100683static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
684{
685 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
686 STATS_TYPE_PORT);
687}
688
689static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
690{
691 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
692 STATS_TYPE_BANK1);
693}
694
695static int mv88e6xxx_get_sset_count(struct dsa_switch *ds)
696{
697 struct mv88e6xxx_chip *chip = ds->priv;
698
699 if (chip->info->ops->stats_get_sset_count)
700 return chip->info->ops->stats_get_sset_count(chip);
701
702 return 0;
703}
704
Andrew Lunn052f9472016-11-21 23:27:03 +0100705static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100706 uint64_t *data, int types,
707 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100708{
709 struct mv88e6xxx_hw_stat *stat;
710 int i, j;
711
712 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
713 stat = &mv88e6xxx_hw_stats[i];
714 if (stat->type & types) {
Andrew Lunne0d8b612016-11-21 23:27:04 +0100715 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
716 bank1_select,
717 histogram);
Andrew Lunn052f9472016-11-21 23:27:03 +0100718 j++;
719 }
720 }
721}
722
723static void mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
724 uint64_t *data)
725{
726 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100727 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400728 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100729}
730
731static void mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
732 uint64_t *data)
733{
734 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100735 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400736 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
737 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100738}
739
740static void mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
741 uint64_t *data)
742{
743 return mv88e6xxx_stats_get_stats(chip, port, data,
744 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400745 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
746 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100747}
748
749static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
750 uint64_t *data)
751{
752 if (chip->info->ops->stats_get_stats)
753 chip->info->ops->stats_get_stats(chip, port, data);
754}
755
Vivien Didelotf81ec902016-05-09 13:22:58 -0400756static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
757 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000758{
Vivien Didelot04bed142016-08-31 18:06:13 -0400759 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000760 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000761
Vivien Didelotfad09c72016-06-21 12:28:20 -0400762 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000763
Andrew Lunna605a0f2016-11-21 23:26:58 +0100764 ret = mv88e6xxx_stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000765 if (ret < 0) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400766 mutex_unlock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000767 return;
768 }
Andrew Lunn052f9472016-11-21 23:27:03 +0100769
770 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000771
Vivien Didelotfad09c72016-06-21 12:28:20 -0400772 mutex_unlock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000773}
Ben Hutchings98e67302011-11-25 14:36:19 +0000774
Andrew Lunnde2273872016-11-21 23:27:01 +0100775static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
776{
777 if (chip->info->ops->stats_set_histogram)
778 return chip->info->ops->stats_set_histogram(chip);
779
780 return 0;
781}
782
Vivien Didelotf81ec902016-05-09 13:22:58 -0400783static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700784{
785 return 32 * sizeof(u16);
786}
787
Vivien Didelotf81ec902016-05-09 13:22:58 -0400788static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
789 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700790{
Vivien Didelot04bed142016-08-31 18:06:13 -0400791 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200792 int err;
793 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700794 u16 *p = _p;
795 int i;
796
797 regs->version = 0;
798
799 memset(p, 0xff, 32 * sizeof(u16));
800
Vivien Didelotfad09c72016-06-21 12:28:20 -0400801 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -0400802
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700803 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700804
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200805 err = mv88e6xxx_port_read(chip, port, i, &reg);
806 if (!err)
807 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700808 }
Vivien Didelot23062512016-05-09 13:22:45 -0400809
Vivien Didelotfad09c72016-06-21 12:28:20 -0400810 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700811}
812
Vivien Didelot08f50062017-08-01 16:32:41 -0400813static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
814 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800815{
Vivien Didelot5480db62017-08-01 16:32:40 -0400816 /* Nothing to do on the port's MAC */
817 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800818}
819
Vivien Didelot08f50062017-08-01 16:32:41 -0400820static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
821 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800822{
Vivien Didelot5480db62017-08-01 16:32:40 -0400823 /* Nothing to do on the port's MAC */
824 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800825}
826
Vivien Didelote5887a22017-03-30 17:37:11 -0400827static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700828{
Vivien Didelote5887a22017-03-30 17:37:11 -0400829 struct dsa_switch *ds = NULL;
830 struct net_device *br;
831 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500832 int i;
833
Vivien Didelote5887a22017-03-30 17:37:11 -0400834 if (dev < DSA_MAX_SWITCHES)
835 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500836
Vivien Didelote5887a22017-03-30 17:37:11 -0400837 /* Prevent frames from unknown switch or port */
838 if (!ds || port >= ds->num_ports)
839 return 0;
840
841 /* Frames from DSA links and CPU ports can egress any local port */
842 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
843 return mv88e6xxx_port_mask(chip);
844
845 br = ds->ports[port].bridge_dev;
846 pvlan = 0;
847
848 /* Frames from user ports can egress any local DSA links and CPU ports,
849 * as well as any local member of their bridge group.
850 */
851 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
852 if (dsa_is_cpu_port(chip->ds, i) ||
853 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -0400854 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -0400855 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 Didelot04a69a12017-10-13 14:18:05 -0400935static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
936{
937 if (chip->info->ops->set_switch_mac) {
938 u8 addr[ETH_ALEN];
939
940 eth_random_addr(addr);
941
942 return chip->info->ops->set_switch_mac(chip, addr);
943 }
944
945 return 0;
946}
947
Vivien Didelot17a15942017-03-30 17:37:09 -0400948static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
949{
950 u16 pvlan = 0;
951
952 if (!mv88e6xxx_has_pvt(chip))
953 return -EOPNOTSUPP;
954
955 /* Skip the local source device, which uses in-chip port VLAN */
956 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -0400957 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -0400958
959 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
960}
961
Vivien Didelot81228992017-03-30 17:37:08 -0400962static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
963{
Vivien Didelot17a15942017-03-30 17:37:09 -0400964 int dev, port;
965 int err;
966
Vivien Didelot81228992017-03-30 17:37:08 -0400967 if (!mv88e6xxx_has_pvt(chip))
968 return 0;
969
970 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
971 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
972 */
Vivien Didelot17a15942017-03-30 17:37:09 -0400973 err = mv88e6xxx_g2_misc_4_bit_port(chip);
974 if (err)
975 return err;
976
977 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
978 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
979 err = mv88e6xxx_pvt_map(chip, dev, port);
980 if (err)
981 return err;
982 }
983 }
984
985 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -0400986}
987
Vivien Didelot749efcb2016-09-22 16:49:24 -0400988static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
989{
990 struct mv88e6xxx_chip *chip = ds->priv;
991 int err;
992
993 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -0500994 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400995 mutex_unlock(&chip->reg_lock);
996
997 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400998 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400999}
1000
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001001static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1002{
1003 if (!chip->info->max_vid)
1004 return 0;
1005
1006 return mv88e6xxx_g1_vtu_flush(chip);
1007}
1008
Vivien Didelotf1394b782017-05-01 14:05:22 -04001009static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1010 struct mv88e6xxx_vtu_entry *entry)
1011{
1012 if (!chip->info->ops->vtu_getnext)
1013 return -EOPNOTSUPP;
1014
1015 return chip->info->ops->vtu_getnext(chip, entry);
1016}
1017
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001018static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1019 struct mv88e6xxx_vtu_entry *entry)
1020{
1021 if (!chip->info->ops->vtu_loadpurge)
1022 return -EOPNOTSUPP;
1023
1024 return chip->info->ops->vtu_loadpurge(chip, entry);
1025}
1026
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001027static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001028{
1029 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001030 struct mv88e6xxx_vtu_entry vlan = {
1031 .vid = chip->info->max_vid,
1032 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001033 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001034
1035 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1036
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001037 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001038 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001039 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001040 if (err)
1041 return err;
1042
1043 set_bit(*fid, fid_bitmap);
1044 }
1045
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001046 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001047 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001048 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001049 if (err)
1050 return err;
1051
1052 if (!vlan.valid)
1053 break;
1054
1055 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001056 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001057
1058 /* The reset value 0x000 is used to indicate that multiple address
1059 * databases are not needed. Return the next positive available.
1060 */
1061 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001062 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001063 return -ENOSPC;
1064
1065 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001066 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001067}
1068
Vivien Didelot567aa592017-05-01 14:05:25 -04001069static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1070 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001071{
1072 int err;
1073
1074 if (!vid)
1075 return -EINVAL;
1076
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001077 entry->vid = vid - 1;
1078 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001079
Vivien Didelotf1394b782017-05-01 14:05:22 -04001080 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001081 if (err)
1082 return err;
1083
Vivien Didelot567aa592017-05-01 14:05:25 -04001084 if (entry->vid == vid && entry->valid)
1085 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001086
Vivien Didelot567aa592017-05-01 14:05:25 -04001087 if (new) {
1088 int i;
1089
1090 /* Initialize a fresh VLAN entry */
1091 memset(entry, 0, sizeof(*entry));
1092 entry->valid = true;
1093 entry->vid = vid;
1094
Vivien Didelot553a7682017-06-07 18:12:16 -04001095 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001096 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001097 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001098 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001099
1100 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001101 }
1102
Vivien Didelot567aa592017-05-01 14:05:25 -04001103 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1104 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001105}
1106
Vivien Didelotda9c3592016-02-12 12:09:40 -05001107static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1108 u16 vid_begin, u16 vid_end)
1109{
Vivien Didelot04bed142016-08-31 18:06:13 -04001110 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001111 struct mv88e6xxx_vtu_entry vlan = {
1112 .vid = vid_begin - 1,
1113 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001114 int i, err;
1115
Andrew Lunndb06ae412017-09-25 23:32:20 +02001116 /* DSA and CPU ports have to be members of multiple vlans */
1117 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1118 return 0;
1119
Vivien Didelotda9c3592016-02-12 12:09:40 -05001120 if (!vid_begin)
1121 return -EOPNOTSUPP;
1122
Vivien Didelotfad09c72016-06-21 12:28:20 -04001123 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001124
Vivien Didelotda9c3592016-02-12 12:09:40 -05001125 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001126 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001127 if (err)
1128 goto unlock;
1129
1130 if (!vlan.valid)
1131 break;
1132
1133 if (vlan.vid > vid_end)
1134 break;
1135
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001136 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001137 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1138 continue;
1139
Andrew Lunncd886462017-11-09 22:29:53 +01001140 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001141 continue;
1142
Vivien Didelotbd00e052017-05-01 14:05:11 -04001143 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001144 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001145 continue;
1146
Vivien Didelotc8652c82017-10-16 11:12:19 -04001147 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001148 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001149 break; /* same bridge, check next VLAN */
1150
Vivien Didelotc8652c82017-10-16 11:12:19 -04001151 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001152 continue;
1153
Andrew Lunn743fcc22017-11-09 22:29:54 +01001154 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1155 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001156 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001157 err = -EOPNOTSUPP;
1158 goto unlock;
1159 }
1160 } while (vlan.vid < vid_end);
1161
1162unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001163 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001164
1165 return err;
1166}
1167
Vivien Didelotf81ec902016-05-09 13:22:58 -04001168static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1169 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001170{
Vivien Didelot04bed142016-08-31 18:06:13 -04001171 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001172 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1173 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001174 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001175
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001176 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001177 return -EOPNOTSUPP;
1178
Vivien Didelotfad09c72016-06-21 12:28:20 -04001179 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001180 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001181 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001182
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001183 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001184}
1185
Vivien Didelot57d32312016-06-20 13:13:58 -04001186static int
1187mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001188 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001189{
Vivien Didelot04bed142016-08-31 18:06:13 -04001190 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001191 int err;
1192
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001193 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001194 return -EOPNOTSUPP;
1195
Vivien Didelotda9c3592016-02-12 12:09:40 -05001196 /* If the requested port doesn't belong to the same bridge as the VLAN
1197 * members, do not support it (yet) and fallback to software VLAN.
1198 */
1199 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1200 vlan->vid_end);
1201 if (err)
1202 return err;
1203
Vivien Didelot76e398a2015-11-01 12:33:55 -05001204 /* We don't need any dynamic resource from the kernel (yet),
1205 * so skip the prepare phase.
1206 */
1207 return 0;
1208}
1209
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001210static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1211 const unsigned char *addr, u16 vid,
1212 u8 state)
1213{
1214 struct mv88e6xxx_vtu_entry vlan;
1215 struct mv88e6xxx_atu_entry entry;
1216 int err;
1217
1218 /* Null VLAN ID corresponds to the port private database */
1219 if (vid == 0)
1220 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1221 else
1222 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1223 if (err)
1224 return err;
1225
1226 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1227 ether_addr_copy(entry.mac, addr);
1228 eth_addr_dec(entry.mac);
1229
1230 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1231 if (err)
1232 return err;
1233
1234 /* Initialize a fresh ATU entry if it isn't found */
1235 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1236 !ether_addr_equal(entry.mac, addr)) {
1237 memset(&entry, 0, sizeof(entry));
1238 ether_addr_copy(entry.mac, addr);
1239 }
1240
1241 /* Purge the ATU entry only if no port is using it anymore */
1242 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1243 entry.portvec &= ~BIT(port);
1244 if (!entry.portvec)
1245 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1246 } else {
1247 entry.portvec |= BIT(port);
1248 entry.state = state;
1249 }
1250
1251 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1252}
1253
Andrew Lunn87fa8862017-11-09 22:29:56 +01001254static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1255 u16 vid)
1256{
1257 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1258 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1259
1260 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1261}
1262
1263static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1264{
1265 int port;
1266 int err;
1267
1268 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1269 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1270 if (err)
1271 return err;
1272 }
1273
1274 return 0;
1275}
1276
Vivien Didelotfad09c72016-06-21 12:28:20 -04001277static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001278 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001279{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001280 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001281 int err;
1282
Vivien Didelot567aa592017-05-01 14:05:25 -04001283 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001284 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001285 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001286
Vivien Didelotc91498e2017-06-07 18:12:13 -04001287 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001288
Andrew Lunn87fa8862017-11-09 22:29:56 +01001289 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1290 if (err)
1291 return err;
1292
1293 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001294}
1295
Vivien Didelotf81ec902016-05-09 13:22:58 -04001296static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001297 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001298{
Vivien Didelot04bed142016-08-31 18:06:13 -04001299 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001300 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1301 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001302 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001303 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001304
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001305 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001306 return;
1307
Vivien Didelotc91498e2017-06-07 18:12:13 -04001308 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001309 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001310 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001311 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001312 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001313 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001314
Vivien Didelotfad09c72016-06-21 12:28:20 -04001315 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001316
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001317 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001318 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001319 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1320 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001321
Vivien Didelot77064f32016-11-04 03:23:30 +01001322 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001323 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1324 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001325
Vivien Didelotfad09c72016-06-21 12:28:20 -04001326 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001327}
1328
Vivien Didelotfad09c72016-06-21 12:28:20 -04001329static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001330 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001331{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001332 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001333 int i, err;
1334
Vivien Didelot567aa592017-05-01 14:05:25 -04001335 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001336 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001337 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001338
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001339 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001340 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001341 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001342
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001343 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001344
1345 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001346 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001347 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001348 if (vlan.member[i] !=
1349 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001350 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001351 break;
1352 }
1353 }
1354
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001355 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001356 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001357 return err;
1358
Vivien Didelote606ca32017-03-11 16:12:55 -05001359 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001360}
1361
Vivien Didelotf81ec902016-05-09 13:22:58 -04001362static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1363 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001364{
Vivien Didelot04bed142016-08-31 18:06:13 -04001365 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001366 u16 pvid, vid;
1367 int err = 0;
1368
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001369 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001370 return -EOPNOTSUPP;
1371
Vivien Didelotfad09c72016-06-21 12:28:20 -04001372 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001373
Vivien Didelot77064f32016-11-04 03:23:30 +01001374 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001375 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001376 goto unlock;
1377
Vivien Didelot76e398a2015-11-01 12:33:55 -05001378 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001379 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001380 if (err)
1381 goto unlock;
1382
1383 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001384 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001385 if (err)
1386 goto unlock;
1387 }
1388 }
1389
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001390unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001391 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001392
1393 return err;
1394}
1395
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001396static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1397 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001398{
Vivien Didelot04bed142016-08-31 18:06:13 -04001399 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001400 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001401
Vivien Didelotfad09c72016-06-21 12:28:20 -04001402 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001403 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1404 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001405 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001406
1407 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001408}
1409
Vivien Didelotf81ec902016-05-09 13:22:58 -04001410static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001411 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001412{
Vivien Didelot04bed142016-08-31 18:06:13 -04001413 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001414 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001415
Vivien Didelotfad09c72016-06-21 12:28:20 -04001416 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001417 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001418 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001419 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001420
Vivien Didelot83dabd12016-08-31 11:50:04 -04001421 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001422}
1423
Vivien Didelot83dabd12016-08-31 11:50:04 -04001424static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1425 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001426 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001427{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001428 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001429 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001430 int err;
1431
Vivien Didelot27c0e602017-06-15 12:14:01 -04001432 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001433 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001434
1435 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001436 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001437 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001438 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001439
Vivien Didelot27c0e602017-06-15 12:14:01 -04001440 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001441 break;
1442
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001443 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001444 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001445
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001446 if (!is_unicast_ether_addr(addr.mac))
1447 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001448
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001449 is_static = (addr.state ==
1450 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1451 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001452 if (err)
1453 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001454 } while (!is_broadcast_ether_addr(addr.mac));
1455
1456 return err;
1457}
1458
Vivien Didelot83dabd12016-08-31 11:50:04 -04001459static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001460 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001461{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001462 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001463 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001464 };
1465 u16 fid;
1466 int err;
1467
1468 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001469 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001470 if (err)
1471 return err;
1472
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001473 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001474 if (err)
1475 return err;
1476
1477 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001478 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001479 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001480 if (err)
1481 return err;
1482
1483 if (!vlan.valid)
1484 break;
1485
1486 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001487 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001488 if (err)
1489 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001490 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001491
1492 return err;
1493}
1494
Vivien Didelotf81ec902016-05-09 13:22:58 -04001495static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001496 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001497{
Vivien Didelot04bed142016-08-31 18:06:13 -04001498 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001499 int err;
1500
Vivien Didelotfad09c72016-06-21 12:28:20 -04001501 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001502 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001503 mutex_unlock(&chip->reg_lock);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001504
1505 return err;
1506}
1507
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001508static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1509 struct net_device *br)
1510{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001511 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001512 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001513 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001514 int err;
1515
1516 /* Remap the Port VLAN of each local bridge group member */
1517 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1518 if (chip->ds->ports[port].bridge_dev == br) {
1519 err = mv88e6xxx_port_vlan_map(chip, port);
1520 if (err)
1521 return err;
1522 }
1523 }
1524
Vivien Didelote96a6e02017-03-30 17:37:13 -04001525 if (!mv88e6xxx_has_pvt(chip))
1526 return 0;
1527
1528 /* Remap the Port VLAN of each cross-chip bridge group member */
1529 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1530 ds = chip->ds->dst->ds[dev];
1531 if (!ds)
1532 break;
1533
1534 for (port = 0; port < ds->num_ports; ++port) {
1535 if (ds->ports[port].bridge_dev == br) {
1536 err = mv88e6xxx_pvt_map(chip, dev, port);
1537 if (err)
1538 return err;
1539 }
1540 }
1541 }
1542
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001543 return 0;
1544}
1545
Vivien Didelotf81ec902016-05-09 13:22:58 -04001546static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001547 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001548{
Vivien Didelot04bed142016-08-31 18:06:13 -04001549 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001550 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001551
Vivien Didelotfad09c72016-06-21 12:28:20 -04001552 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001553 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001554 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001555
Vivien Didelot466dfa02016-02-26 13:16:05 -05001556 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001557}
1558
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001559static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1560 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001561{
Vivien Didelot04bed142016-08-31 18:06:13 -04001562 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001563
Vivien Didelotfad09c72016-06-21 12:28:20 -04001564 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001565 if (mv88e6xxx_bridge_map(chip, br) ||
1566 mv88e6xxx_port_vlan_map(chip, port))
1567 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001568 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001569}
1570
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001571static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1572 int port, struct net_device *br)
1573{
1574 struct mv88e6xxx_chip *chip = ds->priv;
1575 int err;
1576
1577 if (!mv88e6xxx_has_pvt(chip))
1578 return 0;
1579
1580 mutex_lock(&chip->reg_lock);
1581 err = mv88e6xxx_pvt_map(chip, dev, port);
1582 mutex_unlock(&chip->reg_lock);
1583
1584 return err;
1585}
1586
1587static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1588 int port, struct net_device *br)
1589{
1590 struct mv88e6xxx_chip *chip = ds->priv;
1591
1592 if (!mv88e6xxx_has_pvt(chip))
1593 return;
1594
1595 mutex_lock(&chip->reg_lock);
1596 if (mv88e6xxx_pvt_map(chip, dev, port))
1597 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1598 mutex_unlock(&chip->reg_lock);
1599}
1600
Vivien Didelot17e708b2016-12-05 17:30:27 -05001601static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1602{
1603 if (chip->info->ops->reset)
1604 return chip->info->ops->reset(chip);
1605
1606 return 0;
1607}
1608
Vivien Didelot309eca62016-12-05 17:30:26 -05001609static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1610{
1611 struct gpio_desc *gpiod = chip->reset;
1612
1613 /* If there is a GPIO connected to the reset pin, toggle it */
1614 if (gpiod) {
1615 gpiod_set_value_cansleep(gpiod, 1);
1616 usleep_range(10000, 20000);
1617 gpiod_set_value_cansleep(gpiod, 0);
1618 usleep_range(10000, 20000);
1619 }
1620}
1621
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001622static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1623{
1624 int i, err;
1625
1626 /* Set all ports to the Disabled state */
1627 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001628 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001629 if (err)
1630 return err;
1631 }
1632
1633 /* Wait for transmit queues to drain,
1634 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1635 */
1636 usleep_range(2000, 4000);
1637
1638 return 0;
1639}
1640
Vivien Didelotfad09c72016-06-21 12:28:20 -04001641static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001642{
Vivien Didelota935c052016-09-29 12:21:53 -04001643 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001644
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001645 err = mv88e6xxx_disable_ports(chip);
1646 if (err)
1647 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001648
Vivien Didelot309eca62016-12-05 17:30:26 -05001649 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001650
Vivien Didelot17e708b2016-12-05 17:30:27 -05001651 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001652}
1653
Vivien Didelot43145572017-03-11 16:12:59 -05001654static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001655 enum mv88e6xxx_frame_mode frame,
1656 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001657{
1658 int err;
1659
Vivien Didelot43145572017-03-11 16:12:59 -05001660 if (!chip->info->ops->port_set_frame_mode)
1661 return -EOPNOTSUPP;
1662
1663 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001664 if (err)
1665 return err;
1666
Vivien Didelot43145572017-03-11 16:12:59 -05001667 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1668 if (err)
1669 return err;
1670
1671 if (chip->info->ops->port_set_ether_type)
1672 return chip->info->ops->port_set_ether_type(chip, port, etype);
1673
1674 return 0;
1675}
1676
1677static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1678{
1679 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001680 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001681 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001682}
1683
1684static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1685{
1686 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001687 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001688 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001689}
1690
1691static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1692{
1693 return mv88e6xxx_set_port_mode(chip, port,
1694 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001695 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1696 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001697}
1698
1699static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1700{
1701 if (dsa_is_dsa_port(chip->ds, port))
1702 return mv88e6xxx_set_port_mode_dsa(chip, port);
1703
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001704 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001705 return mv88e6xxx_set_port_mode_normal(chip, port);
1706
1707 /* Setup CPU port mode depending on its supported tag format */
1708 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1709 return mv88e6xxx_set_port_mode_dsa(chip, port);
1710
1711 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1712 return mv88e6xxx_set_port_mode_edsa(chip, port);
1713
1714 return -EINVAL;
1715}
1716
Vivien Didelotea698f42017-03-11 16:12:50 -05001717static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1718{
1719 bool message = dsa_is_dsa_port(chip->ds, port);
1720
1721 return mv88e6xxx_port_set_message_port(chip, port, message);
1722}
1723
Vivien Didelot601aeed2017-03-11 16:13:00 -05001724static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1725{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001726 struct dsa_switch *ds = chip->ds;
1727 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05001728
1729 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001730 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05001731 if (chip->info->ops->port_set_egress_floods)
1732 return chip->info->ops->port_set_egress_floods(chip, port,
1733 flood, flood);
1734
1735 return 0;
1736}
1737
Andrew Lunn6d917822017-05-26 01:03:21 +02001738static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1739 bool on)
1740{
Vivien Didelot523a8902017-05-26 18:02:42 -04001741 if (chip->info->ops->serdes_power)
1742 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001743
Vivien Didelot523a8902017-05-26 18:02:42 -04001744 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001745}
1746
Vivien Didelotfa371c82017-12-05 15:34:10 -05001747static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
1748{
1749 struct dsa_switch *ds = chip->ds;
1750 int upstream_port;
1751 int err;
1752
1753 upstream_port = dsa_upstream_port(ds);
1754 if (chip->info->ops->port_set_upstream_port) {
1755 err = chip->info->ops->port_set_upstream_port(chip, port,
1756 upstream_port);
1757 if (err)
1758 return err;
1759 }
1760
1761 return 0;
1762}
1763
Vivien Didelotfad09c72016-06-21 12:28:20 -04001764static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001765{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001766 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001767 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001768 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001769
Vivien Didelotd78343d2016-11-04 03:23:36 +01001770 /* MAC Forcing register: don't force link, speed, duplex or flow control
1771 * state to any particular values on physical ports, but force the CPU
1772 * port and all DSA ports to their maximum bandwidth and full duplex.
1773 */
1774 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1775 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1776 SPEED_MAX, DUPLEX_FULL,
1777 PHY_INTERFACE_MODE_NA);
1778 else
1779 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1780 SPEED_UNFORCED, DUPLEX_UNFORCED,
1781 PHY_INTERFACE_MODE_NA);
1782 if (err)
1783 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001784
1785 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1786 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1787 * tunneling, determine priority by looking at 802.1p and IP
1788 * priority fields (IP prio has precedence), and set STP state
1789 * to Forwarding.
1790 *
1791 * If this is the CPU link, use DSA or EDSA tagging depending
1792 * on which tagging mode was configured.
1793 *
1794 * If this is a link to another switch, use DSA tagging mode.
1795 *
1796 * If this is the upstream port for this switch, enable
1797 * forwarding of unknown unicasts and multicasts.
1798 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001799 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1800 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1801 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1802 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001803 if (err)
1804 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001805
Vivien Didelot601aeed2017-03-11 16:13:00 -05001806 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001807 if (err)
1808 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001809
Vivien Didelot601aeed2017-03-11 16:13:00 -05001810 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001811 if (err)
1812 return err;
1813
Andrew Lunn04aca992017-05-26 01:03:24 +02001814 /* Enable the SERDES interface for DSA and CPU ports. Normal
1815 * ports SERDES are enabled when the port is enabled, thus
1816 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001817 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001818 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1819 err = mv88e6xxx_serdes_power(chip, port, true);
1820 if (err)
1821 return err;
1822 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001823
Vivien Didelot8efdda42015-08-13 12:52:23 -04001824 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001825 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001826 * untagged frames on this port, do a destination address lookup on all
1827 * received packets as usual, disable ARP mirroring and don't send a
1828 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001829 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001830 err = mv88e6xxx_port_set_map_da(chip, port);
1831 if (err)
1832 return err;
1833
Vivien Didelotfa371c82017-12-05 15:34:10 -05001834 err = mv88e6xxx_setup_upstream_port(chip, port);
1835 if (err)
1836 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001837
Andrew Lunna23b2962017-02-04 20:15:28 +01001838 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001839 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001840 if (err)
1841 return err;
1842
Vivien Didelotcd782652017-06-08 18:34:13 -04001843 if (chip->info->ops->port_set_jumbo_size) {
1844 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001845 if (err)
1846 return err;
1847 }
1848
Andrew Lunn54d792f2015-05-06 01:09:47 +02001849 /* Port Association Vector: when learning source addresses
1850 * of packets, add the address to the address database using
1851 * a port bitmap that has only the bit for this port set and
1852 * the other bits clear.
1853 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001854 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001855 /* Disable learning for CPU port */
1856 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001857 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001858
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001859 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1860 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001861 if (err)
1862 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001863
1864 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001865 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1866 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001867 if (err)
1868 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001869
Vivien Didelot08984322017-06-08 18:34:12 -04001870 if (chip->info->ops->port_pause_limit) {
1871 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001872 if (err)
1873 return err;
1874 }
1875
Vivien Didelotc8c94892017-03-11 16:13:01 -05001876 if (chip->info->ops->port_disable_learn_limit) {
1877 err = chip->info->ops->port_disable_learn_limit(chip, port);
1878 if (err)
1879 return err;
1880 }
1881
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001882 if (chip->info->ops->port_disable_pri_override) {
1883 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001884 if (err)
1885 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001886 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001887
Andrew Lunnef0a7312016-12-03 04:35:16 +01001888 if (chip->info->ops->port_tag_remap) {
1889 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001890 if (err)
1891 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001892 }
1893
Andrew Lunnef70b112016-12-03 04:45:18 +01001894 if (chip->info->ops->port_egress_rate_limiting) {
1895 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001896 if (err)
1897 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001898 }
1899
Vivien Didelotea698f42017-03-11 16:12:50 -05001900 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001901 if (err)
1902 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001903
Vivien Didelot207afda2016-04-14 14:42:09 -04001904 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001905 * database, and allow bidirectional communication between the
1906 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001907 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001908 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001909 if (err)
1910 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001911
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001912 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001913 if (err)
1914 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001915
1916 /* Default VLAN ID and priority: don't set a default VLAN
1917 * ID, and set the default packet priority to zero.
1918 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04001919 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02001920}
1921
Andrew Lunn04aca992017-05-26 01:03:24 +02001922static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
1923 struct phy_device *phydev)
1924{
1925 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04001926 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02001927
1928 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001929 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02001930 mutex_unlock(&chip->reg_lock);
1931
1932 return err;
1933}
1934
1935static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
1936 struct phy_device *phydev)
1937{
1938 struct mv88e6xxx_chip *chip = ds->priv;
1939
1940 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001941 if (mv88e6xxx_serdes_power(chip, port, false))
1942 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02001943 mutex_unlock(&chip->reg_lock);
1944}
1945
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001946static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
1947 unsigned int ageing_time)
1948{
Vivien Didelot04bed142016-08-31 18:06:13 -04001949 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001950 int err;
1951
1952 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05001953 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001954 mutex_unlock(&chip->reg_lock);
1955
1956 return err;
1957}
1958
Vivien Didelot97299342016-07-18 20:45:30 -04001959static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04001960{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001961 struct dsa_switch *ds = chip->ds;
Vivien Didelotb0745e872016-05-09 13:22:53 -04001962 u32 upstream_port = dsa_upstream_port(ds);
Vivien Didelot08a01262016-05-09 13:22:50 -04001963 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04001964
Vivien Didelotfa8d1172017-06-08 18:34:11 -04001965 if (chip->info->ops->set_cpu_port) {
1966 err = chip->info->ops->set_cpu_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01001967 if (err)
1968 return err;
1969 }
1970
Vivien Didelotfa8d1172017-06-08 18:34:11 -04001971 if (chip->info->ops->set_egress_port) {
1972 err = chip->info->ops->set_egress_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01001973 if (err)
1974 return err;
1975 }
Vivien Didelotb0745e872016-05-09 13:22:53 -04001976
Vivien Didelot50484ff2016-05-09 13:22:54 -04001977 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04001978 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
1979 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04001980 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04001981 if (err)
1982 return err;
1983
Vivien Didelot08a01262016-05-09 13:22:50 -04001984 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04001985 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001986 if (err)
1987 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001988 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001989 if (err)
1990 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001991 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001992 if (err)
1993 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001994 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001995 if (err)
1996 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001997 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04001998 if (err)
1999 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002000 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002001 if (err)
2002 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002003 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002004 if (err)
2005 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002006 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002007 if (err)
2008 return err;
2009
2010 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002011 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002012 if (err)
2013 return err;
2014
Andrew Lunnde2273872016-11-21 23:27:01 +01002015 /* Initialize the statistics unit */
2016 err = mv88e6xxx_stats_set_histogram(chip);
2017 if (err)
2018 return err;
2019
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002020 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002021}
2022
Vivien Didelotf81ec902016-05-09 13:22:58 -04002023static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002024{
Vivien Didelot04bed142016-08-31 18:06:13 -04002025 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002026 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002027 int i;
2028
Vivien Didelotfad09c72016-06-21 12:28:20 -04002029 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002030 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002031
Vivien Didelotfad09c72016-06-21 12:28:20 -04002032 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002033
Vivien Didelot97299342016-07-18 20:45:30 -04002034 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002035 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002036 if (dsa_is_unused_port(ds, i))
2037 continue;
2038
Vivien Didelot97299342016-07-18 20:45:30 -04002039 err = mv88e6xxx_setup_port(chip, i);
2040 if (err)
2041 goto unlock;
2042 }
2043
2044 /* Setup Switch Global 1 Registers */
2045 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002046 if (err)
2047 goto unlock;
2048
Vivien Didelot97299342016-07-18 20:45:30 -04002049 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002050 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002051 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002052 if (err)
2053 goto unlock;
2054 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002055
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002056 err = mv88e6xxx_irl_setup(chip);
2057 if (err)
2058 goto unlock;
2059
Vivien Didelot04a69a12017-10-13 14:18:05 -04002060 err = mv88e6xxx_mac_setup(chip);
2061 if (err)
2062 goto unlock;
2063
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002064 err = mv88e6xxx_phy_setup(chip);
2065 if (err)
2066 goto unlock;
2067
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002068 err = mv88e6xxx_vtu_setup(chip);
2069 if (err)
2070 goto unlock;
2071
Vivien Didelot81228992017-03-30 17:37:08 -04002072 err = mv88e6xxx_pvt_setup(chip);
2073 if (err)
2074 goto unlock;
2075
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002076 err = mv88e6xxx_atu_setup(chip);
2077 if (err)
2078 goto unlock;
2079
Andrew Lunn87fa8862017-11-09 22:29:56 +01002080 err = mv88e6xxx_broadcast_setup(chip, 0);
2081 if (err)
2082 goto unlock;
2083
Vivien Didelot9e907d72017-07-17 13:03:43 -04002084 err = mv88e6xxx_pot_setup(chip);
2085 if (err)
2086 goto unlock;
2087
Vivien Didelot51c901a2017-07-17 13:03:41 -04002088 err = mv88e6xxx_rsvd2cpu_setup(chip);
2089 if (err)
2090 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002091
Vivien Didelot6b17e862015-08-13 12:52:18 -04002092unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002093 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002094
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002095 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002096}
2097
Vivien Didelote57e5e72016-08-15 17:19:00 -04002098static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002099{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002100 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2101 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002102 u16 val;
2103 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002104
Andrew Lunnee26a222017-01-24 14:53:48 +01002105 if (!chip->info->ops->phy_read)
2106 return -EOPNOTSUPP;
2107
Vivien Didelotfad09c72016-06-21 12:28:20 -04002108 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002109 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002110 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002111
Andrew Lunnda9f3302017-02-01 03:40:05 +01002112 if (reg == MII_PHYSID2) {
2113 /* Some internal PHYS don't have a model number. Use
2114 * the mv88e6390 family model number instead.
2115 */
2116 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002117 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002118 }
2119
Vivien Didelote57e5e72016-08-15 17:19:00 -04002120 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002121}
2122
Vivien Didelote57e5e72016-08-15 17:19:00 -04002123static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002124{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002125 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2126 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002127 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002128
Andrew Lunnee26a222017-01-24 14:53:48 +01002129 if (!chip->info->ops->phy_write)
2130 return -EOPNOTSUPP;
2131
Vivien Didelotfad09c72016-06-21 12:28:20 -04002132 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002133 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002134 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002135
2136 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002137}
2138
Vivien Didelotfad09c72016-06-21 12:28:20 -04002139static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002140 struct device_node *np,
2141 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002142{
2143 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002144 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002145 struct mii_bus *bus;
2146 int err;
2147
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002148 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002149 if (!bus)
2150 return -ENOMEM;
2151
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002152 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002153 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002154 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002155 INIT_LIST_HEAD(&mdio_bus->list);
2156 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002157
Andrew Lunnb516d452016-06-04 21:17:06 +02002158 if (np) {
2159 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002160 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002161 } else {
2162 bus->name = "mv88e6xxx SMI";
2163 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2164 }
2165
2166 bus->read = mv88e6xxx_mdio_read;
2167 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002168 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002169
Andrew Lunna3c53be52017-01-24 14:53:50 +01002170 if (np)
2171 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002172 else
2173 err = mdiobus_register(bus);
2174 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002175 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002176 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002177 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002178
2179 if (external)
2180 list_add_tail(&mdio_bus->list, &chip->mdios);
2181 else
2182 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002183
2184 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002185}
2186
Andrew Lunna3c53be52017-01-24 14:53:50 +01002187static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2188 { .compatible = "marvell,mv88e6xxx-mdio-external",
2189 .data = (void *)true },
2190 { },
2191};
2192
2193static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2194 struct device_node *np)
2195{
2196 const struct of_device_id *match;
2197 struct device_node *child;
2198 int err;
2199
2200 /* Always register one mdio bus for the internal/default mdio
2201 * bus. This maybe represented in the device tree, but is
2202 * optional.
2203 */
2204 child = of_get_child_by_name(np, "mdio");
2205 err = mv88e6xxx_mdio_register(chip, child, false);
2206 if (err)
2207 return err;
2208
2209 /* Walk the device tree, and see if there are any other nodes
2210 * which say they are compatible with the external mdio
2211 * bus.
2212 */
2213 for_each_available_child_of_node(np, child) {
2214 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2215 if (match) {
2216 err = mv88e6xxx_mdio_register(chip, child, true);
2217 if (err)
2218 return err;
2219 }
2220 }
2221
2222 return 0;
2223}
2224
2225static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
Andrew Lunnb516d452016-06-04 21:17:06 +02002226
2227{
Andrew Lunna3c53be52017-01-24 14:53:50 +01002228 struct mv88e6xxx_mdio_bus *mdio_bus;
2229 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002230
Andrew Lunna3c53be52017-01-24 14:53:50 +01002231 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2232 bus = mdio_bus->bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002233
Andrew Lunna3c53be52017-01-24 14:53:50 +01002234 mdiobus_unregister(bus);
2235 }
Andrew Lunnb516d452016-06-04 21:17:06 +02002236}
2237
Vivien Didelot855b1932016-07-20 18:18:35 -04002238static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2239{
Vivien Didelot04bed142016-08-31 18:06:13 -04002240 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002241
2242 return chip->eeprom_len;
2243}
2244
Vivien Didelot855b1932016-07-20 18:18:35 -04002245static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2246 struct ethtool_eeprom *eeprom, u8 *data)
2247{
Vivien Didelot04bed142016-08-31 18:06:13 -04002248 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002249 int err;
2250
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002251 if (!chip->info->ops->get_eeprom)
2252 return -EOPNOTSUPP;
2253
Vivien Didelot855b1932016-07-20 18:18:35 -04002254 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002255 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002256 mutex_unlock(&chip->reg_lock);
2257
2258 if (err)
2259 return err;
2260
2261 eeprom->magic = 0xc3ec4951;
2262
2263 return 0;
2264}
2265
Vivien Didelot855b1932016-07-20 18:18:35 -04002266static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2267 struct ethtool_eeprom *eeprom, u8 *data)
2268{
Vivien Didelot04bed142016-08-31 18:06:13 -04002269 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002270 int err;
2271
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002272 if (!chip->info->ops->set_eeprom)
2273 return -EOPNOTSUPP;
2274
Vivien Didelot855b1932016-07-20 18:18:35 -04002275 if (eeprom->magic != 0xc3ec4951)
2276 return -EINVAL;
2277
2278 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002279 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002280 mutex_unlock(&chip->reg_lock);
2281
2282 return err;
2283}
2284
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002285static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002286 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002287 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002288 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002289 .phy_read = mv88e6185_phy_ppu_read,
2290 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002291 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002292 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002293 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002294 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002295 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002296 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002297 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002298 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002299 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002300 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002301 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002302 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002303 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002304 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2305 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002306 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002307 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2308 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002309 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002310 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002311 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002312 .ppu_enable = mv88e6185_g1_ppu_enable,
2313 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002314 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002315 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002316 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002317};
2318
2319static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002320 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002321 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002322 .phy_read = mv88e6185_phy_ppu_read,
2323 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002324 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002325 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002326 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002327 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002328 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002329 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002330 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002331 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002332 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2333 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002334 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002335 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002336 .ppu_enable = mv88e6185_g1_ppu_enable,
2337 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002338 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002339 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002340 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002341};
2342
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002343static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002344 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002345 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002346 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2347 .phy_read = mv88e6xxx_g2_smi_phy_read,
2348 .phy_write = mv88e6xxx_g2_smi_phy_write,
2349 .port_set_link = mv88e6xxx_port_set_link,
2350 .port_set_duplex = mv88e6xxx_port_set_duplex,
2351 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002352 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002353 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002354 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002355 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002356 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002357 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002358 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002359 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002360 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002361 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002362 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002363 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2364 .stats_get_strings = mv88e6095_stats_get_strings,
2365 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002366 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2367 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002368 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002369 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002370 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002371 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002372 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002373 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002374};
2375
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002376static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002377 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002378 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002379 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002380 .phy_read = mv88e6xxx_g2_smi_phy_read,
2381 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002382 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002383 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002384 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002385 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002386 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002387 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002388 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002389 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002390 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002391 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2392 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002393 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002394 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2395 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002396 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002397 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002398 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002399 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002400 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002401 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002402};
2403
2404static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002405 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002406 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002407 .phy_read = mv88e6185_phy_ppu_read,
2408 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002409 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002410 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002411 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002412 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002413 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002414 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002415 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002416 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002417 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002418 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002419 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002420 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002421 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002422 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2423 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002424 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002425 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2426 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002427 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002428 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002429 .ppu_enable = mv88e6185_g1_ppu_enable,
2430 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002431 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002432 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002433 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002434};
2435
Vivien Didelot990e27b2017-03-28 13:50:32 -04002436static const struct mv88e6xxx_ops mv88e6141_ops = {
2437 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002438 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002439 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2440 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2441 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2442 .phy_read = mv88e6xxx_g2_smi_phy_read,
2443 .phy_write = mv88e6xxx_g2_smi_phy_write,
2444 .port_set_link = mv88e6xxx_port_set_link,
2445 .port_set_duplex = mv88e6xxx_port_set_duplex,
2446 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2447 .port_set_speed = mv88e6390_port_set_speed,
2448 .port_tag_remap = mv88e6095_port_tag_remap,
2449 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2450 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2451 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002452 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002453 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002454 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002455 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2456 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2457 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002458 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002459 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2460 .stats_get_strings = mv88e6320_stats_get_strings,
2461 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002462 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2463 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002464 .watchdog_ops = &mv88e6390_watchdog_ops,
2465 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002466 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002467 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002468 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002469 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002470};
2471
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002472static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002473 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002474 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002475 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002476 .phy_read = mv88e6xxx_g2_smi_phy_read,
2477 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002478 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002479 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002480 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002481 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002482 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002483 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002484 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002485 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002486 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002487 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002488 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002489 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002490 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002491 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002492 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2493 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002494 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002495 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2496 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002497 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002498 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002499 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002500 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002501 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002502 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002503};
2504
2505static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002506 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002507 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002508 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002509 .phy_read = mv88e6165_phy_read,
2510 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002511 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002512 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002513 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002514 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002515 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002516 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002517 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002518 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2519 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002520 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002521 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2522 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002523 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002524 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002525 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002526 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002527 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002528 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002529};
2530
2531static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002532 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002533 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002534 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002535 .phy_read = mv88e6xxx_g2_smi_phy_read,
2536 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002537 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002538 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002539 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002540 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002541 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002542 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002543 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002544 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002545 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002546 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002547 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002548 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002549 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002550 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002551 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002552 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2553 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002554 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002555 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2556 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002557 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002558 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002559 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002560 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002561 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002562 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002563};
2564
2565static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002566 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002567 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002568 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2569 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002570 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002571 .phy_read = mv88e6xxx_g2_smi_phy_read,
2572 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002573 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002574 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002575 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002576 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002577 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002578 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002579 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002580 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002581 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002582 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002583 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002584 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002585 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002586 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002587 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002588 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2589 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002590 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002591 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2592 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002593 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002594 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002595 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002596 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002597 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002598 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002599 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002600};
2601
2602static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002603 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002604 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002605 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002606 .phy_read = mv88e6xxx_g2_smi_phy_read,
2607 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002608 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002609 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002610 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002611 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002612 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002613 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002614 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002615 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002616 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002617 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002618 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002619 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002620 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002621 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002622 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002623 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2624 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002625 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002626 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2627 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002628 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002629 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002630 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002631 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002632 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002633 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002634};
2635
2636static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002637 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002638 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002639 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2640 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002641 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002642 .phy_read = mv88e6xxx_g2_smi_phy_read,
2643 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002644 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002645 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002646 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002647 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002648 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002649 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002650 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002651 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002652 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002653 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002654 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002655 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002656 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002657 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002658 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
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,
Andrew Lunn6d917822017-05-26 01:03:21 +02002670 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002671};
2672
2673static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002674 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002675 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002676 .phy_read = mv88e6185_phy_ppu_read,
2677 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002678 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002679 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002680 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002681 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002682 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002683 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002684 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002685 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002686 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002687 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2688 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002689 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002690 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2691 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002692 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002693 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002694 .ppu_enable = mv88e6185_g1_ppu_enable,
2695 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002696 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002697 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002698 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002699};
2700
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002701static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002702 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002703 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002704 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2705 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002706 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2707 .phy_read = mv88e6xxx_g2_smi_phy_read,
2708 .phy_write = mv88e6xxx_g2_smi_phy_write,
2709 .port_set_link = mv88e6xxx_port_set_link,
2710 .port_set_duplex = mv88e6xxx_port_set_duplex,
2711 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2712 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002713 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002714 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002715 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002716 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002717 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002718 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002719 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002720 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002721 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002722 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2723 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002724 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002725 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2726 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002727 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002728 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002729 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002730 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002731 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2732 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002733 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002734};
2735
2736static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002737 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002738 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002739 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2740 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002741 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2742 .phy_read = mv88e6xxx_g2_smi_phy_read,
2743 .phy_write = mv88e6xxx_g2_smi_phy_write,
2744 .port_set_link = mv88e6xxx_port_set_link,
2745 .port_set_duplex = mv88e6xxx_port_set_duplex,
2746 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2747 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002748 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002749 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002750 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002751 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002752 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002753 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002754 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002755 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002756 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002757 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2758 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002759 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002760 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2761 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002762 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002763 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002764 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002765 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002766 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2767 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002768 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002769};
2770
2771static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002772 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002773 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002774 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2775 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002776 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2777 .phy_read = mv88e6xxx_g2_smi_phy_read,
2778 .phy_write = mv88e6xxx_g2_smi_phy_write,
2779 .port_set_link = mv88e6xxx_port_set_link,
2780 .port_set_duplex = mv88e6xxx_port_set_duplex,
2781 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2782 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002783 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002784 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002785 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002786 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002787 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002788 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002789 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002790 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002791 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002792 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2793 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002794 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002795 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2796 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002797 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002798 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002799 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002800 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002801 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2802 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002803 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002804};
2805
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002806static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002807 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002808 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002809 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2810 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002811 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002812 .phy_read = mv88e6xxx_g2_smi_phy_read,
2813 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002814 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002815 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002816 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002817 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002818 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002819 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002820 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002821 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002822 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002823 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002824 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002825 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002826 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002827 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002828 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002829 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2830 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002831 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002832 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2833 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002834 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002835 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002836 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002837 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002838 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002839 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002840 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002841};
2842
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002843static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002844 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002845 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002846 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2847 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002848 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2849 .phy_read = mv88e6xxx_g2_smi_phy_read,
2850 .phy_write = mv88e6xxx_g2_smi_phy_write,
2851 .port_set_link = mv88e6xxx_port_set_link,
2852 .port_set_duplex = mv88e6xxx_port_set_duplex,
2853 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2854 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002855 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002856 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002857 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002858 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002859 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002860 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002861 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002862 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002863 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002864 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002865 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2866 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002867 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002868 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2869 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002870 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002871 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002872 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002873 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002874 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2875 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002876 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002877};
2878
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002879static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002880 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002881 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002882 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2883 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002884 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002885 .phy_read = mv88e6xxx_g2_smi_phy_read,
2886 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002887 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002888 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002889 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002890 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002891 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002892 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002893 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002894 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002895 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002896 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002897 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002898 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002899 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002900 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002901 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2902 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002903 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002904 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2905 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002906 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002907 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002908 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002909 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002910 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002911};
2912
2913static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04002914 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002915 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002916 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2917 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002918 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002919 .phy_read = mv88e6xxx_g2_smi_phy_read,
2920 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002921 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002922 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002923 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002924 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002925 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002926 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002927 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002928 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002929 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002930 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002931 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002932 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002933 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002934 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002935 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2936 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002937 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002938 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2939 .set_egress_port = mv88e6095_g1_set_egress_port,
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
Vivien Didelot16e329a2017-03-28 13:50:33 -04002945static const struct mv88e6xxx_ops mv88e6341_ops = {
2946 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002947 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002948 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2949 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2950 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2951 .phy_read = mv88e6xxx_g2_smi_phy_read,
2952 .phy_write = mv88e6xxx_g2_smi_phy_write,
2953 .port_set_link = mv88e6xxx_port_set_link,
2954 .port_set_duplex = mv88e6xxx_port_set_duplex,
2955 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2956 .port_set_speed = mv88e6390_port_set_speed,
2957 .port_tag_remap = mv88e6095_port_tag_remap,
2958 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2959 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2960 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002961 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002962 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002963 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002964 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2965 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2966 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002967 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002968 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2969 .stats_get_strings = mv88e6320_stats_get_strings,
2970 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002971 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2972 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002973 .watchdog_ops = &mv88e6390_watchdog_ops,
2974 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002975 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002976 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002977 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002978 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002979};
2980
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002981static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002982 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002983 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002984 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002985 .phy_read = mv88e6xxx_g2_smi_phy_read,
2986 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002987 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002988 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002989 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002990 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002991 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002992 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002993 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002994 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002995 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002996 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002997 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002998 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002999 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003000 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003001 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003002 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3003 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003004 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003005 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3006 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003007 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003008 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003009 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003010 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003011 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003012 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003013};
3014
3015static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003016 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003017 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003018 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003019 .phy_read = mv88e6xxx_g2_smi_phy_read,
3020 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003021 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003022 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003023 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003024 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003025 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003026 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003027 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003028 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003029 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003030 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003031 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003032 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003033 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003034 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003035 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003036 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3037 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003038 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003039 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3040 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003041 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003042 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003043 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003044 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003045 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003046 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003047};
3048
3049static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003050 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003051 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003052 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3053 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003054 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003055 .phy_read = mv88e6xxx_g2_smi_phy_read,
3056 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003057 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003058 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003059 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003060 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003061 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003062 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003063 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003064 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003065 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003066 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003067 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003068 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003069 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003070 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003071 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003072 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3073 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003074 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003075 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3076 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003077 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003078 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003079 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003080 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003081 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003082 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003083 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003084};
3085
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003086static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003087 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003088 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003089 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3090 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003091 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3092 .phy_read = mv88e6xxx_g2_smi_phy_read,
3093 .phy_write = mv88e6xxx_g2_smi_phy_write,
3094 .port_set_link = mv88e6xxx_port_set_link,
3095 .port_set_duplex = mv88e6xxx_port_set_duplex,
3096 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3097 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003098 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003099 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003100 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003101 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003102 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003103 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003104 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003105 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003106 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003107 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003108 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003109 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003110 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3111 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003112 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003113 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3114 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003115 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003116 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003117 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003118 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003119 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3120 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003121 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003122};
3123
3124static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003125 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003126 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003127 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3128 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003129 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3130 .phy_read = mv88e6xxx_g2_smi_phy_read,
3131 .phy_write = mv88e6xxx_g2_smi_phy_write,
3132 .port_set_link = mv88e6xxx_port_set_link,
3133 .port_set_duplex = mv88e6xxx_port_set_duplex,
3134 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3135 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003136 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003137 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003138 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003139 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003140 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003141 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003142 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003143 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003144 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003145 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003146 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003147 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003148 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3149 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003150 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003151 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3152 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003153 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003154 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003155 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003156 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003157 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3158 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003159 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003160};
3161
Vivien Didelotf81ec902016-05-09 13:22:58 -04003162static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3163 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003164 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003165 .family = MV88E6XXX_FAMILY_6097,
3166 .name = "Marvell 88E6085",
3167 .num_databases = 4096,
3168 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003169 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003170 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003171 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003172 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003173 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003174 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003175 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003176 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003177 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003178 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003179 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003180 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003181 },
3182
3183 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003184 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003185 .family = MV88E6XXX_FAMILY_6095,
3186 .name = "Marvell 88E6095/88E6095F",
3187 .num_databases = 256,
3188 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003189 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003190 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003191 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003192 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003193 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003194 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003195 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003196 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003197 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003198 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003199 },
3200
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003201 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003202 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003203 .family = MV88E6XXX_FAMILY_6097,
3204 .name = "Marvell 88E6097/88E6097F",
3205 .num_databases = 4096,
3206 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003207 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003208 .port_base_addr = 0x10,
3209 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003210 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003211 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003212 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003213 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003214 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003215 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003216 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003217 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003218 .ops = &mv88e6097_ops,
3219 },
3220
Vivien Didelotf81ec902016-05-09 13:22:58 -04003221 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003222 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003223 .family = MV88E6XXX_FAMILY_6165,
3224 .name = "Marvell 88E6123",
3225 .num_databases = 4096,
3226 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003227 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003228 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003229 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003230 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003231 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003232 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003233 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003234 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003235 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003236 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003237 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003238 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003239 },
3240
3241 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003242 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003243 .family = MV88E6XXX_FAMILY_6185,
3244 .name = "Marvell 88E6131",
3245 .num_databases = 256,
3246 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003247 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003248 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003249 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003250 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003251 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003252 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003253 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003254 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003255 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003256 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003257 },
3258
Vivien Didelot990e27b2017-03-28 13:50:32 -04003259 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003260 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003261 .family = MV88E6XXX_FAMILY_6341,
3262 .name = "Marvell 88E6341",
3263 .num_databases = 4096,
3264 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003265 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003266 .port_base_addr = 0x10,
3267 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003268 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003269 .age_time_coeff = 3750,
3270 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003271 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003272 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003273 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003274 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003275 .ops = &mv88e6141_ops,
3276 },
3277
Vivien Didelotf81ec902016-05-09 13:22:58 -04003278 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003279 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003280 .family = MV88E6XXX_FAMILY_6165,
3281 .name = "Marvell 88E6161",
3282 .num_databases = 4096,
3283 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003284 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003285 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003286 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003287 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003288 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003289 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003290 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003291 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003292 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003293 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003294 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003295 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003296 },
3297
3298 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003299 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003300 .family = MV88E6XXX_FAMILY_6165,
3301 .name = "Marvell 88E6165",
3302 .num_databases = 4096,
3303 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003304 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003305 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003306 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003307 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003308 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003309 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003310 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003311 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003312 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003313 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003314 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003315 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003316 },
3317
3318 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003319 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003320 .family = MV88E6XXX_FAMILY_6351,
3321 .name = "Marvell 88E6171",
3322 .num_databases = 4096,
3323 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003324 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003325 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003326 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003327 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003328 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003329 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003330 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003331 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003332 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003333 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003334 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003335 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003336 },
3337
3338 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003339 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003340 .family = MV88E6XXX_FAMILY_6352,
3341 .name = "Marvell 88E6172",
3342 .num_databases = 4096,
3343 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003344 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003345 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003346 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003347 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003348 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003349 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003350 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003351 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003352 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003353 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003354 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003355 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003356 },
3357
3358 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003359 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003360 .family = MV88E6XXX_FAMILY_6351,
3361 .name = "Marvell 88E6175",
3362 .num_databases = 4096,
3363 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003364 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003365 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003366 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003367 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003368 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003369 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003370 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003371 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003372 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003373 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003374 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003375 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003376 },
3377
3378 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003379 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003380 .family = MV88E6XXX_FAMILY_6352,
3381 .name = "Marvell 88E6176",
3382 .num_databases = 4096,
3383 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003384 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003385 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003386 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003387 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003388 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003389 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003390 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003391 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003392 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003393 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003394 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003395 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003396 },
3397
3398 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003399 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003400 .family = MV88E6XXX_FAMILY_6185,
3401 .name = "Marvell 88E6185",
3402 .num_databases = 256,
3403 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003404 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003405 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003406 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003407 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003408 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003409 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003410 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003411 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003412 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003413 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003414 },
3415
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003416 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003417 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003418 .family = MV88E6XXX_FAMILY_6390,
3419 .name = "Marvell 88E6190",
3420 .num_databases = 4096,
3421 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003422 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003423 .port_base_addr = 0x0,
3424 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003425 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003426 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003427 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003428 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003429 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003430 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003431 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003432 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003433 .ops = &mv88e6190_ops,
3434 },
3435
3436 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003437 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003438 .family = MV88E6XXX_FAMILY_6390,
3439 .name = "Marvell 88E6190X",
3440 .num_databases = 4096,
3441 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003442 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003443 .port_base_addr = 0x0,
3444 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003445 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003446 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003447 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003448 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003449 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003450 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003451 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003452 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003453 .ops = &mv88e6190x_ops,
3454 },
3455
3456 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003457 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003458 .family = MV88E6XXX_FAMILY_6390,
3459 .name = "Marvell 88E6191",
3460 .num_databases = 4096,
3461 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003462 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003463 .port_base_addr = 0x0,
3464 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003465 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003466 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003467 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003468 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003469 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003470 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003471 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003472 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003473 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003474 },
3475
Vivien Didelotf81ec902016-05-09 13:22:58 -04003476 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003477 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003478 .family = MV88E6XXX_FAMILY_6352,
3479 .name = "Marvell 88E6240",
3480 .num_databases = 4096,
3481 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003482 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003483 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003484 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003485 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003486 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003487 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003488 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003489 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003490 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003491 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003492 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003493 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003494 },
3495
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003496 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003497 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003498 .family = MV88E6XXX_FAMILY_6390,
3499 .name = "Marvell 88E6290",
3500 .num_databases = 4096,
3501 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003502 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003503 .port_base_addr = 0x0,
3504 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003505 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003506 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003507 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003508 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003509 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003510 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003511 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003512 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003513 .ops = &mv88e6290_ops,
3514 },
3515
Vivien Didelotf81ec902016-05-09 13:22:58 -04003516 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003517 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003518 .family = MV88E6XXX_FAMILY_6320,
3519 .name = "Marvell 88E6320",
3520 .num_databases = 4096,
3521 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003522 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003523 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003524 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003525 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003526 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003527 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003528 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003529 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003530 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003531 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003532 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003533 },
3534
3535 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003536 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003537 .family = MV88E6XXX_FAMILY_6320,
3538 .name = "Marvell 88E6321",
3539 .num_databases = 4096,
3540 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003541 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003542 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003543 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003544 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003545 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003546 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003547 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003548 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003549 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003550 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003551 },
3552
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003553 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003554 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003555 .family = MV88E6XXX_FAMILY_6341,
3556 .name = "Marvell 88E6341",
3557 .num_databases = 4096,
3558 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003559 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003560 .port_base_addr = 0x10,
3561 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003562 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003563 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003564 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003565 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003566 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003567 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003568 .tag_protocol = DSA_TAG_PROTO_EDSA,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003569 .ops = &mv88e6341_ops,
3570 },
3571
Vivien Didelotf81ec902016-05-09 13:22:58 -04003572 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003573 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003574 .family = MV88E6XXX_FAMILY_6351,
3575 .name = "Marvell 88E6350",
3576 .num_databases = 4096,
3577 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003578 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003579 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003580 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003581 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003582 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003583 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003584 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003585 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003586 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003587 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003588 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003589 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003590 },
3591
3592 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003593 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003594 .family = MV88E6XXX_FAMILY_6351,
3595 .name = "Marvell 88E6351",
3596 .num_databases = 4096,
3597 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003598 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003599 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003600 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003601 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003602 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003603 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003604 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003605 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003606 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003607 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003608 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003609 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003610 },
3611
3612 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003613 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003614 .family = MV88E6XXX_FAMILY_6352,
3615 .name = "Marvell 88E6352",
3616 .num_databases = 4096,
3617 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003618 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003619 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003620 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003621 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003622 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003623 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003624 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003625 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003626 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003627 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003628 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003629 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003630 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003631 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003632 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003633 .family = MV88E6XXX_FAMILY_6390,
3634 .name = "Marvell 88E6390",
3635 .num_databases = 4096,
3636 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003637 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003638 .port_base_addr = 0x0,
3639 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003640 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003641 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003642 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003643 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003644 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003645 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003646 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003647 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003648 .ops = &mv88e6390_ops,
3649 },
3650 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003651 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003652 .family = MV88E6XXX_FAMILY_6390,
3653 .name = "Marvell 88E6390X",
3654 .num_databases = 4096,
3655 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003656 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003657 .port_base_addr = 0x0,
3658 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003659 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003660 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003661 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003662 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003663 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003664 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003665 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003666 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003667 .ops = &mv88e6390x_ops,
3668 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003669};
3670
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003671static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003672{
Vivien Didelota439c062016-04-17 13:23:58 -04003673 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003674
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003675 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3676 if (mv88e6xxx_table[i].prod_num == prod_num)
3677 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003678
Vivien Didelotb9b37712015-10-30 19:39:48 -04003679 return NULL;
3680}
3681
Vivien Didelotfad09c72016-06-21 12:28:20 -04003682static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003683{
3684 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003685 unsigned int prod_num, rev;
3686 u16 id;
3687 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003688
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003689 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003690 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003691 mutex_unlock(&chip->reg_lock);
3692 if (err)
3693 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003694
Vivien Didelot107fcc12017-06-12 12:37:36 -04003695 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3696 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003697
3698 info = mv88e6xxx_lookup_info(prod_num);
3699 if (!info)
3700 return -ENODEV;
3701
Vivien Didelotcaac8542016-06-20 13:14:09 -04003702 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003703 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003704
Vivien Didelotca070c12016-09-02 14:45:34 -04003705 err = mv88e6xxx_g2_require(chip);
3706 if (err)
3707 return err;
3708
Vivien Didelotfad09c72016-06-21 12:28:20 -04003709 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3710 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003711
3712 return 0;
3713}
3714
Vivien Didelotfad09c72016-06-21 12:28:20 -04003715static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003716{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003717 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003718
Vivien Didelotfad09c72016-06-21 12:28:20 -04003719 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3720 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003721 return NULL;
3722
Vivien Didelotfad09c72016-06-21 12:28:20 -04003723 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003724
Vivien Didelotfad09c72016-06-21 12:28:20 -04003725 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003726 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003727
Vivien Didelotfad09c72016-06-21 12:28:20 -04003728 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003729}
3730
Vivien Didelotfad09c72016-06-21 12:28:20 -04003731static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003732 struct mii_bus *bus, int sw_addr)
3733{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003734 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003735 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003736 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003737 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003738 else
3739 return -EINVAL;
3740
Vivien Didelotfad09c72016-06-21 12:28:20 -04003741 chip->bus = bus;
3742 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003743
3744 return 0;
3745}
3746
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08003747static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
3748 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02003749{
Vivien Didelot04bed142016-08-31 18:06:13 -04003750 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003751
Andrew Lunn443d5a12016-12-03 04:35:18 +01003752 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003753}
3754
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003755static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3756 struct device *host_dev, int sw_addr,
3757 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003758{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003759 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003760 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003761 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003762
Vivien Didelota439c062016-04-17 13:23:58 -04003763 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003764 if (!bus)
3765 return NULL;
3766
Vivien Didelotfad09c72016-06-21 12:28:20 -04003767 chip = mv88e6xxx_alloc_chip(dsa_dev);
3768 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003769 return NULL;
3770
Vivien Didelotcaac8542016-06-20 13:14:09 -04003771 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003772 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003773
Vivien Didelotfad09c72016-06-21 12:28:20 -04003774 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003775 if (err)
3776 goto free;
3777
Vivien Didelotfad09c72016-06-21 12:28:20 -04003778 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003779 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003780 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003781
Andrew Lunndc30c352016-10-16 19:56:49 +02003782 mutex_lock(&chip->reg_lock);
3783 err = mv88e6xxx_switch_reset(chip);
3784 mutex_unlock(&chip->reg_lock);
3785 if (err)
3786 goto free;
3787
Vivien Didelote57e5e72016-08-15 17:19:00 -04003788 mv88e6xxx_phy_init(chip);
3789
Andrew Lunna3c53be52017-01-24 14:53:50 +01003790 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003791 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003792 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003793
Vivien Didelotfad09c72016-06-21 12:28:20 -04003794 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003795
Vivien Didelotfad09c72016-06-21 12:28:20 -04003796 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003797free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003798 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003799
3800 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003801}
3802
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003803static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003804 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003805{
3806 /* We don't need any dynamic resource from the kernel (yet),
3807 * so skip the prepare phase.
3808 */
3809
3810 return 0;
3811}
3812
3813static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003814 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003815{
Vivien Didelot04bed142016-08-31 18:06:13 -04003816 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003817
3818 mutex_lock(&chip->reg_lock);
3819 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003820 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003821 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3822 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003823 mutex_unlock(&chip->reg_lock);
3824}
3825
3826static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3827 const struct switchdev_obj_port_mdb *mdb)
3828{
Vivien Didelot04bed142016-08-31 18:06:13 -04003829 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003830 int err;
3831
3832 mutex_lock(&chip->reg_lock);
3833 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003834 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003835 mutex_unlock(&chip->reg_lock);
3836
3837 return err;
3838}
3839
Florian Fainellia82f67a2017-01-08 14:52:08 -08003840static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003841 .probe = mv88e6xxx_drv_probe,
Andrew Lunn7b314362016-08-22 16:01:01 +02003842 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003843 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003844 .adjust_link = mv88e6xxx_adjust_link,
3845 .get_strings = mv88e6xxx_get_strings,
3846 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3847 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003848 .port_enable = mv88e6xxx_port_enable,
3849 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04003850 .get_mac_eee = mv88e6xxx_get_mac_eee,
3851 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003852 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003853 .get_eeprom = mv88e6xxx_get_eeprom,
3854 .set_eeprom = mv88e6xxx_set_eeprom,
3855 .get_regs_len = mv88e6xxx_get_regs_len,
3856 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003857 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003858 .port_bridge_join = mv88e6xxx_port_bridge_join,
3859 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3860 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04003861 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003862 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3863 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3864 .port_vlan_add = mv88e6xxx_port_vlan_add,
3865 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003866 .port_fdb_add = mv88e6xxx_port_fdb_add,
3867 .port_fdb_del = mv88e6xxx_port_fdb_del,
3868 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003869 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
3870 .port_mdb_add = mv88e6xxx_port_mdb_add,
3871 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04003872 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
3873 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003874};
3875
Florian Fainelliab3d4082017-01-08 14:52:07 -08003876static struct dsa_switch_driver mv88e6xxx_switch_drv = {
3877 .ops = &mv88e6xxx_switch_ops,
3878};
3879
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003880static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003881{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003882 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003883 struct dsa_switch *ds;
3884
Vivien Didelot73b12042017-03-30 17:37:10 -04003885 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003886 if (!ds)
3887 return -ENOMEM;
3888
Vivien Didelotfad09c72016-06-21 12:28:20 -04003889 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04003890 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04003891 ds->ageing_time_min = chip->info->age_time_coeff;
3892 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003893
3894 dev_set_drvdata(dev, ds);
3895
Vivien Didelot23c9ee42017-05-26 18:12:51 -04003896 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003897}
3898
Vivien Didelotfad09c72016-06-21 12:28:20 -04003899static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003900{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003901 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003902}
3903
Vivien Didelot57d32312016-06-20 13:13:58 -04003904static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003905{
3906 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003907 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003908 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003909 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003910 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02003911 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003912
Vivien Didelotcaac8542016-06-20 13:14:09 -04003913 compat_info = of_device_get_match_data(dev);
3914 if (!compat_info)
3915 return -EINVAL;
3916
Vivien Didelotfad09c72016-06-21 12:28:20 -04003917 chip = mv88e6xxx_alloc_chip(dev);
3918 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003919 return -ENOMEM;
3920
Vivien Didelotfad09c72016-06-21 12:28:20 -04003921 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003922
Vivien Didelotfad09c72016-06-21 12:28:20 -04003923 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003924 if (err)
3925 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003926
Andrew Lunnb4308f02016-11-21 23:26:55 +01003927 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
3928 if (IS_ERR(chip->reset))
3929 return PTR_ERR(chip->reset);
3930
Vivien Didelotfad09c72016-06-21 12:28:20 -04003931 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003932 if (err)
3933 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003934
Vivien Didelote57e5e72016-08-15 17:19:00 -04003935 mv88e6xxx_phy_init(chip);
3936
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003937 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003938 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04003939 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003940
Andrew Lunndc30c352016-10-16 19:56:49 +02003941 mutex_lock(&chip->reg_lock);
3942 err = mv88e6xxx_switch_reset(chip);
3943 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02003944 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02003945 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02003946
Andrew Lunndc30c352016-10-16 19:56:49 +02003947 chip->irq = of_irq_get(np, 0);
3948 if (chip->irq == -EPROBE_DEFER) {
3949 err = chip->irq;
3950 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02003951 }
3952
Andrew Lunndc30c352016-10-16 19:56:49 +02003953 if (chip->irq > 0) {
3954 /* Has to be performed before the MDIO bus is created,
3955 * because the PHYs will link there interrupts to these
3956 * interrupt controllers
3957 */
3958 mutex_lock(&chip->reg_lock);
3959 err = mv88e6xxx_g1_irq_setup(chip);
3960 mutex_unlock(&chip->reg_lock);
3961
3962 if (err)
3963 goto out;
3964
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003965 if (chip->info->g2_irqs > 0) {
Andrew Lunndc30c352016-10-16 19:56:49 +02003966 err = mv88e6xxx_g2_irq_setup(chip);
3967 if (err)
3968 goto out_g1_irq;
3969 }
3970 }
3971
Andrew Lunna3c53be52017-01-24 14:53:50 +01003972 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02003973 if (err)
3974 goto out_g2_irq;
3975
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003976 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02003977 if (err)
3978 goto out_mdio;
3979
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003980 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02003981
3982out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01003983 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02003984out_g2_irq:
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003985 if (chip->info->g2_irqs > 0 && chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02003986 mv88e6xxx_g2_irq_free(chip);
3987out_g1_irq:
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01003988 if (chip->irq > 0) {
3989 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01003990 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01003991 mutex_unlock(&chip->reg_lock);
3992 }
Andrew Lunndc30c352016-10-16 19:56:49 +02003993out:
3994 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003995}
3996
3997static void mv88e6xxx_remove(struct mdio_device *mdiodev)
3998{
3999 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004000 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004001
Andrew Lunn930188c2016-08-22 16:01:03 +02004002 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004003 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004004 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004005
Andrew Lunn467126442016-11-20 20:14:15 +01004006 if (chip->irq > 0) {
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004007 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004008 mv88e6xxx_g2_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004009 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004010 mv88e6xxx_g1_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004011 mutex_unlock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004012 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004013}
4014
4015static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004016 {
4017 .compatible = "marvell,mv88e6085",
4018 .data = &mv88e6xxx_table[MV88E6085],
4019 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004020 {
4021 .compatible = "marvell,mv88e6190",
4022 .data = &mv88e6xxx_table[MV88E6190],
4023 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004024 { /* sentinel */ },
4025};
4026
4027MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4028
4029static struct mdio_driver mv88e6xxx_driver = {
4030 .probe = mv88e6xxx_probe,
4031 .remove = mv88e6xxx_remove,
4032 .mdiodrv.driver = {
4033 .name = "mv88e6085",
4034 .of_match_table = mv88e6xxx_of_match,
4035 },
4036};
4037
Ben Hutchings98e67302011-11-25 14:36:19 +00004038static int __init mv88e6xxx_init(void)
4039{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004040 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004041 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004042}
4043module_init(mv88e6xxx_init);
4044
4045static void __exit mv88e6xxx_cleanup(void)
4046{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004047 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004048 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004049}
4050module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004051
4052MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4053MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4054MODULE_LICENSE("GPL");