blob: 41e28e28e65b560410f9153dcabd482358f6eba9 [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"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010041#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020042#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelot914b32f2016-06-20 13:14:11 -040052/* The switch ADDR[4:1] configuration pins define the chip SMI device address
53 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
54 *
55 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
56 * is the only device connected to the SMI master. In this mode it responds to
57 * all 32 possible SMI addresses, and thus maps directly the internal devices.
58 *
59 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
60 * multiple devices to share the SMI interface. In this mode it responds to only
61 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000062 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040063
Vivien Didelotfad09c72016-06-21 12:28:20 -040064static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040065 int addr, int reg, u16 *val)
66{
Vivien Didelotfad09c72016-06-21 12:28:20 -040067 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040068 return -EOPNOTSUPP;
69
Vivien Didelotfad09c72016-06-21 12:28:20 -040070 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040071}
72
Vivien Didelotfad09c72016-06-21 12:28:20 -040073static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040074 int addr, int reg, u16 val)
75{
Vivien Didelotfad09c72016-06-21 12:28:20 -040076 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040077 return -EOPNOTSUPP;
78
Vivien Didelotfad09c72016-06-21 12:28:20 -040079 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040080}
81
Vivien Didelotfad09c72016-06-21 12:28:20 -040082static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040083 int addr, int reg, u16 *val)
84{
85 int ret;
86
Vivien Didelotfad09c72016-06-21 12:28:20 -040087 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040088 if (ret < 0)
89 return ret;
90
91 *val = ret & 0xffff;
92
93 return 0;
94}
95
Vivien Didelotfad09c72016-06-21 12:28:20 -040096static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040097 int addr, int reg, u16 val)
98{
99 int ret;
100
Vivien Didelotfad09c72016-06-21 12:28:20 -0400101 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400102 if (ret < 0)
103 return ret;
104
105 return 0;
106}
107
Vivien Didelotc08026a2016-09-29 12:21:59 -0400108static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400109 .read = mv88e6xxx_smi_single_chip_read,
110 .write = mv88e6xxx_smi_single_chip_write,
111};
112
Vivien Didelotfad09c72016-06-21 12:28:20 -0400113static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000114{
115 int ret;
116 int i;
117
118 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400119 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000120 if (ret < 0)
121 return ret;
122
Andrew Lunncca8b132015-04-02 04:06:39 +0200123 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000124 return 0;
125 }
126
127 return -ETIMEDOUT;
128}
129
Vivien Didelotfad09c72016-06-21 12:28:20 -0400130static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400131 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000132{
133 int ret;
134
Barry Grussling3675c8d2013-01-08 16:05:53 +0000135 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400136 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000137 if (ret < 0)
138 return ret;
139
Barry Grussling3675c8d2013-01-08 16:05:53 +0000140 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400141 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200142 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000143 if (ret < 0)
144 return ret;
145
Barry Grussling3675c8d2013-01-08 16:05:53 +0000146 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400147 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000148 if (ret < 0)
149 return ret;
150
Barry Grussling3675c8d2013-01-08 16:05:53 +0000151 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400152 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000153 if (ret < 0)
154 return ret;
155
Vivien Didelot914b32f2016-06-20 13:14:11 -0400156 *val = ret & 0xffff;
157
158 return 0;
159}
160
Vivien Didelotfad09c72016-06-21 12:28:20 -0400161static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400162 int addr, int reg, u16 val)
163{
164 int ret;
165
166 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400167 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400168 if (ret < 0)
169 return ret;
170
171 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400172 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400173 if (ret < 0)
174 return ret;
175
176 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400177 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400178 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
179 if (ret < 0)
180 return ret;
181
182 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400183 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400184 if (ret < 0)
185 return ret;
186
187 return 0;
188}
189
Vivien Didelotc08026a2016-09-29 12:21:59 -0400190static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400191 .read = mv88e6xxx_smi_multi_chip_read,
192 .write = mv88e6xxx_smi_multi_chip_write,
193};
194
Vivien Didelotec561272016-09-02 14:45:33 -0400195int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400196{
197 int err;
198
Vivien Didelotfad09c72016-06-21 12:28:20 -0400199 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400200
Vivien Didelotfad09c72016-06-21 12:28:20 -0400201 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400202 if (err)
203 return err;
204
Vivien Didelotfad09c72016-06-21 12:28:20 -0400205 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400206 addr, reg, *val);
207
208 return 0;
209}
210
Vivien Didelotec561272016-09-02 14:45:33 -0400211int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400212{
213 int err;
214
Vivien Didelotfad09c72016-06-21 12:28:20 -0400215 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400216
Vivien Didelotfad09c72016-06-21 12:28:20 -0400217 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400218 if (err)
219 return err;
220
Vivien Didelotfad09c72016-06-21 12:28:20 -0400221 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400222 addr, reg, val);
223
224 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000225}
226
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200227struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100228{
229 struct mv88e6xxx_mdio_bus *mdio_bus;
230
231 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
232 list);
233 if (!mdio_bus)
234 return NULL;
235
236 return mdio_bus->bus;
237}
238
Andrew Lunndc30c352016-10-16 19:56:49 +0200239static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
240{
241 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
242 unsigned int n = d->hwirq;
243
244 chip->g1_irq.masked |= (1 << n);
245}
246
247static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
248{
249 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
250 unsigned int n = d->hwirq;
251
252 chip->g1_irq.masked &= ~(1 << n);
253}
254
255static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
256{
257 struct mv88e6xxx_chip *chip = dev_id;
258 unsigned int nhandled = 0;
259 unsigned int sub_irq;
260 unsigned int n;
261 u16 reg;
262 int err;
263
264 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400265 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200266 mutex_unlock(&chip->reg_lock);
267
268 if (err)
269 goto out;
270
271 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
272 if (reg & (1 << n)) {
273 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
274 handle_nested_irq(sub_irq);
275 ++nhandled;
276 }
277 }
278out:
279 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
280}
281
282static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
283{
284 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
285
286 mutex_lock(&chip->reg_lock);
287}
288
289static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
290{
291 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
292 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
293 u16 reg;
294 int err;
295
Vivien Didelotd77f4322017-06-15 12:14:03 -0400296 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200297 if (err)
298 goto out;
299
300 reg &= ~mask;
301 reg |= (~chip->g1_irq.masked & mask);
302
Vivien Didelotd77f4322017-06-15 12:14:03 -0400303 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200304 if (err)
305 goto out;
306
307out:
308 mutex_unlock(&chip->reg_lock);
309}
310
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530311static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200312 .name = "mv88e6xxx-g1",
313 .irq_mask = mv88e6xxx_g1_irq_mask,
314 .irq_unmask = mv88e6xxx_g1_irq_unmask,
315 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
316 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
317};
318
319static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
320 unsigned int irq,
321 irq_hw_number_t hwirq)
322{
323 struct mv88e6xxx_chip *chip = d->host_data;
324
325 irq_set_chip_data(irq, d->host_data);
326 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
327 irq_set_noprobe(irq);
328
329 return 0;
330}
331
332static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
333 .map = mv88e6xxx_g1_irq_domain_map,
334 .xlate = irq_domain_xlate_twocell,
335};
336
337static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
338{
339 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100340 u16 mask;
341
Vivien Didelotd77f4322017-06-15 12:14:03 -0400342 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100343 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400344 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100345
346 free_irq(chip->irq, chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200347
Andreas Färber5edef2f2016-11-27 23:26:28 +0100348 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100349 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200350 irq_dispose_mapping(virq);
351 }
352
Andrew Lunna3db3d32016-11-20 20:14:14 +0100353 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200354}
355
356static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
357{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100358 int err, irq, virq;
359 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200360
361 chip->g1_irq.nirqs = chip->info->g1_irqs;
362 chip->g1_irq.domain = irq_domain_add_simple(
363 NULL, chip->g1_irq.nirqs, 0,
364 &mv88e6xxx_g1_irq_domain_ops, chip);
365 if (!chip->g1_irq.domain)
366 return -ENOMEM;
367
368 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
369 irq_create_mapping(chip->g1_irq.domain, irq);
370
371 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
372 chip->g1_irq.masked = ~0;
373
Vivien Didelotd77f4322017-06-15 12:14:03 -0400374 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200375 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100376 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200377
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100378 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200379
Vivien Didelotd77f4322017-06-15 12:14:03 -0400380 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200381 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100382 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200383
384 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400385 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200386 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100387 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200388
389 err = request_threaded_irq(chip->irq, NULL,
390 mv88e6xxx_g1_irq_thread_fn,
391 IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
392 dev_name(chip->dev), chip);
393 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100394 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200395
396 return 0;
397
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100398out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100399 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400400 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100401
402out_mapping:
403 for (irq = 0; irq < 16; irq++) {
404 virq = irq_find_mapping(chip->g1_irq.domain, irq);
405 irq_dispose_mapping(virq);
406 }
407
408 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200409
410 return err;
411}
412
Vivien Didelotec561272016-09-02 14:45:33 -0400413int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400414{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200415 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400416
Andrew Lunn6441e6692016-08-19 00:01:55 +0200417 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400418 u16 val;
419 int err;
420
421 err = mv88e6xxx_read(chip, addr, reg, &val);
422 if (err)
423 return err;
424
425 if (!(val & mask))
426 return 0;
427
428 usleep_range(1000, 2000);
429 }
430
Andrew Lunn30853552016-08-19 00:01:57 +0200431 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400432 return -ETIMEDOUT;
433}
434
Vivien Didelotf22ab642016-07-18 20:45:31 -0400435/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400436int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400437{
438 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200439 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400440
441 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200442 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
443 if (err)
444 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400445
446 /* Set the Update bit to trigger a write operation */
447 val = BIT(15) | update;
448
449 return mv88e6xxx_write(chip, addr, reg, val);
450}
451
Vivien Didelotd78343d2016-11-04 03:23:36 +0100452static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
453 int link, int speed, int duplex,
454 phy_interface_t mode)
455{
456 int err;
457
458 if (!chip->info->ops->port_set_link)
459 return 0;
460
461 /* Port's MAC control must not be changed unless the link is down */
462 err = chip->info->ops->port_set_link(chip, port, 0);
463 if (err)
464 return err;
465
466 if (chip->info->ops->port_set_speed) {
467 err = chip->info->ops->port_set_speed(chip, port, speed);
468 if (err && err != -EOPNOTSUPP)
469 goto restore_link;
470 }
471
472 if (chip->info->ops->port_set_duplex) {
473 err = chip->info->ops->port_set_duplex(chip, port, duplex);
474 if (err && err != -EOPNOTSUPP)
475 goto restore_link;
476 }
477
478 if (chip->info->ops->port_set_rgmii_delay) {
479 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
480 if (err && err != -EOPNOTSUPP)
481 goto restore_link;
482 }
483
Andrew Lunnf39908d2017-02-04 20:02:50 +0100484 if (chip->info->ops->port_set_cmode) {
485 err = chip->info->ops->port_set_cmode(chip, port, mode);
486 if (err && err != -EOPNOTSUPP)
487 goto restore_link;
488 }
489
Vivien Didelotd78343d2016-11-04 03:23:36 +0100490 err = 0;
491restore_link:
492 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400493 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100494
495 return err;
496}
497
Andrew Lunndea87022015-08-31 15:56:47 +0200498/* We expect the switch to perform auto negotiation if there is a real
499 * phy. However, in the case of a fixed link phy, we force the port
500 * settings from the fixed link settings.
501 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400502static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
503 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200504{
Vivien Didelot04bed142016-08-31 18:06:13 -0400505 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200506 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200507
508 if (!phy_is_pseudo_fixed_link(phydev))
509 return;
510
Vivien Didelotfad09c72016-06-21 12:28:20 -0400511 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100512 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
513 phydev->duplex, phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400514 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100515
516 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400517 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200518}
519
Andrew Lunna605a0f2016-11-21 23:26:58 +0100520static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000521{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100522 if (!chip->info->ops->stats_snapshot)
523 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000524
Andrew Lunna605a0f2016-11-21 23:26:58 +0100525 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000526}
527
Andrew Lunne413e7e2015-04-02 04:06:38 +0200528static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100529 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
530 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
531 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
532 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
533 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
534 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
535 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
536 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
537 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
538 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
539 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
540 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
541 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
542 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
543 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
544 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
545 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
546 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
547 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
548 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
549 { "single", 4, 0x14, STATS_TYPE_BANK0, },
550 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
551 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
552 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
553 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
554 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
555 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
556 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
557 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
558 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
559 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
560 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
561 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
562 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
563 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
564 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
565 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
566 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
567 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
568 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
569 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
570 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
571 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
572 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
573 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
574 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
575 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
576 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
577 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
578 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
579 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
580 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
581 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
582 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
583 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
584 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
585 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
586 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
587 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200588};
589
Vivien Didelotfad09c72016-06-21 12:28:20 -0400590static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100591 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100592 int port, u16 bank1_select,
593 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200594{
Andrew Lunn80c46272015-06-20 18:42:30 +0200595 u32 low;
596 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100597 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200598 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200599 u64 value;
600
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100601 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100602 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200603 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
604 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200605 return UINT64_MAX;
606
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200607 low = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200608 if (s->sizeof_stat == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200609 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
610 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200611 return UINT64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200612 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200613 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100614 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100615 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100616 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100617 /* fall through */
618 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100619 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100620 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunn80c46272015-06-20 18:42:30 +0200621 if (s->sizeof_stat == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100622 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500623 break;
624 default:
625 return UINT64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200626 }
627 value = (((u64)high) << 16) | low;
628 return value;
629}
630
Andrew Lunndfafe442016-11-21 23:27:02 +0100631static void mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
632 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100633{
634 struct mv88e6xxx_hw_stat *stat;
635 int i, j;
636
637 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
638 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100639 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100640 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
641 ETH_GSTRING_LEN);
642 j++;
643 }
644 }
645}
646
Andrew Lunndfafe442016-11-21 23:27:02 +0100647static void mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
648 uint8_t *data)
649{
650 mv88e6xxx_stats_get_strings(chip, data,
651 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
652}
653
654static void mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
655 uint8_t *data)
656{
657 mv88e6xxx_stats_get_strings(chip, data,
658 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
659}
660
661static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
662 uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100663{
Vivien Didelot04bed142016-08-31 18:06:13 -0400664 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunndfafe442016-11-21 23:27:02 +0100665
666 if (chip->info->ops->stats_get_strings)
667 chip->info->ops->stats_get_strings(chip, data);
668}
669
670static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
671 int types)
672{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100673 struct mv88e6xxx_hw_stat *stat;
674 int i, j;
675
676 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
677 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100678 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100679 j++;
680 }
681 return j;
682}
683
Andrew Lunndfafe442016-11-21 23:27:02 +0100684static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
685{
686 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
687 STATS_TYPE_PORT);
688}
689
690static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
691{
692 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
693 STATS_TYPE_BANK1);
694}
695
696static int mv88e6xxx_get_sset_count(struct dsa_switch *ds)
697{
698 struct mv88e6xxx_chip *chip = ds->priv;
699
700 if (chip->info->ops->stats_get_sset_count)
701 return chip->info->ops->stats_get_sset_count(chip);
702
703 return 0;
704}
705
Andrew Lunn052f9472016-11-21 23:27:03 +0100706static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100707 uint64_t *data, int types,
708 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100709{
710 struct mv88e6xxx_hw_stat *stat;
711 int i, j;
712
713 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
714 stat = &mv88e6xxx_hw_stats[i];
715 if (stat->type & types) {
Andrew Lunne0d8b612016-11-21 23:27:04 +0100716 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
717 bank1_select,
718 histogram);
Andrew Lunn052f9472016-11-21 23:27:03 +0100719 j++;
720 }
721 }
722}
723
724static void mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
725 uint64_t *data)
726{
727 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100728 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400729 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100730}
731
732static void mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
733 uint64_t *data)
734{
735 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100736 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400737 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
738 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100739}
740
741static void mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
742 uint64_t *data)
743{
744 return mv88e6xxx_stats_get_stats(chip, port, data,
745 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400746 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
747 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100748}
749
750static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
751 uint64_t *data)
752{
753 if (chip->info->ops->stats_get_stats)
754 chip->info->ops->stats_get_stats(chip, port, data);
755}
756
Vivien Didelotf81ec902016-05-09 13:22:58 -0400757static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
758 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000759{
Vivien Didelot04bed142016-08-31 18:06:13 -0400760 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000761 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000762
Vivien Didelotfad09c72016-06-21 12:28:20 -0400763 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000764
Andrew Lunna605a0f2016-11-21 23:26:58 +0100765 ret = mv88e6xxx_stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000766 if (ret < 0) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400767 mutex_unlock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000768 return;
769 }
Andrew Lunn052f9472016-11-21 23:27:03 +0100770
771 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000772
Vivien Didelotfad09c72016-06-21 12:28:20 -0400773 mutex_unlock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000774}
Ben Hutchings98e67302011-11-25 14:36:19 +0000775
Andrew Lunnde2273872016-11-21 23:27:01 +0100776static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
777{
778 if (chip->info->ops->stats_set_histogram)
779 return chip->info->ops->stats_set_histogram(chip);
780
781 return 0;
782}
783
Vivien Didelotf81ec902016-05-09 13:22:58 -0400784static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700785{
786 return 32 * sizeof(u16);
787}
788
Vivien Didelotf81ec902016-05-09 13:22:58 -0400789static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
790 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700791{
Vivien Didelot04bed142016-08-31 18:06:13 -0400792 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200793 int err;
794 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700795 u16 *p = _p;
796 int i;
797
798 regs->version = 0;
799
800 memset(p, 0xff, 32 * sizeof(u16));
801
Vivien Didelotfad09c72016-06-21 12:28:20 -0400802 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -0400803
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700804 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700805
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200806 err = mv88e6xxx_port_read(chip, port, i, &reg);
807 if (!err)
808 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700809 }
Vivien Didelot23062512016-05-09 13:22:45 -0400810
Vivien Didelotfad09c72016-06-21 12:28:20 -0400811 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700812}
813
Vivien Didelot08f50062017-08-01 16:32:41 -0400814static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
815 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800816{
Vivien Didelot5480db62017-08-01 16:32:40 -0400817 /* Nothing to do on the port's MAC */
818 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800819}
820
Vivien Didelot08f50062017-08-01 16:32:41 -0400821static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
822 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800823{
Vivien Didelot5480db62017-08-01 16:32:40 -0400824 /* Nothing to do on the port's MAC */
825 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800826}
827
Vivien Didelote5887a22017-03-30 17:37:11 -0400828static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700829{
Vivien Didelote5887a22017-03-30 17:37:11 -0400830 struct dsa_switch *ds = NULL;
831 struct net_device *br;
832 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500833 int i;
834
Vivien Didelote5887a22017-03-30 17:37:11 -0400835 if (dev < DSA_MAX_SWITCHES)
836 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500837
Vivien Didelote5887a22017-03-30 17:37:11 -0400838 /* Prevent frames from unknown switch or port */
839 if (!ds || port >= ds->num_ports)
840 return 0;
841
842 /* Frames from DSA links and CPU ports can egress any local port */
843 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
844 return mv88e6xxx_port_mask(chip);
845
846 br = ds->ports[port].bridge_dev;
847 pvlan = 0;
848
849 /* Frames from user ports can egress any local DSA links and CPU ports,
850 * as well as any local member of their bridge group.
851 */
852 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
853 if (dsa_is_cpu_port(chip->ds, i) ||
854 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -0400855 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -0400856 pvlan |= BIT(i);
857
858 return pvlan;
859}
860
Vivien Didelot240ea3e2017-03-30 17:37:12 -0400861static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -0400862{
863 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500864
865 /* prevent frames from going back out of the port they came in on */
866 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700867
Vivien Didelot5a7921f2016-11-04 03:23:28 +0100868 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700869}
870
Vivien Didelotf81ec902016-05-09 13:22:58 -0400871static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
872 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700873{
Vivien Didelot04bed142016-08-31 18:06:13 -0400874 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -0400875 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700876
Vivien Didelotfad09c72016-06-21 12:28:20 -0400877 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -0400878 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400879 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -0400880
881 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400882 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700883}
884
Vivien Didelot9e907d72017-07-17 13:03:43 -0400885static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
886{
887 if (chip->info->ops->pot_clear)
888 return chip->info->ops->pot_clear(chip);
889
890 return 0;
891}
892
Vivien Didelot51c901a2017-07-17 13:03:41 -0400893static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
894{
895 if (chip->info->ops->mgmt_rsvd2cpu)
896 return chip->info->ops->mgmt_rsvd2cpu(chip);
897
898 return 0;
899}
900
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500901static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
902{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500903 int err;
904
Vivien Didelotdaefc942017-03-11 16:12:54 -0500905 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
906 if (err)
907 return err;
908
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500909 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
910 if (err)
911 return err;
912
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500913 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
914}
915
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400916static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
917{
918 int port;
919 int err;
920
921 if (!chip->info->ops->irl_init_all)
922 return 0;
923
924 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
925 /* Disable ingress rate limiting by resetting all per port
926 * ingress rate limit resources to their initial state.
927 */
928 err = chip->info->ops->irl_init_all(chip, port);
929 if (err)
930 return err;
931 }
932
933 return 0;
934}
935
Vivien Didelot04a69a12017-10-13 14:18:05 -0400936static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
937{
938 if (chip->info->ops->set_switch_mac) {
939 u8 addr[ETH_ALEN];
940
941 eth_random_addr(addr);
942
943 return chip->info->ops->set_switch_mac(chip, addr);
944 }
945
946 return 0;
947}
948
Vivien Didelot17a15942017-03-30 17:37:09 -0400949static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
950{
951 u16 pvlan = 0;
952
953 if (!mv88e6xxx_has_pvt(chip))
954 return -EOPNOTSUPP;
955
956 /* Skip the local source device, which uses in-chip port VLAN */
957 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -0400958 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -0400959
960 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
961}
962
Vivien Didelot81228992017-03-30 17:37:08 -0400963static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
964{
Vivien Didelot17a15942017-03-30 17:37:09 -0400965 int dev, port;
966 int err;
967
Vivien Didelot81228992017-03-30 17:37:08 -0400968 if (!mv88e6xxx_has_pvt(chip))
969 return 0;
970
971 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
972 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
973 */
Vivien Didelot17a15942017-03-30 17:37:09 -0400974 err = mv88e6xxx_g2_misc_4_bit_port(chip);
975 if (err)
976 return err;
977
978 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
979 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
980 err = mv88e6xxx_pvt_map(chip, dev, port);
981 if (err)
982 return err;
983 }
984 }
985
986 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -0400987}
988
Vivien Didelot749efcb2016-09-22 16:49:24 -0400989static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
990{
991 struct mv88e6xxx_chip *chip = ds->priv;
992 int err;
993
994 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -0500995 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400996 mutex_unlock(&chip->reg_lock);
997
998 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400999 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001000}
1001
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001002static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1003{
1004 if (!chip->info->max_vid)
1005 return 0;
1006
1007 return mv88e6xxx_g1_vtu_flush(chip);
1008}
1009
Vivien Didelotf1394b782017-05-01 14:05:22 -04001010static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1011 struct mv88e6xxx_vtu_entry *entry)
1012{
1013 if (!chip->info->ops->vtu_getnext)
1014 return -EOPNOTSUPP;
1015
1016 return chip->info->ops->vtu_getnext(chip, entry);
1017}
1018
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001019static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1020 struct mv88e6xxx_vtu_entry *entry)
1021{
1022 if (!chip->info->ops->vtu_loadpurge)
1023 return -EOPNOTSUPP;
1024
1025 return chip->info->ops->vtu_loadpurge(chip, entry);
1026}
1027
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001028static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001029{
1030 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001031 struct mv88e6xxx_vtu_entry vlan = {
1032 .vid = chip->info->max_vid,
1033 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001034 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001035
1036 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1037
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001038 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001039 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001040 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001041 if (err)
1042 return err;
1043
1044 set_bit(*fid, fid_bitmap);
1045 }
1046
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001047 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001048 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001049 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001050 if (err)
1051 return err;
1052
1053 if (!vlan.valid)
1054 break;
1055
1056 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001057 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001058
1059 /* The reset value 0x000 is used to indicate that multiple address
1060 * databases are not needed. Return the next positive available.
1061 */
1062 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001063 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001064 return -ENOSPC;
1065
1066 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001067 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001068}
1069
Vivien Didelot567aa592017-05-01 14:05:25 -04001070static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1071 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001072{
1073 int err;
1074
1075 if (!vid)
1076 return -EINVAL;
1077
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001078 entry->vid = vid - 1;
1079 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001080
Vivien Didelotf1394b782017-05-01 14:05:22 -04001081 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001082 if (err)
1083 return err;
1084
Vivien Didelot567aa592017-05-01 14:05:25 -04001085 if (entry->vid == vid && entry->valid)
1086 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001087
Vivien Didelot567aa592017-05-01 14:05:25 -04001088 if (new) {
1089 int i;
1090
1091 /* Initialize a fresh VLAN entry */
1092 memset(entry, 0, sizeof(*entry));
1093 entry->valid = true;
1094 entry->vid = vid;
1095
Vivien Didelot553a7682017-06-07 18:12:16 -04001096 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001097 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001098 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001099 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001100
1101 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001102 }
1103
Vivien Didelot567aa592017-05-01 14:05:25 -04001104 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1105 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001106}
1107
Vivien Didelotda9c3592016-02-12 12:09:40 -05001108static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1109 u16 vid_begin, u16 vid_end)
1110{
Vivien Didelot04bed142016-08-31 18:06:13 -04001111 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001112 struct mv88e6xxx_vtu_entry vlan = {
1113 .vid = vid_begin - 1,
1114 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001115 int i, err;
1116
Andrew Lunndb06ae412017-09-25 23:32:20 +02001117 /* DSA and CPU ports have to be members of multiple vlans */
1118 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1119 return 0;
1120
Vivien Didelotda9c3592016-02-12 12:09:40 -05001121 if (!vid_begin)
1122 return -EOPNOTSUPP;
1123
Vivien Didelotfad09c72016-06-21 12:28:20 -04001124 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001125
Vivien Didelotda9c3592016-02-12 12:09:40 -05001126 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001127 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001128 if (err)
1129 goto unlock;
1130
1131 if (!vlan.valid)
1132 break;
1133
1134 if (vlan.vid > vid_end)
1135 break;
1136
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001137 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001138 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1139 continue;
1140
Andrew Lunncd886462017-11-09 22:29:53 +01001141 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001142 continue;
1143
Vivien Didelotbd00e052017-05-01 14:05:11 -04001144 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001145 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001146 continue;
1147
Vivien Didelotc8652c82017-10-16 11:12:19 -04001148 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001149 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001150 break; /* same bridge, check next VLAN */
1151
Vivien Didelotc8652c82017-10-16 11:12:19 -04001152 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001153 continue;
1154
Andrew Lunn743fcc22017-11-09 22:29:54 +01001155 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1156 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001157 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001158 err = -EOPNOTSUPP;
1159 goto unlock;
1160 }
1161 } while (vlan.vid < vid_end);
1162
1163unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001164 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001165
1166 return err;
1167}
1168
Vivien Didelotf81ec902016-05-09 13:22:58 -04001169static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1170 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001171{
Vivien Didelot04bed142016-08-31 18:06:13 -04001172 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001173 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1174 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001175 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001176
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001177 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001178 return -EOPNOTSUPP;
1179
Vivien Didelotfad09c72016-06-21 12:28:20 -04001180 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001181 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001182 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001183
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001184 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001185}
1186
Vivien Didelot57d32312016-06-20 13:13:58 -04001187static int
1188mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001189 const struct switchdev_obj_port_vlan *vlan)
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
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001211static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1212 const unsigned char *addr, u16 vid,
1213 u8 state)
1214{
1215 struct mv88e6xxx_vtu_entry vlan;
1216 struct mv88e6xxx_atu_entry entry;
1217 int err;
1218
1219 /* Null VLAN ID corresponds to the port private database */
1220 if (vid == 0)
1221 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1222 else
1223 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1224 if (err)
1225 return err;
1226
1227 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1228 ether_addr_copy(entry.mac, addr);
1229 eth_addr_dec(entry.mac);
1230
1231 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1232 if (err)
1233 return err;
1234
1235 /* Initialize a fresh ATU entry if it isn't found */
1236 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1237 !ether_addr_equal(entry.mac, addr)) {
1238 memset(&entry, 0, sizeof(entry));
1239 ether_addr_copy(entry.mac, addr);
1240 }
1241
1242 /* Purge the ATU entry only if no port is using it anymore */
1243 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1244 entry.portvec &= ~BIT(port);
1245 if (!entry.portvec)
1246 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1247 } else {
1248 entry.portvec |= BIT(port);
1249 entry.state = state;
1250 }
1251
1252 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1253}
1254
Andrew Lunn87fa8862017-11-09 22:29:56 +01001255static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1256 u16 vid)
1257{
1258 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1259 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1260
1261 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1262}
1263
1264static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1265{
1266 int port;
1267 int err;
1268
1269 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1270 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1271 if (err)
1272 return err;
1273 }
1274
1275 return 0;
1276}
1277
Vivien Didelotfad09c72016-06-21 12:28:20 -04001278static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001279 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001280{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001281 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001282 int err;
1283
Vivien Didelot567aa592017-05-01 14:05:25 -04001284 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001285 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001286 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001287
Vivien Didelotc91498e2017-06-07 18:12:13 -04001288 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001289
Andrew Lunn87fa8862017-11-09 22:29:56 +01001290 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1291 if (err)
1292 return err;
1293
1294 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001295}
1296
Vivien Didelotf81ec902016-05-09 13:22:58 -04001297static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001298 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001299{
Vivien Didelot04bed142016-08-31 18:06:13 -04001300 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001301 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1302 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001303 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001304 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001305
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001306 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001307 return;
1308
Vivien Didelotc91498e2017-06-07 18:12:13 -04001309 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001310 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001311 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001312 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001313 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001314 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001315
Vivien Didelotfad09c72016-06-21 12:28:20 -04001316 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001317
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001318 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001319 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001320 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1321 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001322
Vivien Didelot77064f32016-11-04 03:23:30 +01001323 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001324 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1325 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001326
Vivien Didelotfad09c72016-06-21 12:28:20 -04001327 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001328}
1329
Vivien Didelotfad09c72016-06-21 12:28:20 -04001330static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001331 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001332{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001333 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001334 int i, err;
1335
Vivien Didelot567aa592017-05-01 14:05:25 -04001336 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001337 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001338 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001339
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001340 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001341 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001342 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001343
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001344 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001345
1346 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001347 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001348 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001349 if (vlan.member[i] !=
1350 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001351 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001352 break;
1353 }
1354 }
1355
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001356 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001357 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001358 return err;
1359
Vivien Didelote606ca32017-03-11 16:12:55 -05001360 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001361}
1362
Vivien Didelotf81ec902016-05-09 13:22:58 -04001363static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1364 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001365{
Vivien Didelot04bed142016-08-31 18:06:13 -04001366 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001367 u16 pvid, vid;
1368 int err = 0;
1369
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001370 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001371 return -EOPNOTSUPP;
1372
Vivien Didelotfad09c72016-06-21 12:28:20 -04001373 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001374
Vivien Didelot77064f32016-11-04 03:23:30 +01001375 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001376 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001377 goto unlock;
1378
Vivien Didelot76e398a2015-11-01 12:33:55 -05001379 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001380 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001381 if (err)
1382 goto unlock;
1383
1384 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001385 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001386 if (err)
1387 goto unlock;
1388 }
1389 }
1390
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001391unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001392 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001393
1394 return err;
1395}
1396
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001397static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1398 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001399{
Vivien Didelot04bed142016-08-31 18:06:13 -04001400 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001401 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001402
Vivien Didelotfad09c72016-06-21 12:28:20 -04001403 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001404 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1405 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001406 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001407
1408 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001409}
1410
Vivien Didelotf81ec902016-05-09 13:22:58 -04001411static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001412 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001413{
Vivien Didelot04bed142016-08-31 18:06:13 -04001414 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001415 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001416
Vivien Didelotfad09c72016-06-21 12:28:20 -04001417 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001418 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001419 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001420 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001421
Vivien Didelot83dabd12016-08-31 11:50:04 -04001422 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001423}
1424
Vivien Didelot83dabd12016-08-31 11:50:04 -04001425static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1426 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001427 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001428{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001429 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001430 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001431 int err;
1432
Vivien Didelot27c0e602017-06-15 12:14:01 -04001433 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001434 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001435
1436 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001437 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001438 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001439 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001440
Vivien Didelot27c0e602017-06-15 12:14:01 -04001441 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001442 break;
1443
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001444 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001445 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001446
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001447 if (!is_unicast_ether_addr(addr.mac))
1448 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001449
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001450 is_static = (addr.state ==
1451 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1452 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001453 if (err)
1454 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001455 } while (!is_broadcast_ether_addr(addr.mac));
1456
1457 return err;
1458}
1459
Vivien Didelot83dabd12016-08-31 11:50:04 -04001460static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001461 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001462{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001463 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001464 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001465 };
1466 u16 fid;
1467 int err;
1468
1469 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001470 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001471 if (err)
1472 return err;
1473
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001474 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001475 if (err)
1476 return err;
1477
1478 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001479 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001480 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001481 if (err)
1482 return err;
1483
1484 if (!vlan.valid)
1485 break;
1486
1487 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001488 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001489 if (err)
1490 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001491 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001492
1493 return err;
1494}
1495
Vivien Didelotf81ec902016-05-09 13:22:58 -04001496static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001497 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001498{
Vivien Didelot04bed142016-08-31 18:06:13 -04001499 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001500 int err;
1501
Vivien Didelotfad09c72016-06-21 12:28:20 -04001502 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001503 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001504 mutex_unlock(&chip->reg_lock);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001505
1506 return err;
1507}
1508
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001509static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1510 struct net_device *br)
1511{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001512 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001513 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001514 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001515 int err;
1516
1517 /* Remap the Port VLAN of each local bridge group member */
1518 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1519 if (chip->ds->ports[port].bridge_dev == br) {
1520 err = mv88e6xxx_port_vlan_map(chip, port);
1521 if (err)
1522 return err;
1523 }
1524 }
1525
Vivien Didelote96a6e02017-03-30 17:37:13 -04001526 if (!mv88e6xxx_has_pvt(chip))
1527 return 0;
1528
1529 /* Remap the Port VLAN of each cross-chip bridge group member */
1530 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1531 ds = chip->ds->dst->ds[dev];
1532 if (!ds)
1533 break;
1534
1535 for (port = 0; port < ds->num_ports; ++port) {
1536 if (ds->ports[port].bridge_dev == br) {
1537 err = mv88e6xxx_pvt_map(chip, dev, port);
1538 if (err)
1539 return err;
1540 }
1541 }
1542 }
1543
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001544 return 0;
1545}
1546
Vivien Didelotf81ec902016-05-09 13:22:58 -04001547static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001548 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001549{
Vivien Didelot04bed142016-08-31 18:06:13 -04001550 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001551 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001552
Vivien Didelotfad09c72016-06-21 12:28:20 -04001553 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001554 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001555 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001556
Vivien Didelot466dfa02016-02-26 13:16:05 -05001557 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001558}
1559
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001560static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1561 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001562{
Vivien Didelot04bed142016-08-31 18:06:13 -04001563 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001564
Vivien Didelotfad09c72016-06-21 12:28:20 -04001565 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001566 if (mv88e6xxx_bridge_map(chip, br) ||
1567 mv88e6xxx_port_vlan_map(chip, port))
1568 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001569 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001570}
1571
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001572static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1573 int port, struct net_device *br)
1574{
1575 struct mv88e6xxx_chip *chip = ds->priv;
1576 int err;
1577
1578 if (!mv88e6xxx_has_pvt(chip))
1579 return 0;
1580
1581 mutex_lock(&chip->reg_lock);
1582 err = mv88e6xxx_pvt_map(chip, dev, port);
1583 mutex_unlock(&chip->reg_lock);
1584
1585 return err;
1586}
1587
1588static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1589 int port, struct net_device *br)
1590{
1591 struct mv88e6xxx_chip *chip = ds->priv;
1592
1593 if (!mv88e6xxx_has_pvt(chip))
1594 return;
1595
1596 mutex_lock(&chip->reg_lock);
1597 if (mv88e6xxx_pvt_map(chip, dev, port))
1598 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1599 mutex_unlock(&chip->reg_lock);
1600}
1601
Vivien Didelot17e708b2016-12-05 17:30:27 -05001602static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1603{
1604 if (chip->info->ops->reset)
1605 return chip->info->ops->reset(chip);
1606
1607 return 0;
1608}
1609
Vivien Didelot309eca62016-12-05 17:30:26 -05001610static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1611{
1612 struct gpio_desc *gpiod = chip->reset;
1613
1614 /* If there is a GPIO connected to the reset pin, toggle it */
1615 if (gpiod) {
1616 gpiod_set_value_cansleep(gpiod, 1);
1617 usleep_range(10000, 20000);
1618 gpiod_set_value_cansleep(gpiod, 0);
1619 usleep_range(10000, 20000);
1620 }
1621}
1622
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001623static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1624{
1625 int i, err;
1626
1627 /* Set all ports to the Disabled state */
1628 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001629 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001630 if (err)
1631 return err;
1632 }
1633
1634 /* Wait for transmit queues to drain,
1635 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1636 */
1637 usleep_range(2000, 4000);
1638
1639 return 0;
1640}
1641
Vivien Didelotfad09c72016-06-21 12:28:20 -04001642static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001643{
Vivien Didelota935c052016-09-29 12:21:53 -04001644 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001645
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001646 err = mv88e6xxx_disable_ports(chip);
1647 if (err)
1648 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001649
Vivien Didelot309eca62016-12-05 17:30:26 -05001650 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001651
Vivien Didelot17e708b2016-12-05 17:30:27 -05001652 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001653}
1654
Vivien Didelot43145572017-03-11 16:12:59 -05001655static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001656 enum mv88e6xxx_frame_mode frame,
1657 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001658{
1659 int err;
1660
Vivien Didelot43145572017-03-11 16:12:59 -05001661 if (!chip->info->ops->port_set_frame_mode)
1662 return -EOPNOTSUPP;
1663
1664 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001665 if (err)
1666 return err;
1667
Vivien Didelot43145572017-03-11 16:12:59 -05001668 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1669 if (err)
1670 return err;
1671
1672 if (chip->info->ops->port_set_ether_type)
1673 return chip->info->ops->port_set_ether_type(chip, port, etype);
1674
1675 return 0;
1676}
1677
1678static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1679{
1680 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001681 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001682 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001683}
1684
1685static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1686{
1687 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001688 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001689 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001690}
1691
1692static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1693{
1694 return mv88e6xxx_set_port_mode(chip, port,
1695 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001696 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1697 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001698}
1699
1700static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1701{
1702 if (dsa_is_dsa_port(chip->ds, port))
1703 return mv88e6xxx_set_port_mode_dsa(chip, port);
1704
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001705 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001706 return mv88e6xxx_set_port_mode_normal(chip, port);
1707
1708 /* Setup CPU port mode depending on its supported tag format */
1709 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1710 return mv88e6xxx_set_port_mode_dsa(chip, port);
1711
1712 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1713 return mv88e6xxx_set_port_mode_edsa(chip, port);
1714
1715 return -EINVAL;
1716}
1717
Vivien Didelotea698f42017-03-11 16:12:50 -05001718static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1719{
1720 bool message = dsa_is_dsa_port(chip->ds, port);
1721
1722 return mv88e6xxx_port_set_message_port(chip, port, message);
1723}
1724
Vivien Didelot601aeed2017-03-11 16:13:00 -05001725static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1726{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001727 struct dsa_switch *ds = chip->ds;
1728 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05001729
1730 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001731 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05001732 if (chip->info->ops->port_set_egress_floods)
1733 return chip->info->ops->port_set_egress_floods(chip, port,
1734 flood, flood);
1735
1736 return 0;
1737}
1738
Andrew Lunn6d917822017-05-26 01:03:21 +02001739static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1740 bool on)
1741{
Vivien Didelot523a8902017-05-26 18:02:42 -04001742 if (chip->info->ops->serdes_power)
1743 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001744
Vivien Didelot523a8902017-05-26 18:02:42 -04001745 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001746}
1747
Vivien Didelotfa371c82017-12-05 15:34:10 -05001748static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
1749{
1750 struct dsa_switch *ds = chip->ds;
1751 int upstream_port;
1752 int err;
1753
Vivien Didelot07073c72017-12-05 15:34:13 -05001754 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05001755 if (chip->info->ops->port_set_upstream_port) {
1756 err = chip->info->ops->port_set_upstream_port(chip, port,
1757 upstream_port);
1758 if (err)
1759 return err;
1760 }
1761
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05001762 if (port == upstream_port) {
1763 if (chip->info->ops->set_cpu_port) {
1764 err = chip->info->ops->set_cpu_port(chip,
1765 upstream_port);
1766 if (err)
1767 return err;
1768 }
1769
1770 if (chip->info->ops->set_egress_port) {
1771 err = chip->info->ops->set_egress_port(chip,
1772 upstream_port);
1773 if (err)
1774 return err;
1775 }
1776 }
1777
Vivien Didelotfa371c82017-12-05 15:34:10 -05001778 return 0;
1779}
1780
Vivien Didelotfad09c72016-06-21 12:28:20 -04001781static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001782{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001783 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001784 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001785 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001786
Vivien Didelotd78343d2016-11-04 03:23:36 +01001787 /* MAC Forcing register: don't force link, speed, duplex or flow control
1788 * state to any particular values on physical ports, but force the CPU
1789 * port and all DSA ports to their maximum bandwidth and full duplex.
1790 */
1791 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1792 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1793 SPEED_MAX, DUPLEX_FULL,
1794 PHY_INTERFACE_MODE_NA);
1795 else
1796 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1797 SPEED_UNFORCED, DUPLEX_UNFORCED,
1798 PHY_INTERFACE_MODE_NA);
1799 if (err)
1800 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001801
1802 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1803 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1804 * tunneling, determine priority by looking at 802.1p and IP
1805 * priority fields (IP prio has precedence), and set STP state
1806 * to Forwarding.
1807 *
1808 * If this is the CPU link, use DSA or EDSA tagging depending
1809 * on which tagging mode was configured.
1810 *
1811 * If this is a link to another switch, use DSA tagging mode.
1812 *
1813 * If this is the upstream port for this switch, enable
1814 * forwarding of unknown unicasts and multicasts.
1815 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001816 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1817 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1818 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1819 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001820 if (err)
1821 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001822
Vivien Didelot601aeed2017-03-11 16:13:00 -05001823 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001824 if (err)
1825 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001826
Vivien Didelot601aeed2017-03-11 16:13:00 -05001827 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001828 if (err)
1829 return err;
1830
Andrew Lunn04aca992017-05-26 01:03:24 +02001831 /* Enable the SERDES interface for DSA and CPU ports. Normal
1832 * ports SERDES are enabled when the port is enabled, thus
1833 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001834 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001835 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1836 err = mv88e6xxx_serdes_power(chip, port, true);
1837 if (err)
1838 return err;
1839 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001840
Vivien Didelot8efdda42015-08-13 12:52:23 -04001841 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001842 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001843 * untagged frames on this port, do a destination address lookup on all
1844 * received packets as usual, disable ARP mirroring and don't send a
1845 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001846 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001847 err = mv88e6xxx_port_set_map_da(chip, port);
1848 if (err)
1849 return err;
1850
Vivien Didelotfa371c82017-12-05 15:34:10 -05001851 err = mv88e6xxx_setup_upstream_port(chip, port);
1852 if (err)
1853 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001854
Andrew Lunna23b2962017-02-04 20:15:28 +01001855 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001856 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001857 if (err)
1858 return err;
1859
Vivien Didelotcd782652017-06-08 18:34:13 -04001860 if (chip->info->ops->port_set_jumbo_size) {
1861 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001862 if (err)
1863 return err;
1864 }
1865
Andrew Lunn54d792f2015-05-06 01:09:47 +02001866 /* Port Association Vector: when learning source addresses
1867 * of packets, add the address to the address database using
1868 * a port bitmap that has only the bit for this port set and
1869 * the other bits clear.
1870 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001871 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001872 /* Disable learning for CPU port */
1873 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001874 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001875
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001876 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1877 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001878 if (err)
1879 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001880
1881 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001882 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1883 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001884 if (err)
1885 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001886
Vivien Didelot08984322017-06-08 18:34:12 -04001887 if (chip->info->ops->port_pause_limit) {
1888 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001889 if (err)
1890 return err;
1891 }
1892
Vivien Didelotc8c94892017-03-11 16:13:01 -05001893 if (chip->info->ops->port_disable_learn_limit) {
1894 err = chip->info->ops->port_disable_learn_limit(chip, port);
1895 if (err)
1896 return err;
1897 }
1898
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001899 if (chip->info->ops->port_disable_pri_override) {
1900 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001901 if (err)
1902 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001903 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001904
Andrew Lunnef0a7312016-12-03 04:35:16 +01001905 if (chip->info->ops->port_tag_remap) {
1906 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001907 if (err)
1908 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001909 }
1910
Andrew Lunnef70b112016-12-03 04:45:18 +01001911 if (chip->info->ops->port_egress_rate_limiting) {
1912 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001913 if (err)
1914 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001915 }
1916
Vivien Didelotea698f42017-03-11 16:12:50 -05001917 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001918 if (err)
1919 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001920
Vivien Didelot207afda2016-04-14 14:42:09 -04001921 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001922 * database, and allow bidirectional communication between the
1923 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001924 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001925 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001926 if (err)
1927 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001928
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001929 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001930 if (err)
1931 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001932
1933 /* Default VLAN ID and priority: don't set a default VLAN
1934 * ID, and set the default packet priority to zero.
1935 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04001936 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02001937}
1938
Andrew Lunn04aca992017-05-26 01:03:24 +02001939static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
1940 struct phy_device *phydev)
1941{
1942 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04001943 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02001944
1945 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001946 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02001947 mutex_unlock(&chip->reg_lock);
1948
1949 return err;
1950}
1951
1952static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
1953 struct phy_device *phydev)
1954{
1955 struct mv88e6xxx_chip *chip = ds->priv;
1956
1957 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001958 if (mv88e6xxx_serdes_power(chip, port, false))
1959 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02001960 mutex_unlock(&chip->reg_lock);
1961}
1962
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001963static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
1964 unsigned int ageing_time)
1965{
Vivien Didelot04bed142016-08-31 18:06:13 -04001966 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001967 int err;
1968
1969 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05001970 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001971 mutex_unlock(&chip->reg_lock);
1972
1973 return err;
1974}
1975
Vivien Didelot97299342016-07-18 20:45:30 -04001976static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04001977{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001978 struct dsa_switch *ds = chip->ds;
Vivien Didelot08a01262016-05-09 13:22:50 -04001979 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04001980
Vivien Didelot50484ff2016-05-09 13:22:54 -04001981 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04001982 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
1983 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04001984 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04001985 if (err)
1986 return err;
1987
Vivien Didelot08a01262016-05-09 13:22:50 -04001988 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04001989 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001990 if (err)
1991 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001992 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001993 if (err)
1994 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001995 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001996 if (err)
1997 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001998 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001999 if (err)
2000 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002001 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002002 if (err)
2003 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002004 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002005 if (err)
2006 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002007 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002008 if (err)
2009 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002010 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002011 if (err)
2012 return err;
2013
2014 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002015 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002016 if (err)
2017 return err;
2018
Andrew Lunnde2273872016-11-21 23:27:01 +01002019 /* Initialize the statistics unit */
2020 err = mv88e6xxx_stats_set_histogram(chip);
2021 if (err)
2022 return err;
2023
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002024 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002025}
2026
Vivien Didelotf81ec902016-05-09 13:22:58 -04002027static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002028{
Vivien Didelot04bed142016-08-31 18:06:13 -04002029 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002030 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002031 int i;
2032
Vivien Didelotfad09c72016-06-21 12:28:20 -04002033 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002034 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002035
Vivien Didelotfad09c72016-06-21 12:28:20 -04002036 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002037
Vivien Didelot97299342016-07-18 20:45:30 -04002038 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002039 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002040 if (dsa_is_unused_port(ds, i))
2041 continue;
2042
Vivien Didelot97299342016-07-18 20:45:30 -04002043 err = mv88e6xxx_setup_port(chip, i);
2044 if (err)
2045 goto unlock;
2046 }
2047
2048 /* Setup Switch Global 1 Registers */
2049 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002050 if (err)
2051 goto unlock;
2052
Vivien Didelot97299342016-07-18 20:45:30 -04002053 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002054 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002055 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002056 if (err)
2057 goto unlock;
2058 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002059
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002060 err = mv88e6xxx_irl_setup(chip);
2061 if (err)
2062 goto unlock;
2063
Vivien Didelot04a69a12017-10-13 14:18:05 -04002064 err = mv88e6xxx_mac_setup(chip);
2065 if (err)
2066 goto unlock;
2067
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002068 err = mv88e6xxx_phy_setup(chip);
2069 if (err)
2070 goto unlock;
2071
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002072 err = mv88e6xxx_vtu_setup(chip);
2073 if (err)
2074 goto unlock;
2075
Vivien Didelot81228992017-03-30 17:37:08 -04002076 err = mv88e6xxx_pvt_setup(chip);
2077 if (err)
2078 goto unlock;
2079
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002080 err = mv88e6xxx_atu_setup(chip);
2081 if (err)
2082 goto unlock;
2083
Andrew Lunn87fa8862017-11-09 22:29:56 +01002084 err = mv88e6xxx_broadcast_setup(chip, 0);
2085 if (err)
2086 goto unlock;
2087
Vivien Didelot9e907d72017-07-17 13:03:43 -04002088 err = mv88e6xxx_pot_setup(chip);
2089 if (err)
2090 goto unlock;
2091
Vivien Didelot51c901a2017-07-17 13:03:41 -04002092 err = mv88e6xxx_rsvd2cpu_setup(chip);
2093 if (err)
2094 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002095
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002096 /* Setup PTP Hardware Clock */
2097 if (chip->info->ptp_support) {
2098 err = mv88e6xxx_ptp_setup(chip);
2099 if (err)
2100 goto unlock;
2101 }
2102
Vivien Didelot6b17e862015-08-13 12:52:18 -04002103unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002104 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002105
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002106 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002107}
2108
Vivien Didelote57e5e72016-08-15 17:19:00 -04002109static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002110{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002111 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2112 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002113 u16 val;
2114 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002115
Andrew Lunnee26a222017-01-24 14:53:48 +01002116 if (!chip->info->ops->phy_read)
2117 return -EOPNOTSUPP;
2118
Vivien Didelotfad09c72016-06-21 12:28:20 -04002119 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002120 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002121 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002122
Andrew Lunnda9f3302017-02-01 03:40:05 +01002123 if (reg == MII_PHYSID2) {
2124 /* Some internal PHYS don't have a model number. Use
2125 * the mv88e6390 family model number instead.
2126 */
2127 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002128 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002129 }
2130
Vivien Didelote57e5e72016-08-15 17:19:00 -04002131 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002132}
2133
Vivien Didelote57e5e72016-08-15 17:19:00 -04002134static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002135{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002136 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2137 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002138 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002139
Andrew Lunnee26a222017-01-24 14:53:48 +01002140 if (!chip->info->ops->phy_write)
2141 return -EOPNOTSUPP;
2142
Vivien Didelotfad09c72016-06-21 12:28:20 -04002143 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002144 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002145 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002146
2147 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002148}
2149
Vivien Didelotfad09c72016-06-21 12:28:20 -04002150static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002151 struct device_node *np,
2152 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002153{
2154 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002155 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002156 struct mii_bus *bus;
2157 int err;
2158
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002159 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002160 if (!bus)
2161 return -ENOMEM;
2162
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002163 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002164 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002165 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002166 INIT_LIST_HEAD(&mdio_bus->list);
2167 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002168
Andrew Lunnb516d452016-06-04 21:17:06 +02002169 if (np) {
2170 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002171 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002172 } else {
2173 bus->name = "mv88e6xxx SMI";
2174 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2175 }
2176
2177 bus->read = mv88e6xxx_mdio_read;
2178 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002179 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002180
Andrew Lunna3c53be52017-01-24 14:53:50 +01002181 if (np)
2182 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002183 else
2184 err = mdiobus_register(bus);
2185 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002186 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002187 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002188 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002189
2190 if (external)
2191 list_add_tail(&mdio_bus->list, &chip->mdios);
2192 else
2193 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002194
2195 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002196}
2197
Andrew Lunna3c53be52017-01-24 14:53:50 +01002198static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2199 { .compatible = "marvell,mv88e6xxx-mdio-external",
2200 .data = (void *)true },
2201 { },
2202};
2203
Andrew Lunn3126aee2017-12-07 01:05:57 +01002204static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2205
2206{
2207 struct mv88e6xxx_mdio_bus *mdio_bus;
2208 struct mii_bus *bus;
2209
2210 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2211 bus = mdio_bus->bus;
2212
2213 mdiobus_unregister(bus);
2214 }
2215}
2216
Andrew Lunna3c53be52017-01-24 14:53:50 +01002217static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2218 struct device_node *np)
2219{
2220 const struct of_device_id *match;
2221 struct device_node *child;
2222 int err;
2223
2224 /* Always register one mdio bus for the internal/default mdio
2225 * bus. This maybe represented in the device tree, but is
2226 * optional.
2227 */
2228 child = of_get_child_by_name(np, "mdio");
2229 err = mv88e6xxx_mdio_register(chip, child, false);
2230 if (err)
2231 return err;
2232
2233 /* Walk the device tree, and see if there are any other nodes
2234 * which say they are compatible with the external mdio
2235 * bus.
2236 */
2237 for_each_available_child_of_node(np, child) {
2238 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2239 if (match) {
2240 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002241 if (err) {
2242 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002243 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002244 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002245 }
2246 }
2247
2248 return 0;
2249}
2250
Vivien Didelot855b1932016-07-20 18:18:35 -04002251static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2252{
Vivien Didelot04bed142016-08-31 18:06:13 -04002253 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002254
2255 return chip->eeprom_len;
2256}
2257
Vivien Didelot855b1932016-07-20 18:18:35 -04002258static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2259 struct ethtool_eeprom *eeprom, u8 *data)
2260{
Vivien Didelot04bed142016-08-31 18:06:13 -04002261 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002262 int err;
2263
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002264 if (!chip->info->ops->get_eeprom)
2265 return -EOPNOTSUPP;
2266
Vivien Didelot855b1932016-07-20 18:18:35 -04002267 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002268 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002269 mutex_unlock(&chip->reg_lock);
2270
2271 if (err)
2272 return err;
2273
2274 eeprom->magic = 0xc3ec4951;
2275
2276 return 0;
2277}
2278
Vivien Didelot855b1932016-07-20 18:18:35 -04002279static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2280 struct ethtool_eeprom *eeprom, u8 *data)
2281{
Vivien Didelot04bed142016-08-31 18:06:13 -04002282 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002283 int err;
2284
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002285 if (!chip->info->ops->set_eeprom)
2286 return -EOPNOTSUPP;
2287
Vivien Didelot855b1932016-07-20 18:18:35 -04002288 if (eeprom->magic != 0xc3ec4951)
2289 return -EINVAL;
2290
2291 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002292 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002293 mutex_unlock(&chip->reg_lock);
2294
2295 return err;
2296}
2297
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002298static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002299 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002300 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002301 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002302 .phy_read = mv88e6185_phy_ppu_read,
2303 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002304 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002305 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002306 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002307 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002308 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002309 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002310 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002311 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002312 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002313 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002314 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002315 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002316 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002317 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2318 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002319 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002320 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2321 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002322 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002323 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002324 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002325 .ppu_enable = mv88e6185_g1_ppu_enable,
2326 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002327 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002328 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002329 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002330};
2331
2332static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002333 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002334 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002335 .phy_read = mv88e6185_phy_ppu_read,
2336 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002337 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002338 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002339 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002340 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002341 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002342 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002343 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002344 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002345 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2346 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002347 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002348 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002349 .ppu_enable = mv88e6185_g1_ppu_enable,
2350 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002351 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002352 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002353 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002354};
2355
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002356static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002357 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002358 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002359 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2360 .phy_read = mv88e6xxx_g2_smi_phy_read,
2361 .phy_write = mv88e6xxx_g2_smi_phy_write,
2362 .port_set_link = mv88e6xxx_port_set_link,
2363 .port_set_duplex = mv88e6xxx_port_set_duplex,
2364 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002365 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002366 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002367 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002368 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002369 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002370 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002371 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002372 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002373 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002374 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002375 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002376 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2377 .stats_get_strings = mv88e6095_stats_get_strings,
2378 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002379 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2380 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002381 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002382 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002383 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002384 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002385 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002386 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002387};
2388
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002389static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002390 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002391 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002392 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002393 .phy_read = mv88e6xxx_g2_smi_phy_read,
2394 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002395 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002396 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002397 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002398 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002399 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002400 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002401 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002402 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002403 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002404 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2405 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002406 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002407 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2408 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002409 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002410 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002411 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002412 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002413 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002414 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002415};
2416
2417static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002418 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002419 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002420 .phy_read = mv88e6185_phy_ppu_read,
2421 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002422 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002423 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002424 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002425 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002426 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002427 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002428 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002429 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002430 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002431 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002432 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002433 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002434 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002435 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2436 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002437 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002438 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2439 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002440 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002441 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002442 .ppu_enable = mv88e6185_g1_ppu_enable,
2443 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002444 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002445 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002446 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002447};
2448
Vivien Didelot990e27b2017-03-28 13:50:32 -04002449static const struct mv88e6xxx_ops mv88e6141_ops = {
2450 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002451 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002452 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2453 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2454 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2455 .phy_read = mv88e6xxx_g2_smi_phy_read,
2456 .phy_write = mv88e6xxx_g2_smi_phy_write,
2457 .port_set_link = mv88e6xxx_port_set_link,
2458 .port_set_duplex = mv88e6xxx_port_set_duplex,
2459 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2460 .port_set_speed = mv88e6390_port_set_speed,
2461 .port_tag_remap = mv88e6095_port_tag_remap,
2462 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2463 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2464 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002465 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002466 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002467 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002468 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2469 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2470 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002471 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002472 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2473 .stats_get_strings = mv88e6320_stats_get_strings,
2474 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002475 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2476 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002477 .watchdog_ops = &mv88e6390_watchdog_ops,
2478 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002479 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002480 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002481 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002482 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002483 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002484};
2485
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002486static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002487 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002488 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002489 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002490 .phy_read = mv88e6xxx_g2_smi_phy_read,
2491 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002492 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002493 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002494 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002495 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002496 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002497 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002498 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002499 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002500 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002501 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002502 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002503 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002504 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002505 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002506 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2507 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002508 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002509 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2510 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002511 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002512 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002513 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002514 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002515 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002516 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002517};
2518
2519static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002520 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002521 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002522 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002523 .phy_read = mv88e6165_phy_read,
2524 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002525 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002526 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002527 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002528 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002529 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002530 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002531 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002532 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2533 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002534 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002535 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2536 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002537 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002538 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002539 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002540 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002541 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002542 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002543};
2544
2545static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002546 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002547 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002548 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002549 .phy_read = mv88e6xxx_g2_smi_phy_read,
2550 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002551 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002552 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002553 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002554 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002555 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002556 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002557 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002558 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002559 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002560 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002561 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002562 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002563 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002564 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002565 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002566 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2567 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002568 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002569 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2570 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002571 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002572 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002573 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002574 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002575 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002576 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002577};
2578
2579static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002580 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002581 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002582 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2583 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002584 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002585 .phy_read = mv88e6xxx_g2_smi_phy_read,
2586 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002587 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002588 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002589 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002590 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002591 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002592 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002593 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002594 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002595 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002596 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002597 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002598 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002599 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002600 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002601 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002602 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2603 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002604 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002605 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2606 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002607 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002608 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002609 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002610 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002611 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002612 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002613 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002614 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002615};
2616
2617static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002618 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002619 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002620 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002621 .phy_read = mv88e6xxx_g2_smi_phy_read,
2622 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002623 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002624 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002625 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002626 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002627 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002628 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002629 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002630 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002631 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002632 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002633 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002634 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002635 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002636 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002637 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002638 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2639 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002640 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002641 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2642 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002643 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002644 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002645 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002646 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002647 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002648 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002649};
2650
2651static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002652 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002653 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002654 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2655 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002656 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002657 .phy_read = mv88e6xxx_g2_smi_phy_read,
2658 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002659 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002660 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002661 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002662 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002663 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002664 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002665 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002666 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002667 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002668 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002669 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002670 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002671 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002672 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002673 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002674 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2675 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002676 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002677 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2678 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002679 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002680 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002681 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002682 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002683 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002684 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002685 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002686 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002687};
2688
2689static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002690 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002691 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002692 .phy_read = mv88e6185_phy_ppu_read,
2693 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002694 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002695 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002696 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002697 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002698 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002699 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002700 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002701 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002702 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002703 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2704 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002705 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002706 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2707 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002708 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002709 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002710 .ppu_enable = mv88e6185_g1_ppu_enable,
2711 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002712 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002713 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002714 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002715};
2716
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002717static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002718 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002719 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002720 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2721 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002722 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2723 .phy_read = mv88e6xxx_g2_smi_phy_read,
2724 .phy_write = mv88e6xxx_g2_smi_phy_write,
2725 .port_set_link = mv88e6xxx_port_set_link,
2726 .port_set_duplex = mv88e6xxx_port_set_duplex,
2727 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2728 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002729 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002730 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002731 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002732 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002733 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002734 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002735 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002736 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002737 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002738 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2739 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002740 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002741 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2742 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002743 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002744 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002745 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002746 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002747 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2748 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002749 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002750 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002751};
2752
2753static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002754 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002755 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002756 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2757 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002758 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2759 .phy_read = mv88e6xxx_g2_smi_phy_read,
2760 .phy_write = mv88e6xxx_g2_smi_phy_write,
2761 .port_set_link = mv88e6xxx_port_set_link,
2762 .port_set_duplex = mv88e6xxx_port_set_duplex,
2763 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2764 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002765 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002766 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002767 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002768 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002769 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002770 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002771 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002772 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002773 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002774 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2775 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002776 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002777 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2778 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002779 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002780 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002781 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002782 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002783 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2784 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002785 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002786 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002787};
2788
2789static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002790 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002791 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002792 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2793 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002794 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2795 .phy_read = mv88e6xxx_g2_smi_phy_read,
2796 .phy_write = mv88e6xxx_g2_smi_phy_write,
2797 .port_set_link = mv88e6xxx_port_set_link,
2798 .port_set_duplex = mv88e6xxx_port_set_duplex,
2799 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2800 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002801 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002802 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002803 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002804 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002805 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002806 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002807 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002808 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002809 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002810 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2811 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002812 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002813 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2814 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002815 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002816 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002817 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002818 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002819 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2820 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002821 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002822};
2823
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002824static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002825 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002826 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002827 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2828 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002829 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002830 .phy_read = mv88e6xxx_g2_smi_phy_read,
2831 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002832 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002833 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002834 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002835 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002836 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002837 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002838 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002839 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002840 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002841 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002842 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002843 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002844 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002845 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002846 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002847 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2848 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002849 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002850 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2851 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002852 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002853 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002854 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002855 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002856 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002857 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002858 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002859 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002860 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002861};
2862
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002863static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002864 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002865 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002866 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2867 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002868 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2869 .phy_read = mv88e6xxx_g2_smi_phy_read,
2870 .phy_write = mv88e6xxx_g2_smi_phy_write,
2871 .port_set_link = mv88e6xxx_port_set_link,
2872 .port_set_duplex = mv88e6xxx_port_set_duplex,
2873 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2874 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002875 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002876 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002877 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002878 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002879 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002880 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002881 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002882 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002883 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002884 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002885 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2886 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002887 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002888 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2889 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002890 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002891 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002892 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002893 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002894 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2895 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002896 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002897 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002898 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002899};
2900
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002901static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002902 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002903 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002904 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2905 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002906 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002907 .phy_read = mv88e6xxx_g2_smi_phy_read,
2908 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002909 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002910 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002911 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002912 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002913 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002914 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002915 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002916 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002917 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002918 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002919 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002920 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002921 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002922 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002923 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2924 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002925 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002926 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2927 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002928 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002929 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002930 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002931 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002932 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002933 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002934 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002935};
2936
2937static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04002938 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002939 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002940 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2941 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002942 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002943 .phy_read = mv88e6xxx_g2_smi_phy_read,
2944 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002945 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002946 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002947 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002948 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002949 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002950 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002951 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002952 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002953 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002954 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002955 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002956 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002957 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002958 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002959 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2960 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002961 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002962 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2963 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002964 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002965 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002966 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002967 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002968 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002969};
2970
Vivien Didelot16e329a2017-03-28 13:50:33 -04002971static const struct mv88e6xxx_ops mv88e6341_ops = {
2972 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002973 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002974 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2975 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2976 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2977 .phy_read = mv88e6xxx_g2_smi_phy_read,
2978 .phy_write = mv88e6xxx_g2_smi_phy_write,
2979 .port_set_link = mv88e6xxx_port_set_link,
2980 .port_set_duplex = mv88e6xxx_port_set_duplex,
2981 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2982 .port_set_speed = mv88e6390_port_set_speed,
2983 .port_tag_remap = mv88e6095_port_tag_remap,
2984 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2985 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2986 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002987 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002988 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002989 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002990 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2991 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2992 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002993 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002994 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2995 .stats_get_strings = mv88e6320_stats_get_strings,
2996 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002997 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2998 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002999 .watchdog_ops = &mv88e6390_watchdog_ops,
3000 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003001 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003002 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003003 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003004 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003005 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003006 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003007};
3008
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003009static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003010 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003011 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003012 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003013 .phy_read = mv88e6xxx_g2_smi_phy_read,
3014 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003015 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003016 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003017 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003018 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003019 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003020 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003021 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003022 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003023 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003024 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003025 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003026 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003027 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003028 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003029 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003030 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3031 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003032 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003033 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3034 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003035 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003036 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003037 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003038 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003039 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003040 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003041};
3042
3043static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003044 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003045 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003046 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003047 .phy_read = mv88e6xxx_g2_smi_phy_read,
3048 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003049 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003050 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003051 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003052 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003053 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003054 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003055 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003056 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003057 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003058 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003059 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003060 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003061 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003062 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003063 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003064 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3065 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003066 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003067 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3068 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003069 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003070 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003071 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003072 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003073 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003074 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003075 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003076};
3077
3078static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003079 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003080 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003081 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3082 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003083 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003084 .phy_read = mv88e6xxx_g2_smi_phy_read,
3085 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003086 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003087 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003088 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003089 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003090 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003091 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003092 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003093 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003094 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003095 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003096 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003097 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003098 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003099 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003100 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003101 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3102 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003103 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003104 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3105 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003106 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003107 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003108 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003109 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003110 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003111 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003112 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003113 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003114 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003115};
3116
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003117static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003118 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003119 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003120 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3121 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003122 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3123 .phy_read = mv88e6xxx_g2_smi_phy_read,
3124 .phy_write = mv88e6xxx_g2_smi_phy_write,
3125 .port_set_link = mv88e6xxx_port_set_link,
3126 .port_set_duplex = mv88e6xxx_port_set_duplex,
3127 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3128 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003129 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003130 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003131 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003132 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003133 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003134 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003135 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003136 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003137 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003138 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003139 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003140 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003141 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3142 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003143 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003144 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3145 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003146 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003147 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003148 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003149 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003150 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3151 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003152 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003153 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003154 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003155};
3156
3157static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003158 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003159 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003160 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3161 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003162 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3163 .phy_read = mv88e6xxx_g2_smi_phy_read,
3164 .phy_write = mv88e6xxx_g2_smi_phy_write,
3165 .port_set_link = mv88e6xxx_port_set_link,
3166 .port_set_duplex = mv88e6xxx_port_set_duplex,
3167 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3168 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003169 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003170 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003171 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003172 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003173 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003174 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003175 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003176 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003177 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003178 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003179 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003180 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003181 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3182 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003183 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003184 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3185 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003186 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003187 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003188 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003189 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003190 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3191 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003192 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003193 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003194 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003195};
3196
Vivien Didelotf81ec902016-05-09 13:22:58 -04003197static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3198 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003199 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003200 .family = MV88E6XXX_FAMILY_6097,
3201 .name = "Marvell 88E6085",
3202 .num_databases = 4096,
3203 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003204 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003205 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003206 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003207 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003208 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003209 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003210 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003211 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003212 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003213 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003214 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003215 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003216 },
3217
3218 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003219 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003220 .family = MV88E6XXX_FAMILY_6095,
3221 .name = "Marvell 88E6095/88E6095F",
3222 .num_databases = 256,
3223 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003224 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003225 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003226 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003227 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003228 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003229 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003230 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003231 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003232 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003233 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003234 },
3235
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003236 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003237 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003238 .family = MV88E6XXX_FAMILY_6097,
3239 .name = "Marvell 88E6097/88E6097F",
3240 .num_databases = 4096,
3241 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003242 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003243 .port_base_addr = 0x10,
3244 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003245 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003246 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003247 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003248 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003249 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003250 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003251 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003252 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003253 .ops = &mv88e6097_ops,
3254 },
3255
Vivien Didelotf81ec902016-05-09 13:22:58 -04003256 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003257 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003258 .family = MV88E6XXX_FAMILY_6165,
3259 .name = "Marvell 88E6123",
3260 .num_databases = 4096,
3261 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003262 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003263 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003264 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003265 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003266 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003267 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003268 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003269 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003270 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003271 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003272 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003273 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003274 },
3275
3276 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003277 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003278 .family = MV88E6XXX_FAMILY_6185,
3279 .name = "Marvell 88E6131",
3280 .num_databases = 256,
3281 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003282 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003283 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003284 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003285 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003286 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003287 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003288 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003289 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003290 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003291 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003292 },
3293
Vivien Didelot990e27b2017-03-28 13:50:32 -04003294 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003295 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003296 .family = MV88E6XXX_FAMILY_6341,
3297 .name = "Marvell 88E6341",
3298 .num_databases = 4096,
3299 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003300 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003301 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003302 .port_base_addr = 0x10,
3303 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003304 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003305 .age_time_coeff = 3750,
3306 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003307 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003308 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003309 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003310 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003311 .ops = &mv88e6141_ops,
3312 },
3313
Vivien Didelotf81ec902016-05-09 13:22:58 -04003314 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003315 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003316 .family = MV88E6XXX_FAMILY_6165,
3317 .name = "Marvell 88E6161",
3318 .num_databases = 4096,
3319 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003320 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003321 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003322 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003323 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003324 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003325 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003326 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003327 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003328 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003329 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003330 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003331 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003332 },
3333
3334 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003335 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003336 .family = MV88E6XXX_FAMILY_6165,
3337 .name = "Marvell 88E6165",
3338 .num_databases = 4096,
3339 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003340 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003341 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003342 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003343 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003344 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003345 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003346 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003347 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003348 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003349 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003350 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003351 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003352 },
3353
3354 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003355 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003356 .family = MV88E6XXX_FAMILY_6351,
3357 .name = "Marvell 88E6171",
3358 .num_databases = 4096,
3359 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003360 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003361 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003362 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003363 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003364 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003365 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003366 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003367 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003368 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003369 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003370 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003371 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003372 },
3373
3374 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003375 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003376 .family = MV88E6XXX_FAMILY_6352,
3377 .name = "Marvell 88E6172",
3378 .num_databases = 4096,
3379 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003380 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003381 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003382 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003383 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003384 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003385 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003386 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003387 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003388 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003389 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003390 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003391 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003392 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003393 },
3394
3395 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003396 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003397 .family = MV88E6XXX_FAMILY_6351,
3398 .name = "Marvell 88E6175",
3399 .num_databases = 4096,
3400 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003401 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003402 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003403 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003404 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003405 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003406 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003407 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003408 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003409 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003410 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003411 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003412 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003413 },
3414
3415 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003416 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003417 .family = MV88E6XXX_FAMILY_6352,
3418 .name = "Marvell 88E6176",
3419 .num_databases = 4096,
3420 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003421 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003422 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003423 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003424 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003425 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003426 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003427 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003428 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003429 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003430 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003431 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003432 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003433 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003434 },
3435
3436 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003437 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003438 .family = MV88E6XXX_FAMILY_6185,
3439 .name = "Marvell 88E6185",
3440 .num_databases = 256,
3441 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003442 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003443 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003444 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003445 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003446 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003447 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003448 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003449 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003450 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003451 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003452 },
3453
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003454 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003455 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003456 .family = MV88E6XXX_FAMILY_6390,
3457 .name = "Marvell 88E6190",
3458 .num_databases = 4096,
3459 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003460 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003461 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003462 .port_base_addr = 0x0,
3463 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003464 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003465 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003466 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003467 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003468 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003469 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003470 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003471 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003472 .ops = &mv88e6190_ops,
3473 },
3474
3475 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003476 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003477 .family = MV88E6XXX_FAMILY_6390,
3478 .name = "Marvell 88E6190X",
3479 .num_databases = 4096,
3480 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003481 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003482 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003483 .port_base_addr = 0x0,
3484 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003485 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003486 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003487 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003488 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003489 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003490 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003491 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003492 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003493 .ops = &mv88e6190x_ops,
3494 },
3495
3496 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003497 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003498 .family = MV88E6XXX_FAMILY_6390,
3499 .name = "Marvell 88E6191",
3500 .num_databases = 4096,
3501 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003502 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003503 .port_base_addr = 0x0,
3504 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003505 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003506 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003507 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003508 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003509 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003510 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003511 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003512 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003513 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003514 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003515 },
3516
Vivien Didelotf81ec902016-05-09 13:22:58 -04003517 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003518 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003519 .family = MV88E6XXX_FAMILY_6352,
3520 .name = "Marvell 88E6240",
3521 .num_databases = 4096,
3522 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003523 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003524 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003525 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003526 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003527 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003528 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003529 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003530 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003531 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003532 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003533 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003534 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003535 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003536 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003537 },
3538
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003539 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003540 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003541 .family = MV88E6XXX_FAMILY_6390,
3542 .name = "Marvell 88E6290",
3543 .num_databases = 4096,
3544 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003545 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003546 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003547 .port_base_addr = 0x0,
3548 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003549 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003550 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003551 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003552 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003553 .atu_move_port_mask = 0x1f,
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_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003557 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003558 .ops = &mv88e6290_ops,
3559 },
3560
Vivien Didelotf81ec902016-05-09 13:22:58 -04003561 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003562 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003563 .family = MV88E6XXX_FAMILY_6320,
3564 .name = "Marvell 88E6320",
3565 .num_databases = 4096,
3566 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003567 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003568 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003569 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003570 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003571 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003572 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003573 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003574 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003575 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003576 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003577 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003578 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003579 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003580 },
3581
3582 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003583 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003584 .family = MV88E6XXX_FAMILY_6320,
3585 .name = "Marvell 88E6321",
3586 .num_databases = 4096,
3587 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003588 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003589 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003590 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003591 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003592 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003593 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003594 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003595 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003596 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003597 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003598 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003599 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003600 },
3601
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003602 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003603 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003604 .family = MV88E6XXX_FAMILY_6341,
3605 .name = "Marvell 88E6341",
3606 .num_databases = 4096,
3607 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003608 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003609 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003610 .port_base_addr = 0x10,
3611 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003612 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003613 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003614 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003615 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003616 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003617 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003618 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003619 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003620 .ops = &mv88e6341_ops,
3621 },
3622
Vivien Didelotf81ec902016-05-09 13:22:58 -04003623 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003624 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003625 .family = MV88E6XXX_FAMILY_6351,
3626 .name = "Marvell 88E6350",
3627 .num_databases = 4096,
3628 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003629 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003630 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003631 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003632 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003633 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003634 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003635 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003636 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003637 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003638 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003639 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003640 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003641 },
3642
3643 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003644 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003645 .family = MV88E6XXX_FAMILY_6351,
3646 .name = "Marvell 88E6351",
3647 .num_databases = 4096,
3648 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003649 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003650 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003651 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003652 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003653 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003654 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003655 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003656 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003657 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003658 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003659 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003660 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003661 },
3662
3663 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003664 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003665 .family = MV88E6XXX_FAMILY_6352,
3666 .name = "Marvell 88E6352",
3667 .num_databases = 4096,
3668 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003669 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003670 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003671 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003672 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003673 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003674 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003675 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003676 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003677 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003678 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003679 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003680 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003681 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003682 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003683 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003684 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003685 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003686 .family = MV88E6XXX_FAMILY_6390,
3687 .name = "Marvell 88E6390",
3688 .num_databases = 4096,
3689 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003690 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003691 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003692 .port_base_addr = 0x0,
3693 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003694 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003695 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003696 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003697 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003698 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003699 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003700 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003701 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003702 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003703 .ops = &mv88e6390_ops,
3704 },
3705 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003706 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003707 .family = MV88E6XXX_FAMILY_6390,
3708 .name = "Marvell 88E6390X",
3709 .num_databases = 4096,
3710 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003711 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003712 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003713 .port_base_addr = 0x0,
3714 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003715 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003716 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003717 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003718 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003719 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003720 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003721 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003722 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003723 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003724 .ops = &mv88e6390x_ops,
3725 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003726};
3727
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003728static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003729{
Vivien Didelota439c062016-04-17 13:23:58 -04003730 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003731
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003732 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3733 if (mv88e6xxx_table[i].prod_num == prod_num)
3734 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003735
Vivien Didelotb9b37712015-10-30 19:39:48 -04003736 return NULL;
3737}
3738
Vivien Didelotfad09c72016-06-21 12:28:20 -04003739static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003740{
3741 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003742 unsigned int prod_num, rev;
3743 u16 id;
3744 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003745
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003746 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003747 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003748 mutex_unlock(&chip->reg_lock);
3749 if (err)
3750 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003751
Vivien Didelot107fcc12017-06-12 12:37:36 -04003752 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3753 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003754
3755 info = mv88e6xxx_lookup_info(prod_num);
3756 if (!info)
3757 return -ENODEV;
3758
Vivien Didelotcaac8542016-06-20 13:14:09 -04003759 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003760 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003761
Vivien Didelotca070c12016-09-02 14:45:34 -04003762 err = mv88e6xxx_g2_require(chip);
3763 if (err)
3764 return err;
3765
Vivien Didelotfad09c72016-06-21 12:28:20 -04003766 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3767 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003768
3769 return 0;
3770}
3771
Vivien Didelotfad09c72016-06-21 12:28:20 -04003772static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003773{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003774 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003775
Vivien Didelotfad09c72016-06-21 12:28:20 -04003776 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3777 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003778 return NULL;
3779
Vivien Didelotfad09c72016-06-21 12:28:20 -04003780 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003781
Vivien Didelotfad09c72016-06-21 12:28:20 -04003782 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003783 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003784
Vivien Didelotfad09c72016-06-21 12:28:20 -04003785 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003786}
3787
Vivien Didelotfad09c72016-06-21 12:28:20 -04003788static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003789 struct mii_bus *bus, int sw_addr)
3790{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003791 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003792 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003793 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003794 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003795 else
3796 return -EINVAL;
3797
Vivien Didelotfad09c72016-06-21 12:28:20 -04003798 chip->bus = bus;
3799 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003800
3801 return 0;
3802}
3803
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08003804static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
3805 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02003806{
Vivien Didelot04bed142016-08-31 18:06:13 -04003807 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003808
Andrew Lunn443d5a12016-12-03 04:35:18 +01003809 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003810}
3811
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003812#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003813static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3814 struct device *host_dev, int sw_addr,
3815 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003816{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003817 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003818 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003819 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003820
Vivien Didelota439c062016-04-17 13:23:58 -04003821 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003822 if (!bus)
3823 return NULL;
3824
Vivien Didelotfad09c72016-06-21 12:28:20 -04003825 chip = mv88e6xxx_alloc_chip(dsa_dev);
3826 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003827 return NULL;
3828
Vivien Didelotcaac8542016-06-20 13:14:09 -04003829 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003830 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003831
Vivien Didelotfad09c72016-06-21 12:28:20 -04003832 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003833 if (err)
3834 goto free;
3835
Vivien Didelotfad09c72016-06-21 12:28:20 -04003836 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003837 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003838 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003839
Andrew Lunndc30c352016-10-16 19:56:49 +02003840 mutex_lock(&chip->reg_lock);
3841 err = mv88e6xxx_switch_reset(chip);
3842 mutex_unlock(&chip->reg_lock);
3843 if (err)
3844 goto free;
3845
Vivien Didelote57e5e72016-08-15 17:19:00 -04003846 mv88e6xxx_phy_init(chip);
3847
Andrew Lunna3c53be52017-01-24 14:53:50 +01003848 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003849 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003850 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003851
Vivien Didelotfad09c72016-06-21 12:28:20 -04003852 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003853
Vivien Didelotfad09c72016-06-21 12:28:20 -04003854 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003855free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003856 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003857
3858 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003859}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003860#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02003861
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003862static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003863 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003864{
3865 /* We don't need any dynamic resource from the kernel (yet),
3866 * so skip the prepare phase.
3867 */
3868
3869 return 0;
3870}
3871
3872static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003873 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003874{
Vivien Didelot04bed142016-08-31 18:06:13 -04003875 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003876
3877 mutex_lock(&chip->reg_lock);
3878 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003879 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003880 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3881 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003882 mutex_unlock(&chip->reg_lock);
3883}
3884
3885static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3886 const struct switchdev_obj_port_mdb *mdb)
3887{
Vivien Didelot04bed142016-08-31 18:06:13 -04003888 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003889 int err;
3890
3891 mutex_lock(&chip->reg_lock);
3892 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003893 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003894 mutex_unlock(&chip->reg_lock);
3895
3896 return err;
3897}
3898
Florian Fainellia82f67a2017-01-08 14:52:08 -08003899static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003900#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003901 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003902#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02003903 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003904 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003905 .adjust_link = mv88e6xxx_adjust_link,
3906 .get_strings = mv88e6xxx_get_strings,
3907 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3908 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003909 .port_enable = mv88e6xxx_port_enable,
3910 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04003911 .get_mac_eee = mv88e6xxx_get_mac_eee,
3912 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003913 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003914 .get_eeprom = mv88e6xxx_get_eeprom,
3915 .set_eeprom = mv88e6xxx_set_eeprom,
3916 .get_regs_len = mv88e6xxx_get_regs_len,
3917 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003918 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003919 .port_bridge_join = mv88e6xxx_port_bridge_join,
3920 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3921 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04003922 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003923 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3924 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3925 .port_vlan_add = mv88e6xxx_port_vlan_add,
3926 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003927 .port_fdb_add = mv88e6xxx_port_fdb_add,
3928 .port_fdb_del = mv88e6xxx_port_fdb_del,
3929 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003930 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
3931 .port_mdb_add = mv88e6xxx_port_mdb_add,
3932 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04003933 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
3934 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003935};
3936
Florian Fainelliab3d4082017-01-08 14:52:07 -08003937static struct dsa_switch_driver mv88e6xxx_switch_drv = {
3938 .ops = &mv88e6xxx_switch_ops,
3939};
3940
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003941static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003942{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003943 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003944 struct dsa_switch *ds;
3945
Vivien Didelot73b12042017-03-30 17:37:10 -04003946 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003947 if (!ds)
3948 return -ENOMEM;
3949
Vivien Didelotfad09c72016-06-21 12:28:20 -04003950 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04003951 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04003952 ds->ageing_time_min = chip->info->age_time_coeff;
3953 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003954
3955 dev_set_drvdata(dev, ds);
3956
Vivien Didelot23c9ee42017-05-26 18:12:51 -04003957 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003958}
3959
Vivien Didelotfad09c72016-06-21 12:28:20 -04003960static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003961{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003962 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003963}
3964
Vivien Didelot57d32312016-06-20 13:13:58 -04003965static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003966{
3967 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003968 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003969 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003970 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003971 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02003972 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003973
Vivien Didelotcaac8542016-06-20 13:14:09 -04003974 compat_info = of_device_get_match_data(dev);
3975 if (!compat_info)
3976 return -EINVAL;
3977
Vivien Didelotfad09c72016-06-21 12:28:20 -04003978 chip = mv88e6xxx_alloc_chip(dev);
3979 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003980 return -ENOMEM;
3981
Vivien Didelotfad09c72016-06-21 12:28:20 -04003982 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003983
Vivien Didelotfad09c72016-06-21 12:28:20 -04003984 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003985 if (err)
3986 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003987
Andrew Lunnb4308f02016-11-21 23:26:55 +01003988 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
3989 if (IS_ERR(chip->reset))
3990 return PTR_ERR(chip->reset);
3991
Vivien Didelotfad09c72016-06-21 12:28:20 -04003992 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003993 if (err)
3994 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003995
Vivien Didelote57e5e72016-08-15 17:19:00 -04003996 mv88e6xxx_phy_init(chip);
3997
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003998 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003999 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004000 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004001
Andrew Lunndc30c352016-10-16 19:56:49 +02004002 mutex_lock(&chip->reg_lock);
4003 err = mv88e6xxx_switch_reset(chip);
4004 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004005 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004006 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004007
Andrew Lunndc30c352016-10-16 19:56:49 +02004008 chip->irq = of_irq_get(np, 0);
4009 if (chip->irq == -EPROBE_DEFER) {
4010 err = chip->irq;
4011 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004012 }
4013
Andrew Lunndc30c352016-10-16 19:56:49 +02004014 if (chip->irq > 0) {
4015 /* Has to be performed before the MDIO bus is created,
4016 * because the PHYs will link there interrupts to these
4017 * interrupt controllers
4018 */
4019 mutex_lock(&chip->reg_lock);
4020 err = mv88e6xxx_g1_irq_setup(chip);
4021 mutex_unlock(&chip->reg_lock);
4022
4023 if (err)
4024 goto out;
4025
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004026 if (chip->info->g2_irqs > 0) {
Andrew Lunndc30c352016-10-16 19:56:49 +02004027 err = mv88e6xxx_g2_irq_setup(chip);
4028 if (err)
4029 goto out_g1_irq;
4030 }
Andrew Lunn09776442018-01-14 02:32:44 +01004031
4032 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4033 if (err)
4034 goto out_g2_irq;
Andrew Lunn62eb1162018-01-14 02:32:45 +01004035
4036 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4037 if (err)
4038 goto out_g1_atu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004039 }
4040
Andrew Lunna3c53be52017-01-24 14:53:50 +01004041 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004042 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004043 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004044
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004045 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004046 if (err)
4047 goto out_mdio;
4048
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004049 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004050
4051out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004052 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004053out_g1_vtu_prob_irq:
Andrew Lunnae14caf2018-01-18 17:42:50 +01004054 if (chip->irq > 0)
4055 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004056out_g1_atu_prob_irq:
Andrew Lunnae14caf2018-01-18 17:42:50 +01004057 if (chip->irq > 0)
4058 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004059out_g2_irq:
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004060 if (chip->info->g2_irqs > 0 && chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004061 mv88e6xxx_g2_irq_free(chip);
4062out_g1_irq:
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004063 if (chip->irq > 0) {
4064 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004065 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004066 mutex_unlock(&chip->reg_lock);
4067 }
Andrew Lunndc30c352016-10-16 19:56:49 +02004068out:
4069 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004070}
4071
4072static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4073{
4074 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004075 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004076
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004077 if (chip->info->ptp_support)
4078 mv88e6xxx_ptp_free(chip);
4079
Andrew Lunn930188c2016-08-22 16:01:03 +02004080 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004081 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004082 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004083
Andrew Lunn467126442016-11-20 20:14:15 +01004084 if (chip->irq > 0) {
Andrew Lunn62eb1162018-01-14 02:32:45 +01004085 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004086 mv88e6xxx_g1_atu_prob_irq_free(chip);
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004087 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004088 mv88e6xxx_g2_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004089 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004090 mv88e6xxx_g1_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004091 mutex_unlock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004092 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004093}
4094
4095static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004096 {
4097 .compatible = "marvell,mv88e6085",
4098 .data = &mv88e6xxx_table[MV88E6085],
4099 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004100 {
4101 .compatible = "marvell,mv88e6190",
4102 .data = &mv88e6xxx_table[MV88E6190],
4103 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004104 { /* sentinel */ },
4105};
4106
4107MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4108
4109static struct mdio_driver mv88e6xxx_driver = {
4110 .probe = mv88e6xxx_probe,
4111 .remove = mv88e6xxx_remove,
4112 .mdiodrv.driver = {
4113 .name = "mv88e6085",
4114 .of_match_table = mv88e6xxx_of_match,
4115 },
4116};
4117
Ben Hutchings98e67302011-11-25 14:36:19 +00004118static int __init mv88e6xxx_init(void)
4119{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004120 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004121 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004122}
4123module_init(mv88e6xxx_init);
4124
4125static void __exit mv88e6xxx_cleanup(void)
4126{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004127 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004128 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004129}
4130module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004131
4132MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4133MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4134MODULE_LICENSE("GPL");