blob: 09a66d4d9492d50857b283bc8b226d51b8abe7fb [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
Vivien Didelotf8b8b1c2017-10-16 11:12:18 -04001140 if (!ds->ports[port].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
Vivien Didelot774439e52017-06-08 18:34:08 -04001154 dev_err(ds->dev, "p%d: hw VLAN %d already used by %s\n",
1155 port, vlan.vid,
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,
1188 const struct switchdev_obj_port_vlan *vlan,
1189 struct switchdev_trans *trans)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001190{
Vivien Didelot04bed142016-08-31 18:06:13 -04001191 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001192 int err;
1193
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001194 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001195 return -EOPNOTSUPP;
1196
Vivien Didelotda9c3592016-02-12 12:09:40 -05001197 /* If the requested port doesn't belong to the same bridge as the VLAN
1198 * members, do not support it (yet) and fallback to software VLAN.
1199 */
1200 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1201 vlan->vid_end);
1202 if (err)
1203 return err;
1204
Vivien Didelot76e398a2015-11-01 12:33:55 -05001205 /* We don't need any dynamic resource from the kernel (yet),
1206 * so skip the prepare phase.
1207 */
1208 return 0;
1209}
1210
Vivien Didelotfad09c72016-06-21 12:28:20 -04001211static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001212 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001213{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001214 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001215 int err;
1216
Vivien Didelot567aa592017-05-01 14:05:25 -04001217 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001218 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001219 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001220
Vivien Didelotc91498e2017-06-07 18:12:13 -04001221 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001222
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001223 return mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001224}
1225
Vivien Didelotf81ec902016-05-09 13:22:58 -04001226static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
1227 const struct switchdev_obj_port_vlan *vlan,
1228 struct switchdev_trans *trans)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001229{
Vivien Didelot04bed142016-08-31 18:06:13 -04001230 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001231 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1232 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001233 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001234 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001235
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001236 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001237 return;
1238
Vivien Didelotc91498e2017-06-07 18:12:13 -04001239 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001240 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001241 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001242 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001243 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001244 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001245
Vivien Didelotfad09c72016-06-21 12:28:20 -04001246 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001247
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001248 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001249 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001250 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1251 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001252
Vivien Didelot77064f32016-11-04 03:23:30 +01001253 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001254 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1255 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001256
Vivien Didelotfad09c72016-06-21 12:28:20 -04001257 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001258}
1259
Vivien Didelotfad09c72016-06-21 12:28:20 -04001260static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001261 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001262{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001263 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001264 int i, err;
1265
Vivien Didelot567aa592017-05-01 14:05:25 -04001266 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001267 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001268 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001269
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001270 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001271 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001272 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001273
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001274 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001275
1276 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001277 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001278 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001279 if (vlan.member[i] !=
1280 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001281 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001282 break;
1283 }
1284 }
1285
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001286 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001287 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001288 return err;
1289
Vivien Didelote606ca32017-03-11 16:12:55 -05001290 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001291}
1292
Vivien Didelotf81ec902016-05-09 13:22:58 -04001293static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1294 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001295{
Vivien Didelot04bed142016-08-31 18:06:13 -04001296 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001297 u16 pvid, vid;
1298 int err = 0;
1299
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001300 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001301 return -EOPNOTSUPP;
1302
Vivien Didelotfad09c72016-06-21 12:28:20 -04001303 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001304
Vivien Didelot77064f32016-11-04 03:23:30 +01001305 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001306 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001307 goto unlock;
1308
Vivien Didelot76e398a2015-11-01 12:33:55 -05001309 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001310 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001311 if (err)
1312 goto unlock;
1313
1314 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001315 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001316 if (err)
1317 goto unlock;
1318 }
1319 }
1320
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001321unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001322 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001323
1324 return err;
1325}
1326
Vivien Didelot83dabd12016-08-31 11:50:04 -04001327static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1328 const unsigned char *addr, u16 vid,
1329 u8 state)
Vivien Didelotfd231c82015-08-10 09:09:50 -04001330{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001331 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot88472932016-09-19 19:56:11 -04001332 struct mv88e6xxx_atu_entry entry;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001333 int err;
Vivien Didelotfd231c82015-08-10 09:09:50 -04001334
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001335 /* Null VLAN ID corresponds to the port private database */
1336 if (vid == 0)
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001337 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001338 else
Vivien Didelot567aa592017-05-01 14:05:25 -04001339 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001340 if (err)
1341 return err;
1342
Vivien Didelot27c0e602017-06-15 12:14:01 -04001343 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001344 ether_addr_copy(entry.mac, addr);
1345 eth_addr_dec(entry.mac);
1346
1347 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
Vivien Didelot88472932016-09-19 19:56:11 -04001348 if (err)
1349 return err;
1350
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001351 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelot27c0e602017-06-15 12:14:01 -04001352 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001353 !ether_addr_equal(entry.mac, addr)) {
1354 memset(&entry, 0, sizeof(entry));
1355 ether_addr_copy(entry.mac, addr);
1356 }
1357
Vivien Didelot88472932016-09-19 19:56:11 -04001358 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelot27c0e602017-06-15 12:14:01 -04001359 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001360 entry.portvec &= ~BIT(port);
1361 if (!entry.portvec)
Vivien Didelot27c0e602017-06-15 12:14:01 -04001362 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelot88472932016-09-19 19:56:11 -04001363 } else {
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001364 entry.portvec |= BIT(port);
Vivien Didelot88472932016-09-19 19:56:11 -04001365 entry.state = state;
Vivien Didelotfd231c82015-08-10 09:09:50 -04001366 }
1367
Vivien Didelot9c13c022017-03-11 16:12:52 -05001368 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001369}
1370
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001371static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1372 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001373{
Vivien Didelot04bed142016-08-31 18:06:13 -04001374 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001375 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001376
Vivien Didelotfad09c72016-06-21 12:28:20 -04001377 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001378 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1379 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001380 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001381
1382 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001383}
1384
Vivien Didelotf81ec902016-05-09 13:22:58 -04001385static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001386 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001387{
Vivien Didelot04bed142016-08-31 18:06:13 -04001388 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001389 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001390
Vivien Didelotfad09c72016-06-21 12:28:20 -04001391 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001392 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001393 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001394 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001395
Vivien Didelot83dabd12016-08-31 11:50:04 -04001396 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001397}
1398
Vivien Didelot83dabd12016-08-31 11:50:04 -04001399static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1400 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001401 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001402{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001403 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001404 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001405 int err;
1406
Vivien Didelot27c0e602017-06-15 12:14:01 -04001407 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001408 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001409
1410 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001411 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001412 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001413 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001414
Vivien Didelot27c0e602017-06-15 12:14:01 -04001415 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001416 break;
1417
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001418 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001419 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001420
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001421 if (!is_unicast_ether_addr(addr.mac))
1422 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001423
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001424 is_static = (addr.state ==
1425 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1426 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001427 if (err)
1428 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001429 } while (!is_broadcast_ether_addr(addr.mac));
1430
1431 return err;
1432}
1433
Vivien Didelot83dabd12016-08-31 11:50:04 -04001434static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001435 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001436{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001437 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001438 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001439 };
1440 u16 fid;
1441 int err;
1442
1443 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001444 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001445 if (err)
1446 return err;
1447
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001448 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001449 if (err)
1450 return err;
1451
1452 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001453 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001454 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001455 if (err)
1456 return err;
1457
1458 if (!vlan.valid)
1459 break;
1460
1461 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001462 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001463 if (err)
1464 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001465 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001466
1467 return err;
1468}
1469
Vivien Didelotf81ec902016-05-09 13:22:58 -04001470static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001471 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001472{
Vivien Didelot04bed142016-08-31 18:06:13 -04001473 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001474 int err;
1475
Vivien Didelotfad09c72016-06-21 12:28:20 -04001476 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001477 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001478 mutex_unlock(&chip->reg_lock);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001479
1480 return err;
1481}
1482
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001483static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1484 struct net_device *br)
1485{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001486 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001487 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001488 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001489 int err;
1490
1491 /* Remap the Port VLAN of each local bridge group member */
1492 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1493 if (chip->ds->ports[port].bridge_dev == br) {
1494 err = mv88e6xxx_port_vlan_map(chip, port);
1495 if (err)
1496 return err;
1497 }
1498 }
1499
Vivien Didelote96a6e02017-03-30 17:37:13 -04001500 if (!mv88e6xxx_has_pvt(chip))
1501 return 0;
1502
1503 /* Remap the Port VLAN of each cross-chip bridge group member */
1504 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1505 ds = chip->ds->dst->ds[dev];
1506 if (!ds)
1507 break;
1508
1509 for (port = 0; port < ds->num_ports; ++port) {
1510 if (ds->ports[port].bridge_dev == br) {
1511 err = mv88e6xxx_pvt_map(chip, dev, port);
1512 if (err)
1513 return err;
1514 }
1515 }
1516 }
1517
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001518 return 0;
1519}
1520
Vivien Didelotf81ec902016-05-09 13:22:58 -04001521static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001522 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001523{
Vivien Didelot04bed142016-08-31 18:06:13 -04001524 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001525 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001526
Vivien Didelotfad09c72016-06-21 12:28:20 -04001527 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001528 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001529 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001530
Vivien Didelot466dfa02016-02-26 13:16:05 -05001531 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001532}
1533
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001534static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1535 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001536{
Vivien Didelot04bed142016-08-31 18:06:13 -04001537 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001538
Vivien Didelotfad09c72016-06-21 12:28:20 -04001539 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001540 if (mv88e6xxx_bridge_map(chip, br) ||
1541 mv88e6xxx_port_vlan_map(chip, port))
1542 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001543 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001544}
1545
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001546static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1547 int port, struct net_device *br)
1548{
1549 struct mv88e6xxx_chip *chip = ds->priv;
1550 int err;
1551
1552 if (!mv88e6xxx_has_pvt(chip))
1553 return 0;
1554
1555 mutex_lock(&chip->reg_lock);
1556 err = mv88e6xxx_pvt_map(chip, dev, port);
1557 mutex_unlock(&chip->reg_lock);
1558
1559 return err;
1560}
1561
1562static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1563 int port, struct net_device *br)
1564{
1565 struct mv88e6xxx_chip *chip = ds->priv;
1566
1567 if (!mv88e6xxx_has_pvt(chip))
1568 return;
1569
1570 mutex_lock(&chip->reg_lock);
1571 if (mv88e6xxx_pvt_map(chip, dev, port))
1572 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1573 mutex_unlock(&chip->reg_lock);
1574}
1575
Vivien Didelot17e708b2016-12-05 17:30:27 -05001576static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1577{
1578 if (chip->info->ops->reset)
1579 return chip->info->ops->reset(chip);
1580
1581 return 0;
1582}
1583
Vivien Didelot309eca62016-12-05 17:30:26 -05001584static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1585{
1586 struct gpio_desc *gpiod = chip->reset;
1587
1588 /* If there is a GPIO connected to the reset pin, toggle it */
1589 if (gpiod) {
1590 gpiod_set_value_cansleep(gpiod, 1);
1591 usleep_range(10000, 20000);
1592 gpiod_set_value_cansleep(gpiod, 0);
1593 usleep_range(10000, 20000);
1594 }
1595}
1596
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001597static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1598{
1599 int i, err;
1600
1601 /* Set all ports to the Disabled state */
1602 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001603 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001604 if (err)
1605 return err;
1606 }
1607
1608 /* Wait for transmit queues to drain,
1609 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1610 */
1611 usleep_range(2000, 4000);
1612
1613 return 0;
1614}
1615
Vivien Didelotfad09c72016-06-21 12:28:20 -04001616static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001617{
Vivien Didelota935c052016-09-29 12:21:53 -04001618 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001619
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001620 err = mv88e6xxx_disable_ports(chip);
1621 if (err)
1622 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001623
Vivien Didelot309eca62016-12-05 17:30:26 -05001624 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001625
Vivien Didelot17e708b2016-12-05 17:30:27 -05001626 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001627}
1628
Vivien Didelot43145572017-03-11 16:12:59 -05001629static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001630 enum mv88e6xxx_frame_mode frame,
1631 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001632{
1633 int err;
1634
Vivien Didelot43145572017-03-11 16:12:59 -05001635 if (!chip->info->ops->port_set_frame_mode)
1636 return -EOPNOTSUPP;
1637
1638 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001639 if (err)
1640 return err;
1641
Vivien Didelot43145572017-03-11 16:12:59 -05001642 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1643 if (err)
1644 return err;
1645
1646 if (chip->info->ops->port_set_ether_type)
1647 return chip->info->ops->port_set_ether_type(chip, port, etype);
1648
1649 return 0;
1650}
1651
1652static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1653{
1654 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001655 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001656 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001657}
1658
1659static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1660{
1661 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001662 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001663 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001664}
1665
1666static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1667{
1668 return mv88e6xxx_set_port_mode(chip, port,
1669 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001670 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1671 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001672}
1673
1674static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1675{
1676 if (dsa_is_dsa_port(chip->ds, port))
1677 return mv88e6xxx_set_port_mode_dsa(chip, port);
1678
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001679 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001680 return mv88e6xxx_set_port_mode_normal(chip, port);
1681
1682 /* Setup CPU port mode depending on its supported tag format */
1683 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1684 return mv88e6xxx_set_port_mode_dsa(chip, port);
1685
1686 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1687 return mv88e6xxx_set_port_mode_edsa(chip, port);
1688
1689 return -EINVAL;
1690}
1691
Vivien Didelotea698f42017-03-11 16:12:50 -05001692static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1693{
1694 bool message = dsa_is_dsa_port(chip->ds, port);
1695
1696 return mv88e6xxx_port_set_message_port(chip, port, message);
1697}
1698
Vivien Didelot601aeed2017-03-11 16:13:00 -05001699static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1700{
1701 bool flood = port == dsa_upstream_port(chip->ds);
1702
1703 /* Upstream ports flood frames with unknown unicast or multicast DA */
1704 if (chip->info->ops->port_set_egress_floods)
1705 return chip->info->ops->port_set_egress_floods(chip, port,
1706 flood, flood);
1707
1708 return 0;
1709}
1710
Andrew Lunn6d917822017-05-26 01:03:21 +02001711static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1712 bool on)
1713{
Vivien Didelot523a8902017-05-26 18:02:42 -04001714 if (chip->info->ops->serdes_power)
1715 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001716
Vivien Didelot523a8902017-05-26 18:02:42 -04001717 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001718}
1719
Vivien Didelotfad09c72016-06-21 12:28:20 -04001720static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001721{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001722 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001723 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001724 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001725
Vivien Didelotd78343d2016-11-04 03:23:36 +01001726 /* MAC Forcing register: don't force link, speed, duplex or flow control
1727 * state to any particular values on physical ports, but force the CPU
1728 * port and all DSA ports to their maximum bandwidth and full duplex.
1729 */
1730 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1731 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1732 SPEED_MAX, DUPLEX_FULL,
1733 PHY_INTERFACE_MODE_NA);
1734 else
1735 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1736 SPEED_UNFORCED, DUPLEX_UNFORCED,
1737 PHY_INTERFACE_MODE_NA);
1738 if (err)
1739 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001740
1741 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1742 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1743 * tunneling, determine priority by looking at 802.1p and IP
1744 * priority fields (IP prio has precedence), and set STP state
1745 * to Forwarding.
1746 *
1747 * If this is the CPU link, use DSA or EDSA tagging depending
1748 * on which tagging mode was configured.
1749 *
1750 * If this is a link to another switch, use DSA tagging mode.
1751 *
1752 * If this is the upstream port for this switch, enable
1753 * forwarding of unknown unicasts and multicasts.
1754 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001755 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1756 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1757 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1758 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001759 if (err)
1760 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001761
Vivien Didelot601aeed2017-03-11 16:13:00 -05001762 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001763 if (err)
1764 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001765
Vivien Didelot601aeed2017-03-11 16:13:00 -05001766 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001767 if (err)
1768 return err;
1769
Andrew Lunn04aca992017-05-26 01:03:24 +02001770 /* Enable the SERDES interface for DSA and CPU ports. Normal
1771 * ports SERDES are enabled when the port is enabled, thus
1772 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001773 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001774 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1775 err = mv88e6xxx_serdes_power(chip, port, true);
1776 if (err)
1777 return err;
1778 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001779
Vivien Didelot8efdda42015-08-13 12:52:23 -04001780 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001781 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001782 * untagged frames on this port, do a destination address lookup on all
1783 * received packets as usual, disable ARP mirroring and don't send a
1784 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001785 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001786 err = mv88e6xxx_port_set_map_da(chip, port);
1787 if (err)
1788 return err;
1789
Andrew Lunn54d792f2015-05-06 01:09:47 +02001790 reg = 0;
Andrew Lunna23b2962017-02-04 20:15:28 +01001791 if (chip->info->ops->port_set_upstream_port) {
1792 err = chip->info->ops->port_set_upstream_port(
1793 chip, port, dsa_upstream_port(ds));
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001794 if (err)
1795 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001796 }
1797
Andrew Lunna23b2962017-02-04 20:15:28 +01001798 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001799 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001800 if (err)
1801 return err;
1802
Vivien Didelotcd782652017-06-08 18:34:13 -04001803 if (chip->info->ops->port_set_jumbo_size) {
1804 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001805 if (err)
1806 return err;
1807 }
1808
Andrew Lunn54d792f2015-05-06 01:09:47 +02001809 /* Port Association Vector: when learning source addresses
1810 * of packets, add the address to the address database using
1811 * a port bitmap that has only the bit for this port set and
1812 * the other bits clear.
1813 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001814 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001815 /* Disable learning for CPU port */
1816 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001817 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001818
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001819 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1820 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001821 if (err)
1822 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001823
1824 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001825 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1826 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001827 if (err)
1828 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001829
Vivien Didelot08984322017-06-08 18:34:12 -04001830 if (chip->info->ops->port_pause_limit) {
1831 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001832 if (err)
1833 return err;
1834 }
1835
Vivien Didelotc8c94892017-03-11 16:13:01 -05001836 if (chip->info->ops->port_disable_learn_limit) {
1837 err = chip->info->ops->port_disable_learn_limit(chip, port);
1838 if (err)
1839 return err;
1840 }
1841
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001842 if (chip->info->ops->port_disable_pri_override) {
1843 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001844 if (err)
1845 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001846 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001847
Andrew Lunnef0a7312016-12-03 04:35:16 +01001848 if (chip->info->ops->port_tag_remap) {
1849 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001850 if (err)
1851 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001852 }
1853
Andrew Lunnef70b112016-12-03 04:45:18 +01001854 if (chip->info->ops->port_egress_rate_limiting) {
1855 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001856 if (err)
1857 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001858 }
1859
Vivien Didelotea698f42017-03-11 16:12:50 -05001860 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001861 if (err)
1862 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001863
Vivien Didelot207afda2016-04-14 14:42:09 -04001864 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001865 * database, and allow bidirectional communication between the
1866 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001867 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001868 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001869 if (err)
1870 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001871
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001872 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001873 if (err)
1874 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001875
1876 /* Default VLAN ID and priority: don't set a default VLAN
1877 * ID, and set the default packet priority to zero.
1878 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04001879 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02001880}
1881
Andrew Lunn04aca992017-05-26 01:03:24 +02001882static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
1883 struct phy_device *phydev)
1884{
1885 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04001886 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02001887
1888 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001889 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02001890 mutex_unlock(&chip->reg_lock);
1891
1892 return err;
1893}
1894
1895static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
1896 struct phy_device *phydev)
1897{
1898 struct mv88e6xxx_chip *chip = ds->priv;
1899
1900 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001901 if (mv88e6xxx_serdes_power(chip, port, false))
1902 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02001903 mutex_unlock(&chip->reg_lock);
1904}
1905
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001906static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
1907 unsigned int ageing_time)
1908{
Vivien Didelot04bed142016-08-31 18:06:13 -04001909 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001910 int err;
1911
1912 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05001913 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001914 mutex_unlock(&chip->reg_lock);
1915
1916 return err;
1917}
1918
Vivien Didelot97299342016-07-18 20:45:30 -04001919static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04001920{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001921 struct dsa_switch *ds = chip->ds;
Vivien Didelotb0745e872016-05-09 13:22:53 -04001922 u32 upstream_port = dsa_upstream_port(ds);
Vivien Didelot08a01262016-05-09 13:22:50 -04001923 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04001924
Vivien Didelotfa8d1172017-06-08 18:34:11 -04001925 if (chip->info->ops->set_cpu_port) {
1926 err = chip->info->ops->set_cpu_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01001927 if (err)
1928 return err;
1929 }
1930
Vivien Didelotfa8d1172017-06-08 18:34:11 -04001931 if (chip->info->ops->set_egress_port) {
1932 err = chip->info->ops->set_egress_port(chip, upstream_port);
Andrew Lunn33641992016-12-03 04:35:17 +01001933 if (err)
1934 return err;
1935 }
Vivien Didelotb0745e872016-05-09 13:22:53 -04001936
Vivien Didelot50484ff2016-05-09 13:22:54 -04001937 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04001938 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
1939 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04001940 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04001941 if (err)
1942 return err;
1943
Vivien Didelot08a01262016-05-09 13:22:50 -04001944 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04001945 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001946 if (err)
1947 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001948 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001949 if (err)
1950 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001951 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001952 if (err)
1953 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001954 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001955 if (err)
1956 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001957 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04001958 if (err)
1959 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001960 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04001961 if (err)
1962 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001963 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04001964 if (err)
1965 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001966 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04001967 if (err)
1968 return err;
1969
1970 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04001971 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04001972 if (err)
1973 return err;
1974
Andrew Lunnde2273872016-11-21 23:27:01 +01001975 /* Initialize the statistics unit */
1976 err = mv88e6xxx_stats_set_histogram(chip);
1977 if (err)
1978 return err;
1979
Vivien Didelot97299342016-07-18 20:45:30 -04001980 /* Clear the statistics counters for all ports */
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001981 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_STATS_OP,
1982 MV88E6XXX_G1_STATS_OP_BUSY |
1983 MV88E6XXX_G1_STATS_OP_FLUSH_ALL);
Vivien Didelot97299342016-07-18 20:45:30 -04001984 if (err)
1985 return err;
1986
1987 /* Wait for the flush to complete. */
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +01001988 err = mv88e6xxx_g1_stats_wait(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04001989 if (err)
1990 return err;
1991
1992 return 0;
1993}
1994
Vivien Didelotf81ec902016-05-09 13:22:58 -04001995static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07001996{
Vivien Didelot04bed142016-08-31 18:06:13 -04001997 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04001998 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04001999 int i;
2000
Vivien Didelotfad09c72016-06-21 12:28:20 -04002001 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002002 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002003
Vivien Didelotfad09c72016-06-21 12:28:20 -04002004 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002005
Vivien Didelot97299342016-07-18 20:45:30 -04002006 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002007 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002008 if (dsa_is_unused_port(ds, i))
2009 continue;
2010
Vivien Didelot97299342016-07-18 20:45:30 -04002011 err = mv88e6xxx_setup_port(chip, i);
2012 if (err)
2013 goto unlock;
2014 }
2015
2016 /* Setup Switch Global 1 Registers */
2017 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002018 if (err)
2019 goto unlock;
2020
Vivien Didelot97299342016-07-18 20:45:30 -04002021 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002022 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002023 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002024 if (err)
2025 goto unlock;
2026 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002027
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002028 err = mv88e6xxx_irl_setup(chip);
2029 if (err)
2030 goto unlock;
2031
Vivien Didelot04a69a12017-10-13 14:18:05 -04002032 err = mv88e6xxx_mac_setup(chip);
2033 if (err)
2034 goto unlock;
2035
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002036 err = mv88e6xxx_phy_setup(chip);
2037 if (err)
2038 goto unlock;
2039
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002040 err = mv88e6xxx_vtu_setup(chip);
2041 if (err)
2042 goto unlock;
2043
Vivien Didelot81228992017-03-30 17:37:08 -04002044 err = mv88e6xxx_pvt_setup(chip);
2045 if (err)
2046 goto unlock;
2047
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002048 err = mv88e6xxx_atu_setup(chip);
2049 if (err)
2050 goto unlock;
2051
Vivien Didelot9e907d72017-07-17 13:03:43 -04002052 err = mv88e6xxx_pot_setup(chip);
2053 if (err)
2054 goto unlock;
2055
Vivien Didelot51c901a2017-07-17 13:03:41 -04002056 err = mv88e6xxx_rsvd2cpu_setup(chip);
2057 if (err)
2058 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002059
Vivien Didelot6b17e862015-08-13 12:52:18 -04002060unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002061 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002062
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002063 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002064}
2065
Vivien Didelote57e5e72016-08-15 17:19:00 -04002066static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002067{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002068 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2069 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002070 u16 val;
2071 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002072
Andrew Lunnee26a222017-01-24 14:53:48 +01002073 if (!chip->info->ops->phy_read)
2074 return -EOPNOTSUPP;
2075
Vivien Didelotfad09c72016-06-21 12:28:20 -04002076 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002077 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002078 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002079
Andrew Lunnda9f3302017-02-01 03:40:05 +01002080 if (reg == MII_PHYSID2) {
2081 /* Some internal PHYS don't have a model number. Use
2082 * the mv88e6390 family model number instead.
2083 */
2084 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002085 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002086 }
2087
Vivien Didelote57e5e72016-08-15 17:19:00 -04002088 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002089}
2090
Vivien Didelote57e5e72016-08-15 17:19:00 -04002091static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002092{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002093 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2094 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002095 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002096
Andrew Lunnee26a222017-01-24 14:53:48 +01002097 if (!chip->info->ops->phy_write)
2098 return -EOPNOTSUPP;
2099
Vivien Didelotfad09c72016-06-21 12:28:20 -04002100 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002101 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002102 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002103
2104 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002105}
2106
Vivien Didelotfad09c72016-06-21 12:28:20 -04002107static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002108 struct device_node *np,
2109 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002110{
2111 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002112 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002113 struct mii_bus *bus;
2114 int err;
2115
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002116 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002117 if (!bus)
2118 return -ENOMEM;
2119
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002120 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002121 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002122 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002123 INIT_LIST_HEAD(&mdio_bus->list);
2124 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002125
Andrew Lunnb516d452016-06-04 21:17:06 +02002126 if (np) {
2127 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002128 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002129 } else {
2130 bus->name = "mv88e6xxx SMI";
2131 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2132 }
2133
2134 bus->read = mv88e6xxx_mdio_read;
2135 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002136 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002137
Andrew Lunna3c53be52017-01-24 14:53:50 +01002138 if (np)
2139 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002140 else
2141 err = mdiobus_register(bus);
2142 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002143 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002144 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002145 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002146
2147 if (external)
2148 list_add_tail(&mdio_bus->list, &chip->mdios);
2149 else
2150 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002151
2152 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002153}
2154
Andrew Lunna3c53be52017-01-24 14:53:50 +01002155static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2156 { .compatible = "marvell,mv88e6xxx-mdio-external",
2157 .data = (void *)true },
2158 { },
2159};
2160
2161static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2162 struct device_node *np)
2163{
2164 const struct of_device_id *match;
2165 struct device_node *child;
2166 int err;
2167
2168 /* Always register one mdio bus for the internal/default mdio
2169 * bus. This maybe represented in the device tree, but is
2170 * optional.
2171 */
2172 child = of_get_child_by_name(np, "mdio");
2173 err = mv88e6xxx_mdio_register(chip, child, false);
2174 if (err)
2175 return err;
2176
2177 /* Walk the device tree, and see if there are any other nodes
2178 * which say they are compatible with the external mdio
2179 * bus.
2180 */
2181 for_each_available_child_of_node(np, child) {
2182 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2183 if (match) {
2184 err = mv88e6xxx_mdio_register(chip, child, true);
2185 if (err)
2186 return err;
2187 }
2188 }
2189
2190 return 0;
2191}
2192
2193static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
Andrew Lunnb516d452016-06-04 21:17:06 +02002194
2195{
Andrew Lunna3c53be52017-01-24 14:53:50 +01002196 struct mv88e6xxx_mdio_bus *mdio_bus;
2197 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002198
Andrew Lunna3c53be52017-01-24 14:53:50 +01002199 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2200 bus = mdio_bus->bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002201
Andrew Lunna3c53be52017-01-24 14:53:50 +01002202 mdiobus_unregister(bus);
2203 }
Andrew Lunnb516d452016-06-04 21:17:06 +02002204}
2205
Vivien Didelot855b1932016-07-20 18:18:35 -04002206static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2207{
Vivien Didelot04bed142016-08-31 18:06:13 -04002208 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002209
2210 return chip->eeprom_len;
2211}
2212
Vivien Didelot855b1932016-07-20 18:18:35 -04002213static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2214 struct ethtool_eeprom *eeprom, u8 *data)
2215{
Vivien Didelot04bed142016-08-31 18:06:13 -04002216 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002217 int err;
2218
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002219 if (!chip->info->ops->get_eeprom)
2220 return -EOPNOTSUPP;
2221
Vivien Didelot855b1932016-07-20 18:18:35 -04002222 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002223 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002224 mutex_unlock(&chip->reg_lock);
2225
2226 if (err)
2227 return err;
2228
2229 eeprom->magic = 0xc3ec4951;
2230
2231 return 0;
2232}
2233
Vivien Didelot855b1932016-07-20 18:18:35 -04002234static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2235 struct ethtool_eeprom *eeprom, u8 *data)
2236{
Vivien Didelot04bed142016-08-31 18:06:13 -04002237 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002238 int err;
2239
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002240 if (!chip->info->ops->set_eeprom)
2241 return -EOPNOTSUPP;
2242
Vivien Didelot855b1932016-07-20 18:18:35 -04002243 if (eeprom->magic != 0xc3ec4951)
2244 return -EINVAL;
2245
2246 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002247 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002248 mutex_unlock(&chip->reg_lock);
2249
2250 return err;
2251}
2252
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002253static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002254 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002255 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002256 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002257 .phy_read = mv88e6185_phy_ppu_read,
2258 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002259 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002260 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002261 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002262 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002263 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002264 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002265 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002266 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002267 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002268 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002269 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002270 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002271 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2272 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002273 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002274 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2275 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002276 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002277 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002278 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002279 .ppu_enable = mv88e6185_g1_ppu_enable,
2280 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002281 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002282 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002283 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002284};
2285
2286static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002287 /* MV88E6XXX_FAMILY_6095 */
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 Lunn56995cb2016-12-03 04:35:19 +01002294 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002295 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002296 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002297 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002298 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2299 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002300 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002301 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002302 .ppu_enable = mv88e6185_g1_ppu_enable,
2303 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002304 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002305 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002306 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002307};
2308
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002309static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002310 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002311 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002312 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2313 .phy_read = mv88e6xxx_g2_smi_phy_read,
2314 .phy_write = mv88e6xxx_g2_smi_phy_write,
2315 .port_set_link = mv88e6xxx_port_set_link,
2316 .port_set_duplex = mv88e6xxx_port_set_duplex,
2317 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002318 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002319 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002320 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002321 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002322 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002323 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002324 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002325 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002326 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002327 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
2328 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2329 .stats_get_strings = mv88e6095_stats_get_strings,
2330 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002331 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2332 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002333 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002334 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002335 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002336 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002337 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002338 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002339};
2340
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002341static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002342 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002343 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002344 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002345 .phy_read = mv88e6xxx_g2_smi_phy_read,
2346 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002347 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002348 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002349 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002350 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002351 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002352 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002353 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002354 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002355 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2356 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002357 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002358 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2359 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002360 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002361 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002362 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002363 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002364 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002365 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002366};
2367
2368static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002369 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002370 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002371 .phy_read = mv88e6185_phy_ppu_read,
2372 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002373 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002374 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002375 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002376 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002377 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002378 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002379 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002380 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002381 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002382 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002383 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002384 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002385 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2386 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002387 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002388 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2389 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002390 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002391 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002392 .ppu_enable = mv88e6185_g1_ppu_enable,
2393 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002394 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002395 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002396 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002397};
2398
Vivien Didelot990e27b2017-03-28 13:50:32 -04002399static const struct mv88e6xxx_ops mv88e6141_ops = {
2400 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002401 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002402 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2403 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2404 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2405 .phy_read = mv88e6xxx_g2_smi_phy_read,
2406 .phy_write = mv88e6xxx_g2_smi_phy_write,
2407 .port_set_link = mv88e6xxx_port_set_link,
2408 .port_set_duplex = mv88e6xxx_port_set_duplex,
2409 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2410 .port_set_speed = mv88e6390_port_set_speed,
2411 .port_tag_remap = mv88e6095_port_tag_remap,
2412 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2413 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2414 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002415 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002416 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002417 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002418 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2419 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2420 .stats_snapshot = mv88e6390_g1_stats_snapshot,
2421 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2422 .stats_get_strings = mv88e6320_stats_get_strings,
2423 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002424 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2425 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002426 .watchdog_ops = &mv88e6390_watchdog_ops,
2427 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002428 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002429 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002430 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002431 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002432};
2433
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002434static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002435 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002436 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002437 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002438 .phy_read = mv88e6xxx_g2_smi_phy_read,
2439 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002440 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002441 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002442 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002443 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002444 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002445 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002446 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002447 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002448 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002449 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002450 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002451 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002452 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002453 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2454 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002455 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002456 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2457 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002458 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002459 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002460 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002461 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002462 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002463 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002464};
2465
2466static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002467 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002468 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002469 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002470 .phy_read = mv88e6165_phy_read,
2471 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002472 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002473 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002474 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002475 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002476 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002477 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002478 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2479 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002480 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002481 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2482 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002483 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002484 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002485 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002486 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002487 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002488 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002489};
2490
2491static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002492 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002493 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002494 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002495 .phy_read = mv88e6xxx_g2_smi_phy_read,
2496 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002497 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002498 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002499 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002500 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002501 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002502 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002503 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002504 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002505 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002506 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002507 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002508 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002509 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002510 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002511 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2512 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002513 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002514 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2515 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002516 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002517 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002518 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002519 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002520 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002521 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002522};
2523
2524static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002525 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002526 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002527 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2528 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002529 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002530 .phy_read = mv88e6xxx_g2_smi_phy_read,
2531 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002532 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002533 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002534 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002535 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002536 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002537 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002538 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002539 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002540 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002541 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002542 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002543 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002544 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002545 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002546 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2547 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002548 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002549 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2550 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002551 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002552 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002553 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002554 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002555 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002556 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002557 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002558};
2559
2560static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002561 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002562 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002563 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002564 .phy_read = mv88e6xxx_g2_smi_phy_read,
2565 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002566 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002567 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002568 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002569 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002570 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002571 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002572 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002573 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002574 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002575 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002576 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002577 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002578 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002579 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002580 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2581 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002582 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002583 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2584 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002585 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002586 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002587 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002588 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002589 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002590 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002591};
2592
2593static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002594 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002595 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002596 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2597 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002598 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002599 .phy_read = mv88e6xxx_g2_smi_phy_read,
2600 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002601 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002602 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002603 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002604 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002605 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002606 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002607 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002608 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002609 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002610 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002611 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002612 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002613 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002614 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002615 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2616 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002617 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002618 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2619 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002620 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002621 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002622 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002623 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002624 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002625 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002626 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002627};
2628
2629static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002630 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002631 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002632 .phy_read = mv88e6185_phy_ppu_read,
2633 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002634 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002635 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002636 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002637 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002638 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002639 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002640 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002641 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002642 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2643 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002644 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002645 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2646 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002647 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002648 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002649 .ppu_enable = mv88e6185_g1_ppu_enable,
2650 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002651 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002652 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002653 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002654};
2655
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002656static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002657 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002658 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002659 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2660 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002661 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2662 .phy_read = mv88e6xxx_g2_smi_phy_read,
2663 .phy_write = mv88e6xxx_g2_smi_phy_write,
2664 .port_set_link = mv88e6xxx_port_set_link,
2665 .port_set_duplex = mv88e6xxx_port_set_duplex,
2666 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2667 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002668 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002669 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002670 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002671 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002672 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002673 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002674 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002675 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002676 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002677 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2678 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002679 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002680 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2681 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002682 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002683 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002684 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002685 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002686 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2687 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002688 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002689};
2690
2691static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002692 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002693 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002694 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2695 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002696 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2697 .phy_read = mv88e6xxx_g2_smi_phy_read,
2698 .phy_write = mv88e6xxx_g2_smi_phy_write,
2699 .port_set_link = mv88e6xxx_port_set_link,
2700 .port_set_duplex = mv88e6xxx_port_set_duplex,
2701 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2702 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002703 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002704 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002705 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002706 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002707 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002708 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002709 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002710 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002711 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002712 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2713 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002714 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002715 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2716 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002717 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002718 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002719 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002720 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002721 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2722 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002723 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002724};
2725
2726static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002727 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002728 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002729 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2730 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002731 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2732 .phy_read = mv88e6xxx_g2_smi_phy_read,
2733 .phy_write = mv88e6xxx_g2_smi_phy_write,
2734 .port_set_link = mv88e6xxx_port_set_link,
2735 .port_set_duplex = mv88e6xxx_port_set_duplex,
2736 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2737 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002738 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002739 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002740 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002741 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002742 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002743 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002744 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002745 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002746 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002747 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2748 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002749 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002750 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2751 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002752 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002753 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002754 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002755 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002756 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2757 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002758 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002759};
2760
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002761static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002762 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002763 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002764 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2765 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002766 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002767 .phy_read = mv88e6xxx_g2_smi_phy_read,
2768 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002769 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002770 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002771 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002772 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002773 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002774 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002775 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002776 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002777 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002778 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002779 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002780 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002781 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002782 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002783 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2784 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002785 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002786 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2787 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002788 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002789 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002790 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002791 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002792 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002793 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002794 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002795};
2796
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002797static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002798 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002799 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002800 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2801 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002802 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2803 .phy_read = mv88e6xxx_g2_smi_phy_read,
2804 .phy_write = mv88e6xxx_g2_smi_phy_write,
2805 .port_set_link = mv88e6xxx_port_set_link,
2806 .port_set_duplex = mv88e6xxx_port_set_duplex,
2807 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2808 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002809 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002810 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002811 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002812 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002813 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002814 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002815 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002816 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002817 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002818 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002819 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2820 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002821 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002822 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2823 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002824 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002825 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002826 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002827 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002828 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2829 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002830 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002831};
2832
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002833static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002834 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002835 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002836 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2837 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002838 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002839 .phy_read = mv88e6xxx_g2_smi_phy_read,
2840 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002841 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002842 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002843 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002844 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002845 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002846 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002847 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002848 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002849 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002850 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002851 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002852 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002853 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002854 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2855 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002856 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002857 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2858 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002859 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002860 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002861 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002862 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002863 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002864};
2865
2866static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04002867 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002868 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002869 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2870 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002871 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002872 .phy_read = mv88e6xxx_g2_smi_phy_read,
2873 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002874 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002875 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002876 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002877 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002878 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002879 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002880 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002881 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002882 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002883 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002884 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002885 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002886 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002887 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2888 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002889 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002890 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2891 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002892 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002893 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002894 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002895};
2896
Vivien Didelot16e329a2017-03-28 13:50:33 -04002897static const struct mv88e6xxx_ops mv88e6341_ops = {
2898 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002899 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002900 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2901 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2902 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2903 .phy_read = mv88e6xxx_g2_smi_phy_read,
2904 .phy_write = mv88e6xxx_g2_smi_phy_write,
2905 .port_set_link = mv88e6xxx_port_set_link,
2906 .port_set_duplex = mv88e6xxx_port_set_duplex,
2907 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2908 .port_set_speed = mv88e6390_port_set_speed,
2909 .port_tag_remap = mv88e6095_port_tag_remap,
2910 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2911 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2912 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002913 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002914 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002915 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002916 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2917 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2918 .stats_snapshot = mv88e6390_g1_stats_snapshot,
2919 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2920 .stats_get_strings = mv88e6320_stats_get_strings,
2921 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002922 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2923 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002924 .watchdog_ops = &mv88e6390_watchdog_ops,
2925 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002926 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002927 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002928 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002929 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002930};
2931
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002932static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002933 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002934 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002935 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002936 .phy_read = mv88e6xxx_g2_smi_phy_read,
2937 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002938 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002939 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002940 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002941 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002942 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002943 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002944 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002945 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002946 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002947 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002948 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002949 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002950 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002951 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002952 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2953 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002954 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002955 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2956 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002957 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002958 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002959 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002960 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002961 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002962 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002963};
2964
2965static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002966 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002967 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002968 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002969 .phy_read = mv88e6xxx_g2_smi_phy_read,
2970 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002971 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002972 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002973 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002974 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002975 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002976 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002977 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002978 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002979 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002980 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002981 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002982 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002983 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002984 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01002985 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2986 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002987 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002988 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2989 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002990 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002991 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002992 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002993 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002994 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002995 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002996};
2997
2998static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002999 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003000 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003001 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3002 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003003 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003004 .phy_read = mv88e6xxx_g2_smi_phy_read,
3005 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003006 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003007 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003008 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003009 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003010 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003011 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003012 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003013 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003014 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003015 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003016 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003017 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003018 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003019 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunndfafe442016-11-21 23:27:02 +01003020 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3021 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003022 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003023 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3024 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003025 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003026 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003027 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003028 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003029 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003030 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003031 .serdes_power = mv88e6352_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003032};
3033
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003034static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003035 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003036 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003037 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3038 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003039 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3040 .phy_read = mv88e6xxx_g2_smi_phy_read,
3041 .phy_write = mv88e6xxx_g2_smi_phy_write,
3042 .port_set_link = mv88e6xxx_port_set_link,
3043 .port_set_duplex = mv88e6xxx_port_set_duplex,
3044 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3045 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003046 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003047 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003048 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003049 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003050 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003051 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003052 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003053 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003054 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003055 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003056 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003057 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003058 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3059 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003060 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003061 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3062 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003063 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003064 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003065 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003066 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003067 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3068 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003069 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003070};
3071
3072static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003073 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003074 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003075 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3076 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003077 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3078 .phy_read = mv88e6xxx_g2_smi_phy_read,
3079 .phy_write = mv88e6xxx_g2_smi_phy_write,
3080 .port_set_link = mv88e6xxx_port_set_link,
3081 .port_set_duplex = mv88e6xxx_port_set_duplex,
3082 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3083 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003084 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003085 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003086 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003087 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003088 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003089 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003090 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003091 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003092 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003093 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003094 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003095 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003096 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3097 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003098 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003099 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3100 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003101 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003102 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003103 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003104 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003105 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3106 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003107 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003108};
3109
Vivien Didelotf81ec902016-05-09 13:22:58 -04003110static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3111 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003112 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003113 .family = MV88E6XXX_FAMILY_6097,
3114 .name = "Marvell 88E6085",
3115 .num_databases = 4096,
3116 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003117 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003118 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003119 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003120 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003121 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003122 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003123 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003124 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003125 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003126 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003127 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003128 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003129 },
3130
3131 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003132 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003133 .family = MV88E6XXX_FAMILY_6095,
3134 .name = "Marvell 88E6095/88E6095F",
3135 .num_databases = 256,
3136 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003137 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003138 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003139 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003140 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003141 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003142 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003143 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003144 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003145 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003146 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003147 },
3148
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003149 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003150 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003151 .family = MV88E6XXX_FAMILY_6097,
3152 .name = "Marvell 88E6097/88E6097F",
3153 .num_databases = 4096,
3154 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003155 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003156 .port_base_addr = 0x10,
3157 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003158 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003159 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003160 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003161 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003162 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003163 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003164 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003165 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003166 .ops = &mv88e6097_ops,
3167 },
3168
Vivien Didelotf81ec902016-05-09 13:22:58 -04003169 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003170 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003171 .family = MV88E6XXX_FAMILY_6165,
3172 .name = "Marvell 88E6123",
3173 .num_databases = 4096,
3174 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003175 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003176 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003177 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003178 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003179 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003180 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003181 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003182 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003183 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003184 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003185 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003186 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003187 },
3188
3189 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003190 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003191 .family = MV88E6XXX_FAMILY_6185,
3192 .name = "Marvell 88E6131",
3193 .num_databases = 256,
3194 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003195 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003196 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003197 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003198 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003199 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003200 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003201 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003202 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003203 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003204 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003205 },
3206
Vivien Didelot990e27b2017-03-28 13:50:32 -04003207 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003208 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003209 .family = MV88E6XXX_FAMILY_6341,
3210 .name = "Marvell 88E6341",
3211 .num_databases = 4096,
3212 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003213 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003214 .port_base_addr = 0x10,
3215 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003216 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003217 .age_time_coeff = 3750,
3218 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003219 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003220 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003221 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003222 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003223 .ops = &mv88e6141_ops,
3224 },
3225
Vivien Didelotf81ec902016-05-09 13:22:58 -04003226 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003227 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003228 .family = MV88E6XXX_FAMILY_6165,
3229 .name = "Marvell 88E6161",
3230 .num_databases = 4096,
3231 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003232 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003233 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003234 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003235 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003236 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003237 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003238 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003239 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003240 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003241 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003242 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003243 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003244 },
3245
3246 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003247 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003248 .family = MV88E6XXX_FAMILY_6165,
3249 .name = "Marvell 88E6165",
3250 .num_databases = 4096,
3251 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003252 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003253 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003254 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003255 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003256 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003257 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003258 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003259 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003260 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003261 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003262 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003263 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003264 },
3265
3266 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003267 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003268 .family = MV88E6XXX_FAMILY_6351,
3269 .name = "Marvell 88E6171",
3270 .num_databases = 4096,
3271 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003272 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003273 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003274 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003275 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003276 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003277 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003278 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003279 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003280 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003281 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003282 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003283 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003284 },
3285
3286 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003287 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003288 .family = MV88E6XXX_FAMILY_6352,
3289 .name = "Marvell 88E6172",
3290 .num_databases = 4096,
3291 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003292 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003293 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003294 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003295 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003296 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003297 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003298 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003299 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003300 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003301 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003302 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003303 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003304 },
3305
3306 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003307 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003308 .family = MV88E6XXX_FAMILY_6351,
3309 .name = "Marvell 88E6175",
3310 .num_databases = 4096,
3311 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003312 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003313 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003314 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003315 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003316 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003317 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003318 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003319 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003320 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003321 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003322 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003323 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003324 },
3325
3326 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003327 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003328 .family = MV88E6XXX_FAMILY_6352,
3329 .name = "Marvell 88E6176",
3330 .num_databases = 4096,
3331 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003332 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003333 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003334 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003335 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003336 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003337 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003338 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003339 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003340 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003341 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003342 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003343 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003344 },
3345
3346 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003347 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003348 .family = MV88E6XXX_FAMILY_6185,
3349 .name = "Marvell 88E6185",
3350 .num_databases = 256,
3351 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003352 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003353 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003354 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003355 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003356 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003357 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003358 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003359 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003360 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003361 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003362 },
3363
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003364 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003365 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003366 .family = MV88E6XXX_FAMILY_6390,
3367 .name = "Marvell 88E6190",
3368 .num_databases = 4096,
3369 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003370 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003371 .port_base_addr = 0x0,
3372 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003373 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003374 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003375 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003376 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003377 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003378 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003379 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003380 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003381 .ops = &mv88e6190_ops,
3382 },
3383
3384 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003385 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003386 .family = MV88E6XXX_FAMILY_6390,
3387 .name = "Marvell 88E6190X",
3388 .num_databases = 4096,
3389 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003390 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003391 .port_base_addr = 0x0,
3392 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003393 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003394 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003395 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003396 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003397 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003398 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003399 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003400 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003401 .ops = &mv88e6190x_ops,
3402 },
3403
3404 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003405 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003406 .family = MV88E6XXX_FAMILY_6390,
3407 .name = "Marvell 88E6191",
3408 .num_databases = 4096,
3409 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003410 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003411 .port_base_addr = 0x0,
3412 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003413 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003414 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003415 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003416 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003417 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003418 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003419 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003420 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003421 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003422 },
3423
Vivien Didelotf81ec902016-05-09 13:22:58 -04003424 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003425 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003426 .family = MV88E6XXX_FAMILY_6352,
3427 .name = "Marvell 88E6240",
3428 .num_databases = 4096,
3429 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003430 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003431 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003432 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003433 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003434 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003435 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003436 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003437 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003438 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003439 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003440 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003441 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003442 },
3443
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003444 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003445 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003446 .family = MV88E6XXX_FAMILY_6390,
3447 .name = "Marvell 88E6290",
3448 .num_databases = 4096,
3449 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003450 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003451 .port_base_addr = 0x0,
3452 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003453 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003454 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003455 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003456 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003457 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003458 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003459 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003460 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003461 .ops = &mv88e6290_ops,
3462 },
3463
Vivien Didelotf81ec902016-05-09 13:22:58 -04003464 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003465 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003466 .family = MV88E6XXX_FAMILY_6320,
3467 .name = "Marvell 88E6320",
3468 .num_databases = 4096,
3469 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003470 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003471 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003472 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003473 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003474 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003475 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003476 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003477 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003478 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003479 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003480 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003481 },
3482
3483 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003484 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003485 .family = MV88E6XXX_FAMILY_6320,
3486 .name = "Marvell 88E6321",
3487 .num_databases = 4096,
3488 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003489 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003490 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003491 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003492 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003493 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003494 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003495 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003496 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003497 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003498 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003499 },
3500
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003501 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003502 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003503 .family = MV88E6XXX_FAMILY_6341,
3504 .name = "Marvell 88E6341",
3505 .num_databases = 4096,
3506 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003507 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003508 .port_base_addr = 0x10,
3509 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003510 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003511 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003512 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003513 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003514 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003515 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003516 .tag_protocol = DSA_TAG_PROTO_EDSA,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003517 .ops = &mv88e6341_ops,
3518 },
3519
Vivien Didelotf81ec902016-05-09 13:22:58 -04003520 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003521 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003522 .family = MV88E6XXX_FAMILY_6351,
3523 .name = "Marvell 88E6350",
3524 .num_databases = 4096,
3525 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003526 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003527 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003528 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003529 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003530 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003531 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003532 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003533 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003534 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003535 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003536 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003537 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003538 },
3539
3540 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003541 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003542 .family = MV88E6XXX_FAMILY_6351,
3543 .name = "Marvell 88E6351",
3544 .num_databases = 4096,
3545 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003546 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003547 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003548 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003549 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003550 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003551 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003552 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003553 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003554 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003555 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003556 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003557 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003558 },
3559
3560 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003561 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003562 .family = MV88E6XXX_FAMILY_6352,
3563 .name = "Marvell 88E6352",
3564 .num_databases = 4096,
3565 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003566 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003567 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003568 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003569 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003570 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003571 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003572 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003573 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003574 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003575 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003576 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003577 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003578 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003579 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003580 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003581 .family = MV88E6XXX_FAMILY_6390,
3582 .name = "Marvell 88E6390",
3583 .num_databases = 4096,
3584 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003585 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003586 .port_base_addr = 0x0,
3587 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003588 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003589 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003590 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003591 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003592 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003593 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003594 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003595 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003596 .ops = &mv88e6390_ops,
3597 },
3598 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003599 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003600 .family = MV88E6XXX_FAMILY_6390,
3601 .name = "Marvell 88E6390X",
3602 .num_databases = 4096,
3603 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003604 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003605 .port_base_addr = 0x0,
3606 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003607 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003608 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003609 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003610 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003611 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003612 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003613 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003614 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003615 .ops = &mv88e6390x_ops,
3616 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003617};
3618
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003619static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003620{
Vivien Didelota439c062016-04-17 13:23:58 -04003621 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003622
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003623 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3624 if (mv88e6xxx_table[i].prod_num == prod_num)
3625 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003626
Vivien Didelotb9b37712015-10-30 19:39:48 -04003627 return NULL;
3628}
3629
Vivien Didelotfad09c72016-06-21 12:28:20 -04003630static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003631{
3632 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003633 unsigned int prod_num, rev;
3634 u16 id;
3635 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003636
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003637 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003638 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003639 mutex_unlock(&chip->reg_lock);
3640 if (err)
3641 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003642
Vivien Didelot107fcc12017-06-12 12:37:36 -04003643 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3644 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003645
3646 info = mv88e6xxx_lookup_info(prod_num);
3647 if (!info)
3648 return -ENODEV;
3649
Vivien Didelotcaac8542016-06-20 13:14:09 -04003650 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003651 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003652
Vivien Didelotca070c12016-09-02 14:45:34 -04003653 err = mv88e6xxx_g2_require(chip);
3654 if (err)
3655 return err;
3656
Vivien Didelotfad09c72016-06-21 12:28:20 -04003657 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3658 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003659
3660 return 0;
3661}
3662
Vivien Didelotfad09c72016-06-21 12:28:20 -04003663static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003664{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003665 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003666
Vivien Didelotfad09c72016-06-21 12:28:20 -04003667 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3668 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003669 return NULL;
3670
Vivien Didelotfad09c72016-06-21 12:28:20 -04003671 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003672
Vivien Didelotfad09c72016-06-21 12:28:20 -04003673 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003674 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003675
Vivien Didelotfad09c72016-06-21 12:28:20 -04003676 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003677}
3678
Vivien Didelotfad09c72016-06-21 12:28:20 -04003679static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003680 struct mii_bus *bus, int sw_addr)
3681{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003682 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003683 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003684 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003685 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003686 else
3687 return -EINVAL;
3688
Vivien Didelotfad09c72016-06-21 12:28:20 -04003689 chip->bus = bus;
3690 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003691
3692 return 0;
3693}
3694
Andrew Lunn7b314362016-08-22 16:01:01 +02003695static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds)
3696{
Vivien Didelot04bed142016-08-31 18:06:13 -04003697 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003698
Andrew Lunn443d5a12016-12-03 04:35:18 +01003699 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003700}
3701
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003702static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3703 struct device *host_dev, int sw_addr,
3704 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003705{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003706 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003707 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003708 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003709
Vivien Didelota439c062016-04-17 13:23:58 -04003710 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003711 if (!bus)
3712 return NULL;
3713
Vivien Didelotfad09c72016-06-21 12:28:20 -04003714 chip = mv88e6xxx_alloc_chip(dsa_dev);
3715 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003716 return NULL;
3717
Vivien Didelotcaac8542016-06-20 13:14:09 -04003718 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003719 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003720
Vivien Didelotfad09c72016-06-21 12:28:20 -04003721 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003722 if (err)
3723 goto free;
3724
Vivien Didelotfad09c72016-06-21 12:28:20 -04003725 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003726 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003727 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003728
Andrew Lunndc30c352016-10-16 19:56:49 +02003729 mutex_lock(&chip->reg_lock);
3730 err = mv88e6xxx_switch_reset(chip);
3731 mutex_unlock(&chip->reg_lock);
3732 if (err)
3733 goto free;
3734
Vivien Didelote57e5e72016-08-15 17:19:00 -04003735 mv88e6xxx_phy_init(chip);
3736
Andrew Lunna3c53be52017-01-24 14:53:50 +01003737 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003738 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003739 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003740
Vivien Didelotfad09c72016-06-21 12:28:20 -04003741 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003742
Vivien Didelotfad09c72016-06-21 12:28:20 -04003743 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003744free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003745 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003746
3747 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003748}
3749
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003750static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
3751 const struct switchdev_obj_port_mdb *mdb,
3752 struct switchdev_trans *trans)
3753{
3754 /* We don't need any dynamic resource from the kernel (yet),
3755 * so skip the prepare phase.
3756 */
3757
3758 return 0;
3759}
3760
3761static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
3762 const struct switchdev_obj_port_mdb *mdb,
3763 struct switchdev_trans *trans)
3764{
Vivien Didelot04bed142016-08-31 18:06:13 -04003765 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003766
3767 mutex_lock(&chip->reg_lock);
3768 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003769 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003770 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3771 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003772 mutex_unlock(&chip->reg_lock);
3773}
3774
3775static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3776 const struct switchdev_obj_port_mdb *mdb)
3777{
Vivien Didelot04bed142016-08-31 18:06:13 -04003778 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003779 int err;
3780
3781 mutex_lock(&chip->reg_lock);
3782 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003783 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003784 mutex_unlock(&chip->reg_lock);
3785
3786 return err;
3787}
3788
Florian Fainellia82f67a2017-01-08 14:52:08 -08003789static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003790 .probe = mv88e6xxx_drv_probe,
Andrew Lunn7b314362016-08-22 16:01:01 +02003791 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003792 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003793 .adjust_link = mv88e6xxx_adjust_link,
3794 .get_strings = mv88e6xxx_get_strings,
3795 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3796 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003797 .port_enable = mv88e6xxx_port_enable,
3798 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04003799 .get_mac_eee = mv88e6xxx_get_mac_eee,
3800 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003801 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003802 .get_eeprom = mv88e6xxx_get_eeprom,
3803 .set_eeprom = mv88e6xxx_set_eeprom,
3804 .get_regs_len = mv88e6xxx_get_regs_len,
3805 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003806 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003807 .port_bridge_join = mv88e6xxx_port_bridge_join,
3808 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3809 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04003810 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003811 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3812 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3813 .port_vlan_add = mv88e6xxx_port_vlan_add,
3814 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003815 .port_fdb_add = mv88e6xxx_port_fdb_add,
3816 .port_fdb_del = mv88e6xxx_port_fdb_del,
3817 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003818 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
3819 .port_mdb_add = mv88e6xxx_port_mdb_add,
3820 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04003821 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
3822 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003823};
3824
Florian Fainelliab3d4082017-01-08 14:52:07 -08003825static struct dsa_switch_driver mv88e6xxx_switch_drv = {
3826 .ops = &mv88e6xxx_switch_ops,
3827};
3828
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003829static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003830{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003831 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003832 struct dsa_switch *ds;
3833
Vivien Didelot73b12042017-03-30 17:37:10 -04003834 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003835 if (!ds)
3836 return -ENOMEM;
3837
Vivien Didelotfad09c72016-06-21 12:28:20 -04003838 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04003839 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04003840 ds->ageing_time_min = chip->info->age_time_coeff;
3841 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003842
3843 dev_set_drvdata(dev, ds);
3844
Vivien Didelot23c9ee42017-05-26 18:12:51 -04003845 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003846}
3847
Vivien Didelotfad09c72016-06-21 12:28:20 -04003848static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003849{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003850 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003851}
3852
Vivien Didelot57d32312016-06-20 13:13:58 -04003853static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003854{
3855 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003856 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003857 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003858 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003859 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02003860 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003861
Vivien Didelotcaac8542016-06-20 13:14:09 -04003862 compat_info = of_device_get_match_data(dev);
3863 if (!compat_info)
3864 return -EINVAL;
3865
Vivien Didelotfad09c72016-06-21 12:28:20 -04003866 chip = mv88e6xxx_alloc_chip(dev);
3867 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003868 return -ENOMEM;
3869
Vivien Didelotfad09c72016-06-21 12:28:20 -04003870 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003871
Vivien Didelotfad09c72016-06-21 12:28:20 -04003872 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003873 if (err)
3874 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003875
Andrew Lunnb4308f02016-11-21 23:26:55 +01003876 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
3877 if (IS_ERR(chip->reset))
3878 return PTR_ERR(chip->reset);
3879
Vivien Didelotfad09c72016-06-21 12:28:20 -04003880 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003881 if (err)
3882 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003883
Vivien Didelote57e5e72016-08-15 17:19:00 -04003884 mv88e6xxx_phy_init(chip);
3885
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003886 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003887 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04003888 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003889
Andrew Lunndc30c352016-10-16 19:56:49 +02003890 mutex_lock(&chip->reg_lock);
3891 err = mv88e6xxx_switch_reset(chip);
3892 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02003893 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02003894 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02003895
Andrew Lunndc30c352016-10-16 19:56:49 +02003896 chip->irq = of_irq_get(np, 0);
3897 if (chip->irq == -EPROBE_DEFER) {
3898 err = chip->irq;
3899 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02003900 }
3901
Andrew Lunndc30c352016-10-16 19:56:49 +02003902 if (chip->irq > 0) {
3903 /* Has to be performed before the MDIO bus is created,
3904 * because the PHYs will link there interrupts to these
3905 * interrupt controllers
3906 */
3907 mutex_lock(&chip->reg_lock);
3908 err = mv88e6xxx_g1_irq_setup(chip);
3909 mutex_unlock(&chip->reg_lock);
3910
3911 if (err)
3912 goto out;
3913
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003914 if (chip->info->g2_irqs > 0) {
Andrew Lunndc30c352016-10-16 19:56:49 +02003915 err = mv88e6xxx_g2_irq_setup(chip);
3916 if (err)
3917 goto out_g1_irq;
3918 }
3919 }
3920
Andrew Lunna3c53be52017-01-24 14:53:50 +01003921 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02003922 if (err)
3923 goto out_g2_irq;
3924
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003925 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02003926 if (err)
3927 goto out_mdio;
3928
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003929 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02003930
3931out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01003932 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02003933out_g2_irq:
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003934 if (chip->info->g2_irqs > 0 && chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02003935 mv88e6xxx_g2_irq_free(chip);
3936out_g1_irq:
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01003937 if (chip->irq > 0) {
3938 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01003939 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01003940 mutex_unlock(&chip->reg_lock);
3941 }
Andrew Lunndc30c352016-10-16 19:56:49 +02003942out:
3943 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003944}
3945
3946static void mv88e6xxx_remove(struct mdio_device *mdiodev)
3947{
3948 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04003949 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003950
Andrew Lunn930188c2016-08-22 16:01:03 +02003951 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04003952 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003953 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02003954
Andrew Lunn467126442016-11-20 20:14:15 +01003955 if (chip->irq > 0) {
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003956 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01003957 mv88e6xxx_g2_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04003958 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01003959 mv88e6xxx_g1_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04003960 mutex_unlock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01003961 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003962}
3963
3964static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04003965 {
3966 .compatible = "marvell,mv88e6085",
3967 .data = &mv88e6xxx_table[MV88E6085],
3968 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003969 {
3970 .compatible = "marvell,mv88e6190",
3971 .data = &mv88e6xxx_table[MV88E6190],
3972 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003973 { /* sentinel */ },
3974};
3975
3976MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
3977
3978static struct mdio_driver mv88e6xxx_driver = {
3979 .probe = mv88e6xxx_probe,
3980 .remove = mv88e6xxx_remove,
3981 .mdiodrv.driver = {
3982 .name = "mv88e6085",
3983 .of_match_table = mv88e6xxx_of_match,
3984 },
3985};
3986
Ben Hutchings98e67302011-11-25 14:36:19 +00003987static int __init mv88e6xxx_init(void)
3988{
Florian Fainelliab3d4082017-01-08 14:52:07 -08003989 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003990 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00003991}
3992module_init(mv88e6xxx_init);
3993
3994static void __exit mv88e6xxx_cleanup(void)
3995{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003996 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08003997 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00003998}
3999module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004000
4001MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4002MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4003MODULE_LICENSE("GPL");