blob: bd5cb8a0330e7b3c2a756a3d165e21009bf3420a [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"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010039#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020040#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010041#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010042#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020043#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000044
Vivien Didelotfad09c72016-06-21 12:28:20 -040045static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040046{
Vivien Didelotfad09c72016-06-21 12:28:20 -040047 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
48 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040049 dump_stack();
50 }
51}
52
Vivien Didelot914b32f2016-06-20 13:14:11 -040053/* The switch ADDR[4:1] configuration pins define the chip SMI device address
54 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
55 *
56 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
57 * is the only device connected to the SMI master. In this mode it responds to
58 * all 32 possible SMI addresses, and thus maps directly the internal devices.
59 *
60 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
61 * multiple devices to share the SMI interface. In this mode it responds to only
62 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000063 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040064
Vivien Didelotfad09c72016-06-21 12:28:20 -040065static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040066 int addr, int reg, u16 *val)
67{
Vivien Didelotfad09c72016-06-21 12:28:20 -040068 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069 return -EOPNOTSUPP;
70
Vivien Didelotfad09c72016-06-21 12:28:20 -040071 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040072}
73
Vivien Didelotfad09c72016-06-21 12:28:20 -040074static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 int addr, int reg, u16 val)
76{
Vivien Didelotfad09c72016-06-21 12:28:20 -040077 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040078 return -EOPNOTSUPP;
79
Vivien Didelotfad09c72016-06-21 12:28:20 -040080 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040081}
82
Vivien Didelotfad09c72016-06-21 12:28:20 -040083static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040084 int addr, int reg, u16 *val)
85{
86 int ret;
87
Vivien Didelotfad09c72016-06-21 12:28:20 -040088 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040089 if (ret < 0)
90 return ret;
91
92 *val = ret & 0xffff;
93
94 return 0;
95}
96
Vivien Didelotfad09c72016-06-21 12:28:20 -040097static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040098 int addr, int reg, u16 val)
99{
100 int ret;
101
Vivien Didelotfad09c72016-06-21 12:28:20 -0400102 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400103 if (ret < 0)
104 return ret;
105
106 return 0;
107}
108
Vivien Didelotc08026a2016-09-29 12:21:59 -0400109static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400110 .read = mv88e6xxx_smi_single_chip_read,
111 .write = mv88e6xxx_smi_single_chip_write,
112};
113
Vivien Didelotfad09c72016-06-21 12:28:20 -0400114static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000115{
116 int ret;
117 int i;
118
119 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400120 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000121 if (ret < 0)
122 return ret;
123
Andrew Lunncca8b132015-04-02 04:06:39 +0200124 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000125 return 0;
126 }
127
128 return -ETIMEDOUT;
129}
130
Vivien Didelotfad09c72016-06-21 12:28:20 -0400131static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400132 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000133{
134 int ret;
135
Barry Grussling3675c8d2013-01-08 16:05:53 +0000136 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400137 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000138 if (ret < 0)
139 return ret;
140
Barry Grussling3675c8d2013-01-08 16:05:53 +0000141 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400142 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200143 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000144 if (ret < 0)
145 return ret;
146
Barry Grussling3675c8d2013-01-08 16:05:53 +0000147 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400148 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000149 if (ret < 0)
150 return ret;
151
Barry Grussling3675c8d2013-01-08 16:05:53 +0000152 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400153 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000154 if (ret < 0)
155 return ret;
156
Vivien Didelot914b32f2016-06-20 13:14:11 -0400157 *val = ret & 0xffff;
158
159 return 0;
160}
161
Vivien Didelotfad09c72016-06-21 12:28:20 -0400162static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400163 int addr, int reg, u16 val)
164{
165 int ret;
166
167 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400168 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400169 if (ret < 0)
170 return ret;
171
172 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400173 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400174 if (ret < 0)
175 return ret;
176
177 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400178 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400179 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
180 if (ret < 0)
181 return ret;
182
183 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400184 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400185 if (ret < 0)
186 return ret;
187
188 return 0;
189}
190
Vivien Didelotc08026a2016-09-29 12:21:59 -0400191static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400192 .read = mv88e6xxx_smi_multi_chip_read,
193 .write = mv88e6xxx_smi_multi_chip_write,
194};
195
Vivien Didelotec561272016-09-02 14:45:33 -0400196int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400197{
198 int err;
199
Vivien Didelotfad09c72016-06-21 12:28:20 -0400200 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400201
Vivien Didelotfad09c72016-06-21 12:28:20 -0400202 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400203 if (err)
204 return err;
205
Vivien Didelotfad09c72016-06-21 12:28:20 -0400206 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400207 addr, reg, *val);
208
209 return 0;
210}
211
Vivien Didelotec561272016-09-02 14:45:33 -0400212int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400213{
214 int err;
215
Vivien Didelotfad09c72016-06-21 12:28:20 -0400216 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400217
Vivien Didelotfad09c72016-06-21 12:28:20 -0400218 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400219 if (err)
220 return err;
221
Vivien Didelotfad09c72016-06-21 12:28:20 -0400222 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400223 addr, reg, val);
224
225 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000226}
227
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200228struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100229{
230 struct mv88e6xxx_mdio_bus *mdio_bus;
231
232 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
233 list);
234 if (!mdio_bus)
235 return NULL;
236
237 return mdio_bus->bus;
238}
239
Andrew Lunndc30c352016-10-16 19:56:49 +0200240static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
241{
242 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
243 unsigned int n = d->hwirq;
244
245 chip->g1_irq.masked |= (1 << n);
246}
247
248static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
249{
250 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
251 unsigned int n = d->hwirq;
252
253 chip->g1_irq.masked &= ~(1 << n);
254}
255
256static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
257{
258 struct mv88e6xxx_chip *chip = dev_id;
259 unsigned int nhandled = 0;
260 unsigned int sub_irq;
261 unsigned int n;
262 u16 reg;
263 int err;
264
265 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400266 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200267 mutex_unlock(&chip->reg_lock);
268
269 if (err)
270 goto out;
271
272 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
273 if (reg & (1 << n)) {
274 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
275 handle_nested_irq(sub_irq);
276 ++nhandled;
277 }
278 }
279out:
280 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
281}
282
283static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
284{
285 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
286
287 mutex_lock(&chip->reg_lock);
288}
289
290static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
291{
292 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
293 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
294 u16 reg;
295 int err;
296
Vivien Didelotd77f4322017-06-15 12:14:03 -0400297 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200298 if (err)
299 goto out;
300
301 reg &= ~mask;
302 reg |= (~chip->g1_irq.masked & mask);
303
Vivien Didelotd77f4322017-06-15 12:14:03 -0400304 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200305 if (err)
306 goto out;
307
308out:
309 mutex_unlock(&chip->reg_lock);
310}
311
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530312static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200313 .name = "mv88e6xxx-g1",
314 .irq_mask = mv88e6xxx_g1_irq_mask,
315 .irq_unmask = mv88e6xxx_g1_irq_unmask,
316 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
317 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
318};
319
320static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
321 unsigned int irq,
322 irq_hw_number_t hwirq)
323{
324 struct mv88e6xxx_chip *chip = d->host_data;
325
326 irq_set_chip_data(irq, d->host_data);
327 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
328 irq_set_noprobe(irq);
329
330 return 0;
331}
332
333static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
334 .map = mv88e6xxx_g1_irq_domain_map,
335 .xlate = irq_domain_xlate_twocell,
336};
337
338static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
339{
340 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100341 u16 mask;
342
Vivien Didelotd77f4322017-06-15 12:14:03 -0400343 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100344 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400345 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100346
347 free_irq(chip->irq, chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200348
Andreas Färber5edef2f2016-11-27 23:26:28 +0100349 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100350 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200351 irq_dispose_mapping(virq);
352 }
353
Andrew Lunna3db3d32016-11-20 20:14:14 +0100354 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200355}
356
357static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
358{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100359 int err, irq, virq;
360 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200361
362 chip->g1_irq.nirqs = chip->info->g1_irqs;
363 chip->g1_irq.domain = irq_domain_add_simple(
364 NULL, chip->g1_irq.nirqs, 0,
365 &mv88e6xxx_g1_irq_domain_ops, chip);
366 if (!chip->g1_irq.domain)
367 return -ENOMEM;
368
369 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
370 irq_create_mapping(chip->g1_irq.domain, irq);
371
372 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
373 chip->g1_irq.masked = ~0;
374
Vivien Didelotd77f4322017-06-15 12:14:03 -0400375 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200376 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100377 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200378
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100379 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200380
Vivien Didelotd77f4322017-06-15 12:14:03 -0400381 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200382 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100383 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200384
385 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400386 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200387 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100388 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200389
390 err = request_threaded_irq(chip->irq, NULL,
391 mv88e6xxx_g1_irq_thread_fn,
392 IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
393 dev_name(chip->dev), chip);
394 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100395 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200396
397 return 0;
398
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100399out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100400 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400401 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100402
403out_mapping:
404 for (irq = 0; irq < 16; irq++) {
405 virq = irq_find_mapping(chip->g1_irq.domain, irq);
406 irq_dispose_mapping(virq);
407 }
408
409 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200410
411 return err;
412}
413
Vivien Didelotec561272016-09-02 14:45:33 -0400414int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400415{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200416 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400417
Andrew Lunn6441e6692016-08-19 00:01:55 +0200418 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400419 u16 val;
420 int err;
421
422 err = mv88e6xxx_read(chip, addr, reg, &val);
423 if (err)
424 return err;
425
426 if (!(val & mask))
427 return 0;
428
429 usleep_range(1000, 2000);
430 }
431
Andrew Lunn30853552016-08-19 00:01:57 +0200432 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400433 return -ETIMEDOUT;
434}
435
Vivien Didelotf22ab642016-07-18 20:45:31 -0400436/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400437int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400438{
439 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200440 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400441
442 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200443 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
444 if (err)
445 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400446
447 /* Set the Update bit to trigger a write operation */
448 val = BIT(15) | update;
449
450 return mv88e6xxx_write(chip, addr, reg, val);
451}
452
Vivien Didelotd78343d2016-11-04 03:23:36 +0100453static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
454 int link, int speed, int duplex,
455 phy_interface_t mode)
456{
457 int err;
458
459 if (!chip->info->ops->port_set_link)
460 return 0;
461
462 /* Port's MAC control must not be changed unless the link is down */
463 err = chip->info->ops->port_set_link(chip, port, 0);
464 if (err)
465 return err;
466
467 if (chip->info->ops->port_set_speed) {
468 err = chip->info->ops->port_set_speed(chip, port, speed);
469 if (err && err != -EOPNOTSUPP)
470 goto restore_link;
471 }
472
473 if (chip->info->ops->port_set_duplex) {
474 err = chip->info->ops->port_set_duplex(chip, port, duplex);
475 if (err && err != -EOPNOTSUPP)
476 goto restore_link;
477 }
478
479 if (chip->info->ops->port_set_rgmii_delay) {
480 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
481 if (err && err != -EOPNOTSUPP)
482 goto restore_link;
483 }
484
Andrew Lunnf39908d2017-02-04 20:02:50 +0100485 if (chip->info->ops->port_set_cmode) {
486 err = chip->info->ops->port_set_cmode(chip, port, mode);
487 if (err && err != -EOPNOTSUPP)
488 goto restore_link;
489 }
490
Vivien Didelotd78343d2016-11-04 03:23:36 +0100491 err = 0;
492restore_link:
493 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400494 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100495
496 return err;
497}
498
Andrew Lunndea87022015-08-31 15:56:47 +0200499/* We expect the switch to perform auto negotiation if there is a real
500 * phy. However, in the case of a fixed link phy, we force the port
501 * settings from the fixed link settings.
502 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400503static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
504 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200505{
Vivien Didelot04bed142016-08-31 18:06:13 -0400506 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200507 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200508
509 if (!phy_is_pseudo_fixed_link(phydev))
510 return;
511
Vivien Didelotfad09c72016-06-21 12:28:20 -0400512 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100513 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
514 phydev->duplex, phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400515 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100516
517 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400518 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200519}
520
Andrew Lunna605a0f2016-11-21 23:26:58 +0100521static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000522{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100523 if (!chip->info->ops->stats_snapshot)
524 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000525
Andrew Lunna605a0f2016-11-21 23:26:58 +0100526 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000527}
528
Andrew Lunne413e7e2015-04-02 04:06:38 +0200529static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100530 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
531 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
532 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
533 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
534 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
535 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
536 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
537 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
538 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
539 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
540 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
541 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
542 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
543 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
544 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
545 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
546 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
547 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
548 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
549 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
550 { "single", 4, 0x14, STATS_TYPE_BANK0, },
551 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
552 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
553 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
554 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
555 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
556 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
557 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
558 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
559 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
560 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
561 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
562 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
563 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
564 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
565 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
566 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
567 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
568 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
569 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
570 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
571 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
572 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
573 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
574 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
575 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
576 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
577 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
578 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
579 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
580 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
581 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
582 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
583 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
584 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
585 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
586 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
587 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
588 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200589};
590
Vivien Didelotfad09c72016-06-21 12:28:20 -0400591static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100592 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100593 int port, u16 bank1_select,
594 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200595{
Andrew Lunn80c46272015-06-20 18:42:30 +0200596 u32 low;
597 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100598 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200599 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200600 u64 value;
601
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100602 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100603 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200604 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
605 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200606 return UINT64_MAX;
607
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200608 low = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200609 if (s->sizeof_stat == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200610 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
611 if (err)
Andrew Lunn80c46272015-06-20 18:42:30 +0200612 return UINT64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200613 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200614 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100615 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100616 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100617 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100618 /* fall through */
619 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100620 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100621 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunn80c46272015-06-20 18:42:30 +0200622 if (s->sizeof_stat == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100623 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500624 break;
625 default:
626 return UINT64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200627 }
628 value = (((u64)high) << 16) | low;
629 return value;
630}
631
Andrew Lunndfafe442016-11-21 23:27:02 +0100632static void mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
633 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100634{
635 struct mv88e6xxx_hw_stat *stat;
636 int i, j;
637
638 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
639 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100640 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100641 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
642 ETH_GSTRING_LEN);
643 j++;
644 }
645 }
646}
647
Andrew Lunndfafe442016-11-21 23:27:02 +0100648static void mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
649 uint8_t *data)
650{
651 mv88e6xxx_stats_get_strings(chip, data,
652 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
653}
654
655static void mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
656 uint8_t *data)
657{
658 mv88e6xxx_stats_get_strings(chip, data,
659 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
660}
661
662static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
663 uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100664{
Vivien Didelot04bed142016-08-31 18:06:13 -0400665 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunndfafe442016-11-21 23:27:02 +0100666
667 if (chip->info->ops->stats_get_strings)
668 chip->info->ops->stats_get_strings(chip, data);
669}
670
671static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
672 int types)
673{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100674 struct mv88e6xxx_hw_stat *stat;
675 int i, j;
676
677 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
678 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100679 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100680 j++;
681 }
682 return j;
683}
684
Andrew Lunndfafe442016-11-21 23:27:02 +0100685static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
686{
687 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
688 STATS_TYPE_PORT);
689}
690
691static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
692{
693 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
694 STATS_TYPE_BANK1);
695}
696
697static int mv88e6xxx_get_sset_count(struct dsa_switch *ds)
698{
699 struct mv88e6xxx_chip *chip = ds->priv;
700
701 if (chip->info->ops->stats_get_sset_count)
702 return chip->info->ops->stats_get_sset_count(chip);
703
704 return 0;
705}
706
Andrew Lunn052f9472016-11-21 23:27:03 +0100707static void mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100708 uint64_t *data, int types,
709 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100710{
711 struct mv88e6xxx_hw_stat *stat;
712 int i, j;
713
714 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
715 stat = &mv88e6xxx_hw_stats[i];
716 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +0100717 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100718 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
719 bank1_select,
720 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +0100721 mutex_unlock(&chip->reg_lock);
722
Andrew Lunn052f9472016-11-21 23:27:03 +0100723 j++;
724 }
725 }
726}
727
728static void mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
729 uint64_t *data)
730{
731 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100732 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400733 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100734}
735
736static void mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
737 uint64_t *data)
738{
739 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100740 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400741 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
742 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100743}
744
745static void mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
746 uint64_t *data)
747{
748 return mv88e6xxx_stats_get_stats(chip, port, data,
749 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400750 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
751 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100752}
753
754static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
755 uint64_t *data)
756{
757 if (chip->info->ops->stats_get_stats)
758 chip->info->ops->stats_get_stats(chip, port, data);
759}
760
Vivien Didelotf81ec902016-05-09 13:22:58 -0400761static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
762 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000763{
Vivien Didelot04bed142016-08-31 18:06:13 -0400764 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000765 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000766
Vivien Didelotfad09c72016-06-21 12:28:20 -0400767 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000768
Andrew Lunna605a0f2016-11-21 23:26:58 +0100769 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +0100770 mutex_unlock(&chip->reg_lock);
771
772 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000773 return;
Andrew Lunn052f9472016-11-21 23:27:03 +0100774
775 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000776
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000777}
Ben Hutchings98e67302011-11-25 14:36:19 +0000778
Andrew Lunnde2273872016-11-21 23:27:01 +0100779static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
780{
781 if (chip->info->ops->stats_set_histogram)
782 return chip->info->ops->stats_set_histogram(chip);
783
784 return 0;
785}
786
Vivien Didelotf81ec902016-05-09 13:22:58 -0400787static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700788{
789 return 32 * sizeof(u16);
790}
791
Vivien Didelotf81ec902016-05-09 13:22:58 -0400792static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
793 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700794{
Vivien Didelot04bed142016-08-31 18:06:13 -0400795 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200796 int err;
797 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700798 u16 *p = _p;
799 int i;
800
801 regs->version = 0;
802
803 memset(p, 0xff, 32 * sizeof(u16));
804
Vivien Didelotfad09c72016-06-21 12:28:20 -0400805 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -0400806
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700807 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700808
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200809 err = mv88e6xxx_port_read(chip, port, i, &reg);
810 if (!err)
811 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700812 }
Vivien Didelot23062512016-05-09 13:22:45 -0400813
Vivien Didelotfad09c72016-06-21 12:28:20 -0400814 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700815}
816
Vivien Didelot08f50062017-08-01 16:32:41 -0400817static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
818 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800819{
Vivien Didelot5480db62017-08-01 16:32:40 -0400820 /* Nothing to do on the port's MAC */
821 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800822}
823
Vivien Didelot08f50062017-08-01 16:32:41 -0400824static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
825 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800826{
Vivien Didelot5480db62017-08-01 16:32:40 -0400827 /* Nothing to do on the port's MAC */
828 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800829}
830
Vivien Didelote5887a22017-03-30 17:37:11 -0400831static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700832{
Vivien Didelote5887a22017-03-30 17:37:11 -0400833 struct dsa_switch *ds = NULL;
834 struct net_device *br;
835 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500836 int i;
837
Vivien Didelote5887a22017-03-30 17:37:11 -0400838 if (dev < DSA_MAX_SWITCHES)
839 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500840
Vivien Didelote5887a22017-03-30 17:37:11 -0400841 /* Prevent frames from unknown switch or port */
842 if (!ds || port >= ds->num_ports)
843 return 0;
844
845 /* Frames from DSA links and CPU ports can egress any local port */
846 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
847 return mv88e6xxx_port_mask(chip);
848
849 br = ds->ports[port].bridge_dev;
850 pvlan = 0;
851
852 /* Frames from user ports can egress any local DSA links and CPU ports,
853 * as well as any local member of their bridge group.
854 */
855 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
856 if (dsa_is_cpu_port(chip->ds, i) ||
857 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -0400858 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -0400859 pvlan |= BIT(i);
860
861 return pvlan;
862}
863
Vivien Didelot240ea3e2017-03-30 17:37:12 -0400864static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -0400865{
866 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500867
868 /* prevent frames from going back out of the port they came in on */
869 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700870
Vivien Didelot5a7921f2016-11-04 03:23:28 +0100871 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700872}
873
Vivien Didelotf81ec902016-05-09 13:22:58 -0400874static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
875 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700876{
Vivien Didelot04bed142016-08-31 18:06:13 -0400877 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -0400878 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700879
Vivien Didelotfad09c72016-06-21 12:28:20 -0400880 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -0400881 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400882 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -0400883
884 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400885 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700886}
887
Vivien Didelot9e907d72017-07-17 13:03:43 -0400888static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
889{
890 if (chip->info->ops->pot_clear)
891 return chip->info->ops->pot_clear(chip);
892
893 return 0;
894}
895
Vivien Didelot51c901a2017-07-17 13:03:41 -0400896static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
897{
898 if (chip->info->ops->mgmt_rsvd2cpu)
899 return chip->info->ops->mgmt_rsvd2cpu(chip);
900
901 return 0;
902}
903
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500904static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
905{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500906 int err;
907
Vivien Didelotdaefc942017-03-11 16:12:54 -0500908 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
909 if (err)
910 return err;
911
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500912 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
913 if (err)
914 return err;
915
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500916 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
917}
918
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400919static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
920{
921 int port;
922 int err;
923
924 if (!chip->info->ops->irl_init_all)
925 return 0;
926
927 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
928 /* Disable ingress rate limiting by resetting all per port
929 * ingress rate limit resources to their initial state.
930 */
931 err = chip->info->ops->irl_init_all(chip, port);
932 if (err)
933 return err;
934 }
935
936 return 0;
937}
938
Vivien Didelot04a69a12017-10-13 14:18:05 -0400939static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
940{
941 if (chip->info->ops->set_switch_mac) {
942 u8 addr[ETH_ALEN];
943
944 eth_random_addr(addr);
945
946 return chip->info->ops->set_switch_mac(chip, addr);
947 }
948
949 return 0;
950}
951
Vivien Didelot17a15942017-03-30 17:37:09 -0400952static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
953{
954 u16 pvlan = 0;
955
956 if (!mv88e6xxx_has_pvt(chip))
957 return -EOPNOTSUPP;
958
959 /* Skip the local source device, which uses in-chip port VLAN */
960 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -0400961 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -0400962
963 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
964}
965
Vivien Didelot81228992017-03-30 17:37:08 -0400966static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
967{
Vivien Didelot17a15942017-03-30 17:37:09 -0400968 int dev, port;
969 int err;
970
Vivien Didelot81228992017-03-30 17:37:08 -0400971 if (!mv88e6xxx_has_pvt(chip))
972 return 0;
973
974 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
975 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
976 */
Vivien Didelot17a15942017-03-30 17:37:09 -0400977 err = mv88e6xxx_g2_misc_4_bit_port(chip);
978 if (err)
979 return err;
980
981 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
982 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
983 err = mv88e6xxx_pvt_map(chip, dev, port);
984 if (err)
985 return err;
986 }
987 }
988
989 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -0400990}
991
Vivien Didelot749efcb2016-09-22 16:49:24 -0400992static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
993{
994 struct mv88e6xxx_chip *chip = ds->priv;
995 int err;
996
997 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -0500998 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400999 mutex_unlock(&chip->reg_lock);
1000
1001 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001002 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001003}
1004
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001005static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1006{
1007 if (!chip->info->max_vid)
1008 return 0;
1009
1010 return mv88e6xxx_g1_vtu_flush(chip);
1011}
1012
Vivien Didelotf1394b782017-05-01 14:05:22 -04001013static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1014 struct mv88e6xxx_vtu_entry *entry)
1015{
1016 if (!chip->info->ops->vtu_getnext)
1017 return -EOPNOTSUPP;
1018
1019 return chip->info->ops->vtu_getnext(chip, entry);
1020}
1021
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001022static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1023 struct mv88e6xxx_vtu_entry *entry)
1024{
1025 if (!chip->info->ops->vtu_loadpurge)
1026 return -EOPNOTSUPP;
1027
1028 return chip->info->ops->vtu_loadpurge(chip, entry);
1029}
1030
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001031static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001032{
1033 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001034 struct mv88e6xxx_vtu_entry vlan = {
1035 .vid = chip->info->max_vid,
1036 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001037 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001038
1039 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1040
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001041 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001042 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001043 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001044 if (err)
1045 return err;
1046
1047 set_bit(*fid, fid_bitmap);
1048 }
1049
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001050 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001051 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001052 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001053 if (err)
1054 return err;
1055
1056 if (!vlan.valid)
1057 break;
1058
1059 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001060 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001061
1062 /* The reset value 0x000 is used to indicate that multiple address
1063 * databases are not needed. Return the next positive available.
1064 */
1065 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001066 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001067 return -ENOSPC;
1068
1069 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001070 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001071}
1072
Vivien Didelot567aa592017-05-01 14:05:25 -04001073static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1074 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001075{
1076 int err;
1077
1078 if (!vid)
1079 return -EINVAL;
1080
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001081 entry->vid = vid - 1;
1082 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001083
Vivien Didelotf1394b782017-05-01 14:05:22 -04001084 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001085 if (err)
1086 return err;
1087
Vivien Didelot567aa592017-05-01 14:05:25 -04001088 if (entry->vid == vid && entry->valid)
1089 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001090
Vivien Didelot567aa592017-05-01 14:05:25 -04001091 if (new) {
1092 int i;
1093
1094 /* Initialize a fresh VLAN entry */
1095 memset(entry, 0, sizeof(*entry));
1096 entry->valid = true;
1097 entry->vid = vid;
1098
Vivien Didelot553a7682017-06-07 18:12:16 -04001099 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001100 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001101 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001102 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001103
1104 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001105 }
1106
Vivien Didelot567aa592017-05-01 14:05:25 -04001107 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1108 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001109}
1110
Vivien Didelotda9c3592016-02-12 12:09:40 -05001111static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1112 u16 vid_begin, u16 vid_end)
1113{
Vivien Didelot04bed142016-08-31 18:06:13 -04001114 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001115 struct mv88e6xxx_vtu_entry vlan = {
1116 .vid = vid_begin - 1,
1117 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001118 int i, err;
1119
Andrew Lunndb06ae412017-09-25 23:32:20 +02001120 /* DSA and CPU ports have to be members of multiple vlans */
1121 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1122 return 0;
1123
Vivien Didelotda9c3592016-02-12 12:09:40 -05001124 if (!vid_begin)
1125 return -EOPNOTSUPP;
1126
Vivien Didelotfad09c72016-06-21 12:28:20 -04001127 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001128
Vivien Didelotda9c3592016-02-12 12:09:40 -05001129 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001130 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001131 if (err)
1132 goto unlock;
1133
1134 if (!vlan.valid)
1135 break;
1136
1137 if (vlan.vid > vid_end)
1138 break;
1139
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001140 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001141 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1142 continue;
1143
Andrew Lunncd886462017-11-09 22:29:53 +01001144 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001145 continue;
1146
Vivien Didelotbd00e052017-05-01 14:05:11 -04001147 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001148 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001149 continue;
1150
Vivien Didelotc8652c82017-10-16 11:12:19 -04001151 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001152 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001153 break; /* same bridge, check next VLAN */
1154
Vivien Didelotc8652c82017-10-16 11:12:19 -04001155 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001156 continue;
1157
Andrew Lunn743fcc22017-11-09 22:29:54 +01001158 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1159 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001160 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001161 err = -EOPNOTSUPP;
1162 goto unlock;
1163 }
1164 } while (vlan.vid < vid_end);
1165
1166unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001167 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001168
1169 return err;
1170}
1171
Vivien Didelotf81ec902016-05-09 13:22:58 -04001172static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1173 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001174{
Vivien Didelot04bed142016-08-31 18:06:13 -04001175 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001176 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1177 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001178 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001179
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001180 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001181 return -EOPNOTSUPP;
1182
Vivien Didelotfad09c72016-06-21 12:28:20 -04001183 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001184 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001185 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001186
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001187 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001188}
1189
Vivien Didelot57d32312016-06-20 13:13:58 -04001190static int
1191mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001192 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001193{
Vivien Didelot04bed142016-08-31 18:06:13 -04001194 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001195 int err;
1196
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001197 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001198 return -EOPNOTSUPP;
1199
Vivien Didelotda9c3592016-02-12 12:09:40 -05001200 /* If the requested port doesn't belong to the same bridge as the VLAN
1201 * members, do not support it (yet) and fallback to software VLAN.
1202 */
1203 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1204 vlan->vid_end);
1205 if (err)
1206 return err;
1207
Vivien Didelot76e398a2015-11-01 12:33:55 -05001208 /* We don't need any dynamic resource from the kernel (yet),
1209 * so skip the prepare phase.
1210 */
1211 return 0;
1212}
1213
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001214static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1215 const unsigned char *addr, u16 vid,
1216 u8 state)
1217{
1218 struct mv88e6xxx_vtu_entry vlan;
1219 struct mv88e6xxx_atu_entry entry;
1220 int err;
1221
1222 /* Null VLAN ID corresponds to the port private database */
1223 if (vid == 0)
1224 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1225 else
1226 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1227 if (err)
1228 return err;
1229
1230 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1231 ether_addr_copy(entry.mac, addr);
1232 eth_addr_dec(entry.mac);
1233
1234 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1235 if (err)
1236 return err;
1237
1238 /* Initialize a fresh ATU entry if it isn't found */
1239 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1240 !ether_addr_equal(entry.mac, addr)) {
1241 memset(&entry, 0, sizeof(entry));
1242 ether_addr_copy(entry.mac, addr);
1243 }
1244
1245 /* Purge the ATU entry only if no port is using it anymore */
1246 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1247 entry.portvec &= ~BIT(port);
1248 if (!entry.portvec)
1249 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1250 } else {
1251 entry.portvec |= BIT(port);
1252 entry.state = state;
1253 }
1254
1255 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1256}
1257
Andrew Lunn87fa8862017-11-09 22:29:56 +01001258static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1259 u16 vid)
1260{
1261 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1262 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1263
1264 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1265}
1266
1267static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1268{
1269 int port;
1270 int err;
1271
1272 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1273 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1274 if (err)
1275 return err;
1276 }
1277
1278 return 0;
1279}
1280
Vivien Didelotfad09c72016-06-21 12:28:20 -04001281static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001282 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001283{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001284 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001285 int err;
1286
Vivien Didelot567aa592017-05-01 14:05:25 -04001287 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001288 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001289 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001290
Vivien Didelotc91498e2017-06-07 18:12:13 -04001291 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001292
Andrew Lunn87fa8862017-11-09 22:29:56 +01001293 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1294 if (err)
1295 return err;
1296
1297 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001298}
1299
Vivien Didelotf81ec902016-05-09 13:22:58 -04001300static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001301 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001302{
Vivien Didelot04bed142016-08-31 18:06:13 -04001303 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001304 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1305 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001306 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001307 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001308
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001309 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001310 return;
1311
Vivien Didelotc91498e2017-06-07 18:12:13 -04001312 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001313 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001314 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001315 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001316 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001317 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001318
Vivien Didelotfad09c72016-06-21 12:28:20 -04001319 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001320
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001321 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001322 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001323 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1324 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001325
Vivien Didelot77064f32016-11-04 03:23:30 +01001326 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001327 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1328 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001329
Vivien Didelotfad09c72016-06-21 12:28:20 -04001330 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001331}
1332
Vivien Didelotfad09c72016-06-21 12:28:20 -04001333static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001334 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001335{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001336 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001337 int i, err;
1338
Vivien Didelot567aa592017-05-01 14:05:25 -04001339 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001340 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001341 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001342
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001343 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001344 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001345 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001346
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001347 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001348
1349 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001350 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001351 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001352 if (vlan.member[i] !=
1353 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001354 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001355 break;
1356 }
1357 }
1358
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001359 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001360 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001361 return err;
1362
Vivien Didelote606ca32017-03-11 16:12:55 -05001363 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001364}
1365
Vivien Didelotf81ec902016-05-09 13:22:58 -04001366static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1367 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001368{
Vivien Didelot04bed142016-08-31 18:06:13 -04001369 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001370 u16 pvid, vid;
1371 int err = 0;
1372
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001373 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001374 return -EOPNOTSUPP;
1375
Vivien Didelotfad09c72016-06-21 12:28:20 -04001376 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001377
Vivien Didelot77064f32016-11-04 03:23:30 +01001378 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001379 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001380 goto unlock;
1381
Vivien Didelot76e398a2015-11-01 12:33:55 -05001382 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001383 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001384 if (err)
1385 goto unlock;
1386
1387 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001388 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001389 if (err)
1390 goto unlock;
1391 }
1392 }
1393
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001394unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001395 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001396
1397 return err;
1398}
1399
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001400static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1401 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001402{
Vivien Didelot04bed142016-08-31 18:06:13 -04001403 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001404 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001405
Vivien Didelotfad09c72016-06-21 12:28:20 -04001406 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001407 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1408 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001409 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001410
1411 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001412}
1413
Vivien Didelotf81ec902016-05-09 13:22:58 -04001414static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001415 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001416{
Vivien Didelot04bed142016-08-31 18:06:13 -04001417 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001418 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001419
Vivien Didelotfad09c72016-06-21 12:28:20 -04001420 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001421 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001422 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001423 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001424
Vivien Didelot83dabd12016-08-31 11:50:04 -04001425 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001426}
1427
Vivien Didelot83dabd12016-08-31 11:50:04 -04001428static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1429 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001430 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001431{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001432 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001433 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001434 int err;
1435
Vivien Didelot27c0e602017-06-15 12:14:01 -04001436 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001437 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001438
1439 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001440 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001441 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001442 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001443
Vivien Didelot27c0e602017-06-15 12:14:01 -04001444 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001445 break;
1446
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001447 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001448 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001449
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001450 if (!is_unicast_ether_addr(addr.mac))
1451 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001452
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001453 is_static = (addr.state ==
1454 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1455 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001456 if (err)
1457 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001458 } while (!is_broadcast_ether_addr(addr.mac));
1459
1460 return err;
1461}
1462
Vivien Didelot83dabd12016-08-31 11:50:04 -04001463static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001464 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001465{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001466 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001467 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001468 };
1469 u16 fid;
1470 int err;
1471
1472 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001473 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001474 if (err)
1475 return err;
1476
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001477 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001478 if (err)
1479 return err;
1480
1481 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001482 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001483 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001484 if (err)
1485 return err;
1486
1487 if (!vlan.valid)
1488 break;
1489
1490 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001491 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001492 if (err)
1493 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001494 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001495
1496 return err;
1497}
1498
Vivien Didelotf81ec902016-05-09 13:22:58 -04001499static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001500 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001501{
Vivien Didelot04bed142016-08-31 18:06:13 -04001502 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001503 int err;
1504
Vivien Didelotfad09c72016-06-21 12:28:20 -04001505 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001506 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001507 mutex_unlock(&chip->reg_lock);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001508
1509 return err;
1510}
1511
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001512static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1513 struct net_device *br)
1514{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001515 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001516 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001517 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001518 int err;
1519
1520 /* Remap the Port VLAN of each local bridge group member */
1521 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1522 if (chip->ds->ports[port].bridge_dev == br) {
1523 err = mv88e6xxx_port_vlan_map(chip, port);
1524 if (err)
1525 return err;
1526 }
1527 }
1528
Vivien Didelote96a6e02017-03-30 17:37:13 -04001529 if (!mv88e6xxx_has_pvt(chip))
1530 return 0;
1531
1532 /* Remap the Port VLAN of each cross-chip bridge group member */
1533 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1534 ds = chip->ds->dst->ds[dev];
1535 if (!ds)
1536 break;
1537
1538 for (port = 0; port < ds->num_ports; ++port) {
1539 if (ds->ports[port].bridge_dev == br) {
1540 err = mv88e6xxx_pvt_map(chip, dev, port);
1541 if (err)
1542 return err;
1543 }
1544 }
1545 }
1546
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001547 return 0;
1548}
1549
Vivien Didelotf81ec902016-05-09 13:22:58 -04001550static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001551 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001552{
Vivien Didelot04bed142016-08-31 18:06:13 -04001553 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001554 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001555
Vivien Didelotfad09c72016-06-21 12:28:20 -04001556 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001557 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001558 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001559
Vivien Didelot466dfa02016-02-26 13:16:05 -05001560 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001561}
1562
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001563static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1564 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001565{
Vivien Didelot04bed142016-08-31 18:06:13 -04001566 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001567
Vivien Didelotfad09c72016-06-21 12:28:20 -04001568 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001569 if (mv88e6xxx_bridge_map(chip, br) ||
1570 mv88e6xxx_port_vlan_map(chip, port))
1571 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001572 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001573}
1574
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001575static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1576 int port, struct net_device *br)
1577{
1578 struct mv88e6xxx_chip *chip = ds->priv;
1579 int err;
1580
1581 if (!mv88e6xxx_has_pvt(chip))
1582 return 0;
1583
1584 mutex_lock(&chip->reg_lock);
1585 err = mv88e6xxx_pvt_map(chip, dev, port);
1586 mutex_unlock(&chip->reg_lock);
1587
1588 return err;
1589}
1590
1591static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1592 int port, struct net_device *br)
1593{
1594 struct mv88e6xxx_chip *chip = ds->priv;
1595
1596 if (!mv88e6xxx_has_pvt(chip))
1597 return;
1598
1599 mutex_lock(&chip->reg_lock);
1600 if (mv88e6xxx_pvt_map(chip, dev, port))
1601 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1602 mutex_unlock(&chip->reg_lock);
1603}
1604
Vivien Didelot17e708b2016-12-05 17:30:27 -05001605static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1606{
1607 if (chip->info->ops->reset)
1608 return chip->info->ops->reset(chip);
1609
1610 return 0;
1611}
1612
Vivien Didelot309eca62016-12-05 17:30:26 -05001613static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1614{
1615 struct gpio_desc *gpiod = chip->reset;
1616
1617 /* If there is a GPIO connected to the reset pin, toggle it */
1618 if (gpiod) {
1619 gpiod_set_value_cansleep(gpiod, 1);
1620 usleep_range(10000, 20000);
1621 gpiod_set_value_cansleep(gpiod, 0);
1622 usleep_range(10000, 20000);
1623 }
1624}
1625
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001626static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1627{
1628 int i, err;
1629
1630 /* Set all ports to the Disabled state */
1631 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001632 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001633 if (err)
1634 return err;
1635 }
1636
1637 /* Wait for transmit queues to drain,
1638 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1639 */
1640 usleep_range(2000, 4000);
1641
1642 return 0;
1643}
1644
Vivien Didelotfad09c72016-06-21 12:28:20 -04001645static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001646{
Vivien Didelota935c052016-09-29 12:21:53 -04001647 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001648
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001649 err = mv88e6xxx_disable_ports(chip);
1650 if (err)
1651 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001652
Vivien Didelot309eca62016-12-05 17:30:26 -05001653 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001654
Vivien Didelot17e708b2016-12-05 17:30:27 -05001655 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001656}
1657
Vivien Didelot43145572017-03-11 16:12:59 -05001658static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001659 enum mv88e6xxx_frame_mode frame,
1660 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001661{
1662 int err;
1663
Vivien Didelot43145572017-03-11 16:12:59 -05001664 if (!chip->info->ops->port_set_frame_mode)
1665 return -EOPNOTSUPP;
1666
1667 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001668 if (err)
1669 return err;
1670
Vivien Didelot43145572017-03-11 16:12:59 -05001671 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1672 if (err)
1673 return err;
1674
1675 if (chip->info->ops->port_set_ether_type)
1676 return chip->info->ops->port_set_ether_type(chip, port, etype);
1677
1678 return 0;
1679}
1680
1681static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1682{
1683 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001684 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001685 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001686}
1687
1688static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1689{
1690 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001691 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001692 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001693}
1694
1695static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1696{
1697 return mv88e6xxx_set_port_mode(chip, port,
1698 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001699 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1700 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001701}
1702
1703static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1704{
1705 if (dsa_is_dsa_port(chip->ds, port))
1706 return mv88e6xxx_set_port_mode_dsa(chip, port);
1707
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001708 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001709 return mv88e6xxx_set_port_mode_normal(chip, port);
1710
1711 /* Setup CPU port mode depending on its supported tag format */
1712 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1713 return mv88e6xxx_set_port_mode_dsa(chip, port);
1714
1715 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1716 return mv88e6xxx_set_port_mode_edsa(chip, port);
1717
1718 return -EINVAL;
1719}
1720
Vivien Didelotea698f42017-03-11 16:12:50 -05001721static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1722{
1723 bool message = dsa_is_dsa_port(chip->ds, port);
1724
1725 return mv88e6xxx_port_set_message_port(chip, port, message);
1726}
1727
Vivien Didelot601aeed2017-03-11 16:13:00 -05001728static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1729{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001730 struct dsa_switch *ds = chip->ds;
1731 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05001732
1733 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001734 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05001735 if (chip->info->ops->port_set_egress_floods)
1736 return chip->info->ops->port_set_egress_floods(chip, port,
1737 flood, flood);
1738
1739 return 0;
1740}
1741
Andrew Lunn6d917822017-05-26 01:03:21 +02001742static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1743 bool on)
1744{
Vivien Didelot523a8902017-05-26 18:02:42 -04001745 if (chip->info->ops->serdes_power)
1746 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001747
Vivien Didelot523a8902017-05-26 18:02:42 -04001748 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001749}
1750
Vivien Didelotfa371c82017-12-05 15:34:10 -05001751static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
1752{
1753 struct dsa_switch *ds = chip->ds;
1754 int upstream_port;
1755 int err;
1756
Vivien Didelot07073c72017-12-05 15:34:13 -05001757 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05001758 if (chip->info->ops->port_set_upstream_port) {
1759 err = chip->info->ops->port_set_upstream_port(chip, port,
1760 upstream_port);
1761 if (err)
1762 return err;
1763 }
1764
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05001765 if (port == upstream_port) {
1766 if (chip->info->ops->set_cpu_port) {
1767 err = chip->info->ops->set_cpu_port(chip,
1768 upstream_port);
1769 if (err)
1770 return err;
1771 }
1772
1773 if (chip->info->ops->set_egress_port) {
1774 err = chip->info->ops->set_egress_port(chip,
1775 upstream_port);
1776 if (err)
1777 return err;
1778 }
1779 }
1780
Vivien Didelotfa371c82017-12-05 15:34:10 -05001781 return 0;
1782}
1783
Vivien Didelotfad09c72016-06-21 12:28:20 -04001784static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001785{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001786 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001787 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001788 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001789
Vivien Didelotd78343d2016-11-04 03:23:36 +01001790 /* MAC Forcing register: don't force link, speed, duplex or flow control
1791 * state to any particular values on physical ports, but force the CPU
1792 * port and all DSA ports to their maximum bandwidth and full duplex.
1793 */
1794 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1795 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1796 SPEED_MAX, DUPLEX_FULL,
1797 PHY_INTERFACE_MODE_NA);
1798 else
1799 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1800 SPEED_UNFORCED, DUPLEX_UNFORCED,
1801 PHY_INTERFACE_MODE_NA);
1802 if (err)
1803 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001804
1805 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1806 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1807 * tunneling, determine priority by looking at 802.1p and IP
1808 * priority fields (IP prio has precedence), and set STP state
1809 * to Forwarding.
1810 *
1811 * If this is the CPU link, use DSA or EDSA tagging depending
1812 * on which tagging mode was configured.
1813 *
1814 * If this is a link to another switch, use DSA tagging mode.
1815 *
1816 * If this is the upstream port for this switch, enable
1817 * forwarding of unknown unicasts and multicasts.
1818 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001819 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1820 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1821 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1822 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001823 if (err)
1824 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001825
Vivien Didelot601aeed2017-03-11 16:13:00 -05001826 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001827 if (err)
1828 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001829
Vivien Didelot601aeed2017-03-11 16:13:00 -05001830 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001831 if (err)
1832 return err;
1833
Andrew Lunn04aca992017-05-26 01:03:24 +02001834 /* Enable the SERDES interface for DSA and CPU ports. Normal
1835 * ports SERDES are enabled when the port is enabled, thus
1836 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001837 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001838 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1839 err = mv88e6xxx_serdes_power(chip, port, true);
1840 if (err)
1841 return err;
1842 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001843
Vivien Didelot8efdda42015-08-13 12:52:23 -04001844 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001845 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001846 * untagged frames on this port, do a destination address lookup on all
1847 * received packets as usual, disable ARP mirroring and don't send a
1848 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001849 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001850 err = mv88e6xxx_port_set_map_da(chip, port);
1851 if (err)
1852 return err;
1853
Vivien Didelotfa371c82017-12-05 15:34:10 -05001854 err = mv88e6xxx_setup_upstream_port(chip, port);
1855 if (err)
1856 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001857
Andrew Lunna23b2962017-02-04 20:15:28 +01001858 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001859 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001860 if (err)
1861 return err;
1862
Vivien Didelotcd782652017-06-08 18:34:13 -04001863 if (chip->info->ops->port_set_jumbo_size) {
1864 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001865 if (err)
1866 return err;
1867 }
1868
Andrew Lunn54d792f2015-05-06 01:09:47 +02001869 /* Port Association Vector: when learning source addresses
1870 * of packets, add the address to the address database using
1871 * a port bitmap that has only the bit for this port set and
1872 * the other bits clear.
1873 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001874 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001875 /* Disable learning for CPU port */
1876 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001877 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001878
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001879 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1880 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001881 if (err)
1882 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001883
1884 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001885 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1886 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001887 if (err)
1888 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001889
Vivien Didelot08984322017-06-08 18:34:12 -04001890 if (chip->info->ops->port_pause_limit) {
1891 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001892 if (err)
1893 return err;
1894 }
1895
Vivien Didelotc8c94892017-03-11 16:13:01 -05001896 if (chip->info->ops->port_disable_learn_limit) {
1897 err = chip->info->ops->port_disable_learn_limit(chip, port);
1898 if (err)
1899 return err;
1900 }
1901
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001902 if (chip->info->ops->port_disable_pri_override) {
1903 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001904 if (err)
1905 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001906 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001907
Andrew Lunnef0a7312016-12-03 04:35:16 +01001908 if (chip->info->ops->port_tag_remap) {
1909 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001910 if (err)
1911 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001912 }
1913
Andrew Lunnef70b112016-12-03 04:45:18 +01001914 if (chip->info->ops->port_egress_rate_limiting) {
1915 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001916 if (err)
1917 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001918 }
1919
Vivien Didelotea698f42017-03-11 16:12:50 -05001920 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001921 if (err)
1922 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001923
Vivien Didelot207afda2016-04-14 14:42:09 -04001924 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001925 * database, and allow bidirectional communication between the
1926 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001927 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001928 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001929 if (err)
1930 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001931
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001932 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001933 if (err)
1934 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001935
1936 /* Default VLAN ID and priority: don't set a default VLAN
1937 * ID, and set the default packet priority to zero.
1938 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04001939 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02001940}
1941
Andrew Lunn04aca992017-05-26 01:03:24 +02001942static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
1943 struct phy_device *phydev)
1944{
1945 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04001946 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02001947
1948 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001949 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02001950 mutex_unlock(&chip->reg_lock);
1951
1952 return err;
1953}
1954
1955static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
1956 struct phy_device *phydev)
1957{
1958 struct mv88e6xxx_chip *chip = ds->priv;
1959
1960 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001961 if (mv88e6xxx_serdes_power(chip, port, false))
1962 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02001963 mutex_unlock(&chip->reg_lock);
1964}
1965
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001966static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
1967 unsigned int ageing_time)
1968{
Vivien Didelot04bed142016-08-31 18:06:13 -04001969 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001970 int err;
1971
1972 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05001973 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001974 mutex_unlock(&chip->reg_lock);
1975
1976 return err;
1977}
1978
Vivien Didelot97299342016-07-18 20:45:30 -04001979static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04001980{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001981 struct dsa_switch *ds = chip->ds;
Vivien Didelot08a01262016-05-09 13:22:50 -04001982 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04001983
Vivien Didelot50484ff2016-05-09 13:22:54 -04001984 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04001985 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
1986 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04001987 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04001988 if (err)
1989 return err;
1990
Vivien Didelot08a01262016-05-09 13:22:50 -04001991 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04001992 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 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_1, 0x0000);
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_2, 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_3, 0x5555);
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_4, 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_5, 0xaaaa);
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_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002011 if (err)
2012 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002013 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002014 if (err)
2015 return err;
2016
2017 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002018 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002019 if (err)
2020 return err;
2021
Andrew Lunnde2273872016-11-21 23:27:01 +01002022 /* Initialize the statistics unit */
2023 err = mv88e6xxx_stats_set_histogram(chip);
2024 if (err)
2025 return err;
2026
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002027 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002028}
2029
Vivien Didelotf81ec902016-05-09 13:22:58 -04002030static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002031{
Vivien Didelot04bed142016-08-31 18:06:13 -04002032 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002033 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002034 int i;
2035
Vivien Didelotfad09c72016-06-21 12:28:20 -04002036 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002037 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002038
Vivien Didelotfad09c72016-06-21 12:28:20 -04002039 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002040
Vivien Didelot97299342016-07-18 20:45:30 -04002041 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002042 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002043 if (dsa_is_unused_port(ds, i))
2044 continue;
2045
Vivien Didelot97299342016-07-18 20:45:30 -04002046 err = mv88e6xxx_setup_port(chip, i);
2047 if (err)
2048 goto unlock;
2049 }
2050
2051 /* Setup Switch Global 1 Registers */
2052 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002053 if (err)
2054 goto unlock;
2055
Vivien Didelot97299342016-07-18 20:45:30 -04002056 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002057 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002058 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002059 if (err)
2060 goto unlock;
2061 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002062
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002063 err = mv88e6xxx_irl_setup(chip);
2064 if (err)
2065 goto unlock;
2066
Vivien Didelot04a69a12017-10-13 14:18:05 -04002067 err = mv88e6xxx_mac_setup(chip);
2068 if (err)
2069 goto unlock;
2070
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002071 err = mv88e6xxx_phy_setup(chip);
2072 if (err)
2073 goto unlock;
2074
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002075 err = mv88e6xxx_vtu_setup(chip);
2076 if (err)
2077 goto unlock;
2078
Vivien Didelot81228992017-03-30 17:37:08 -04002079 err = mv88e6xxx_pvt_setup(chip);
2080 if (err)
2081 goto unlock;
2082
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002083 err = mv88e6xxx_atu_setup(chip);
2084 if (err)
2085 goto unlock;
2086
Andrew Lunn87fa8862017-11-09 22:29:56 +01002087 err = mv88e6xxx_broadcast_setup(chip, 0);
2088 if (err)
2089 goto unlock;
2090
Vivien Didelot9e907d72017-07-17 13:03:43 -04002091 err = mv88e6xxx_pot_setup(chip);
2092 if (err)
2093 goto unlock;
2094
Vivien Didelot51c901a2017-07-17 13:03:41 -04002095 err = mv88e6xxx_rsvd2cpu_setup(chip);
2096 if (err)
2097 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002098
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002099 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002100 if (chip->info->ptp_support) {
2101 err = mv88e6xxx_ptp_setup(chip);
2102 if (err)
2103 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002104
2105 err = mv88e6xxx_hwtstamp_setup(chip);
2106 if (err)
2107 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002108 }
2109
Vivien Didelot6b17e862015-08-13 12:52:18 -04002110unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002111 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002112
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002113 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002114}
2115
Vivien Didelote57e5e72016-08-15 17:19:00 -04002116static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002117{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002118 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2119 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002120 u16 val;
2121 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002122
Andrew Lunnee26a222017-01-24 14:53:48 +01002123 if (!chip->info->ops->phy_read)
2124 return -EOPNOTSUPP;
2125
Vivien Didelotfad09c72016-06-21 12:28:20 -04002126 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002127 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002128 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002129
Andrew Lunnda9f3302017-02-01 03:40:05 +01002130 if (reg == MII_PHYSID2) {
2131 /* Some internal PHYS don't have a model number. Use
2132 * the mv88e6390 family model number instead.
2133 */
2134 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002135 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002136 }
2137
Vivien Didelote57e5e72016-08-15 17:19:00 -04002138 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002139}
2140
Vivien Didelote57e5e72016-08-15 17:19:00 -04002141static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002142{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002143 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2144 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002145 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002146
Andrew Lunnee26a222017-01-24 14:53:48 +01002147 if (!chip->info->ops->phy_write)
2148 return -EOPNOTSUPP;
2149
Vivien Didelotfad09c72016-06-21 12:28:20 -04002150 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002151 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002152 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002153
2154 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002155}
2156
Vivien Didelotfad09c72016-06-21 12:28:20 -04002157static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002158 struct device_node *np,
2159 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002160{
2161 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002162 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002163 struct mii_bus *bus;
2164 int err;
2165
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002166 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002167 if (!bus)
2168 return -ENOMEM;
2169
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002170 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002171 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002172 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002173 INIT_LIST_HEAD(&mdio_bus->list);
2174 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002175
Andrew Lunnb516d452016-06-04 21:17:06 +02002176 if (np) {
2177 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002178 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002179 } else {
2180 bus->name = "mv88e6xxx SMI";
2181 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2182 }
2183
2184 bus->read = mv88e6xxx_mdio_read;
2185 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002186 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002187
Andrew Lunna3c53be52017-01-24 14:53:50 +01002188 if (np)
2189 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002190 else
2191 err = mdiobus_register(bus);
2192 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002193 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002194 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002195 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002196
2197 if (external)
2198 list_add_tail(&mdio_bus->list, &chip->mdios);
2199 else
2200 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002201
2202 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002203}
2204
Andrew Lunna3c53be52017-01-24 14:53:50 +01002205static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2206 { .compatible = "marvell,mv88e6xxx-mdio-external",
2207 .data = (void *)true },
2208 { },
2209};
2210
Andrew Lunn3126aee2017-12-07 01:05:57 +01002211static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2212
2213{
2214 struct mv88e6xxx_mdio_bus *mdio_bus;
2215 struct mii_bus *bus;
2216
2217 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2218 bus = mdio_bus->bus;
2219
2220 mdiobus_unregister(bus);
2221 }
2222}
2223
Andrew Lunna3c53be52017-01-24 14:53:50 +01002224static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2225 struct device_node *np)
2226{
2227 const struct of_device_id *match;
2228 struct device_node *child;
2229 int err;
2230
2231 /* Always register one mdio bus for the internal/default mdio
2232 * bus. This maybe represented in the device tree, but is
2233 * optional.
2234 */
2235 child = of_get_child_by_name(np, "mdio");
2236 err = mv88e6xxx_mdio_register(chip, child, false);
2237 if (err)
2238 return err;
2239
2240 /* Walk the device tree, and see if there are any other nodes
2241 * which say they are compatible with the external mdio
2242 * bus.
2243 */
2244 for_each_available_child_of_node(np, child) {
2245 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2246 if (match) {
2247 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002248 if (err) {
2249 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002250 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002251 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002252 }
2253 }
2254
2255 return 0;
2256}
2257
Vivien Didelot855b1932016-07-20 18:18:35 -04002258static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2259{
Vivien Didelot04bed142016-08-31 18:06:13 -04002260 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002261
2262 return chip->eeprom_len;
2263}
2264
Vivien Didelot855b1932016-07-20 18:18:35 -04002265static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2266 struct ethtool_eeprom *eeprom, u8 *data)
2267{
Vivien Didelot04bed142016-08-31 18:06:13 -04002268 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002269 int err;
2270
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002271 if (!chip->info->ops->get_eeprom)
2272 return -EOPNOTSUPP;
2273
Vivien Didelot855b1932016-07-20 18:18:35 -04002274 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002275 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002276 mutex_unlock(&chip->reg_lock);
2277
2278 if (err)
2279 return err;
2280
2281 eeprom->magic = 0xc3ec4951;
2282
2283 return 0;
2284}
2285
Vivien Didelot855b1932016-07-20 18:18:35 -04002286static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2287 struct ethtool_eeprom *eeprom, u8 *data)
2288{
Vivien Didelot04bed142016-08-31 18:06:13 -04002289 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002290 int err;
2291
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002292 if (!chip->info->ops->set_eeprom)
2293 return -EOPNOTSUPP;
2294
Vivien Didelot855b1932016-07-20 18:18:35 -04002295 if (eeprom->magic != 0xc3ec4951)
2296 return -EINVAL;
2297
2298 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002299 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002300 mutex_unlock(&chip->reg_lock);
2301
2302 return err;
2303}
2304
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002305static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002306 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002307 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002308 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002309 .phy_read = mv88e6185_phy_ppu_read,
2310 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002311 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002312 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002313 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002314 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002315 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002316 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002317 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002318 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002319 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002320 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002321 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002322 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002323 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002324 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2325 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002326 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002327 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2328 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002329 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002330 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002331 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002332 .ppu_enable = mv88e6185_g1_ppu_enable,
2333 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002334 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002335 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002336 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002337};
2338
2339static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002340 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002341 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002342 .phy_read = mv88e6185_phy_ppu_read,
2343 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002344 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002345 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002346 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002347 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002348 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002349 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002350 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002351 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002352 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2353 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002354 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002355 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002356 .ppu_enable = mv88e6185_g1_ppu_enable,
2357 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002358 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002359 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002360 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002361};
2362
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002363static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002364 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002365 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002366 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2367 .phy_read = mv88e6xxx_g2_smi_phy_read,
2368 .phy_write = mv88e6xxx_g2_smi_phy_write,
2369 .port_set_link = mv88e6xxx_port_set_link,
2370 .port_set_duplex = mv88e6xxx_port_set_duplex,
2371 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002372 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002373 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002374 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002375 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002376 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002377 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002378 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002379 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002380 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002381 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002382 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002383 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2384 .stats_get_strings = mv88e6095_stats_get_strings,
2385 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002386 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2387 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002388 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002389 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002390 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002391 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002392 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002393 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002394};
2395
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002396static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002397 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002398 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002399 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002400 .phy_read = mv88e6xxx_g2_smi_phy_read,
2401 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002402 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002403 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002404 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002405 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002406 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002407 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002408 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002409 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002410 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002411 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2412 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002413 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002414 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2415 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002416 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002417 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002418 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002419 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002420 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002421 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002422};
2423
2424static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002425 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002426 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002427 .phy_read = mv88e6185_phy_ppu_read,
2428 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002429 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002430 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002431 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002432 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002433 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002434 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002435 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002436 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002437 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002438 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002439 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002440 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002441 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002442 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2443 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002444 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002445 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2446 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002447 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002448 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002449 .ppu_enable = mv88e6185_g1_ppu_enable,
2450 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002451 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002452 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002453 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002454};
2455
Vivien Didelot990e27b2017-03-28 13:50:32 -04002456static const struct mv88e6xxx_ops mv88e6141_ops = {
2457 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002458 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002459 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2460 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2461 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2462 .phy_read = mv88e6xxx_g2_smi_phy_read,
2463 .phy_write = mv88e6xxx_g2_smi_phy_write,
2464 .port_set_link = mv88e6xxx_port_set_link,
2465 .port_set_duplex = mv88e6xxx_port_set_duplex,
2466 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2467 .port_set_speed = mv88e6390_port_set_speed,
2468 .port_tag_remap = mv88e6095_port_tag_remap,
2469 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2470 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2471 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002472 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002473 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002474 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002475 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2476 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2477 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002478 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002479 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2480 .stats_get_strings = mv88e6320_stats_get_strings,
2481 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002482 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2483 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002484 .watchdog_ops = &mv88e6390_watchdog_ops,
2485 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002486 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002487 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002488 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002489 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002490 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002491};
2492
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002493static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002494 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002495 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002496 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002497 .phy_read = mv88e6xxx_g2_smi_phy_read,
2498 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002499 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002500 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002501 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002502 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002503 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002504 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002505 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002506 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002507 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002508 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002509 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002510 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002511 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002512 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002513 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2514 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002515 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002516 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2517 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002518 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002519 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002520 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002521 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002522 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002523 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002524};
2525
2526static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002527 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002528 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002529 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002530 .phy_read = mv88e6165_phy_read,
2531 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002532 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002533 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002534 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002535 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002536 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002537 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002538 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002539 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2540 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002541 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002542 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2543 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002544 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002545 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002546 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002547 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002548 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002549 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002550};
2551
2552static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002553 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002554 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002555 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002556 .phy_read = mv88e6xxx_g2_smi_phy_read,
2557 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002558 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002559 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002560 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002561 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002562 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002563 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002564 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002565 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002566 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002567 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002568 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002569 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002570 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002571 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002572 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002573 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2574 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002575 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002576 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2577 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002578 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002579 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002580 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002581 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002582 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002583 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002584};
2585
2586static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002587 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002588 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002589 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2590 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002591 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002592 .phy_read = mv88e6xxx_g2_smi_phy_read,
2593 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002594 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002595 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002596 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002597 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002598 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002599 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002600 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002601 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002602 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002603 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002604 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002605 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002606 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002607 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002608 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002609 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2610 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002611 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002612 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2613 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002614 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002615 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002616 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002617 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002618 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002619 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002620 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002621 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002622};
2623
2624static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002625 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002626 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002627 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002628 .phy_read = mv88e6xxx_g2_smi_phy_read,
2629 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002630 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002631 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002632 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002633 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002634 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002635 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002636 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002637 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002638 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002639 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002640 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002641 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002642 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002643 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002644 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002645 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2646 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002647 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002648 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2649 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002650 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002651 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002652 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002653 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002654 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002655 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002656};
2657
2658static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002659 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002660 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002661 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2662 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002663 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002664 .phy_read = mv88e6xxx_g2_smi_phy_read,
2665 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002666 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002667 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002668 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002669 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002670 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002671 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002672 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002673 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002674 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002675 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002676 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002677 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002678 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002679 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002680 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002681 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2682 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002683 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002684 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2685 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002686 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002687 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002688 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002689 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002690 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002691 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002692 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002693 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002694};
2695
2696static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002697 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002698 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002699 .phy_read = mv88e6185_phy_ppu_read,
2700 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002701 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002702 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002703 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002704 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002705 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002706 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002707 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002708 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002709 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002710 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2711 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002712 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002713 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2714 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002715 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002716 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002717 .ppu_enable = mv88e6185_g1_ppu_enable,
2718 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002719 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002720 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002721 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002722};
2723
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002724static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002725 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002726 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002727 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2728 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002729 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2730 .phy_read = mv88e6xxx_g2_smi_phy_read,
2731 .phy_write = mv88e6xxx_g2_smi_phy_write,
2732 .port_set_link = mv88e6xxx_port_set_link,
2733 .port_set_duplex = mv88e6xxx_port_set_duplex,
2734 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2735 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002736 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002737 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002738 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002739 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002740 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002741 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002742 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002743 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002744 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002745 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2746 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002747 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002748 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2749 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002750 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002751 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002752 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002753 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002754 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2755 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002756 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002757 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002758};
2759
2760static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002761 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002762 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002763 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2764 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002765 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2766 .phy_read = mv88e6xxx_g2_smi_phy_read,
2767 .phy_write = mv88e6xxx_g2_smi_phy_write,
2768 .port_set_link = mv88e6xxx_port_set_link,
2769 .port_set_duplex = mv88e6xxx_port_set_duplex,
2770 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2771 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002772 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002773 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002774 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002775 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002776 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002777 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002778 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002779 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002780 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002781 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2782 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002783 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002784 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2785 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002786 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002787 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002788 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002789 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002790 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2791 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002792 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002793 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002794};
2795
2796static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002797 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002798 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002799 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2800 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002801 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2802 .phy_read = mv88e6xxx_g2_smi_phy_read,
2803 .phy_write = mv88e6xxx_g2_smi_phy_write,
2804 .port_set_link = mv88e6xxx_port_set_link,
2805 .port_set_duplex = mv88e6xxx_port_set_duplex,
2806 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2807 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002808 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002809 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002810 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002811 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002812 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002813 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002814 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002815 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002816 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002817 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2818 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002819 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002820 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2821 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002822 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002823 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002824 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002825 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002826 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2827 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002828 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002829};
2830
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002831static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002832 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002833 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002834 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2835 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002836 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002837 .phy_read = mv88e6xxx_g2_smi_phy_read,
2838 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002839 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002840 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002841 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002842 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002843 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002844 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002845 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002846 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002847 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002848 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002849 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002850 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002851 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002852 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002853 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002854 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2855 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002856 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002857 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2858 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002859 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002860 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002861 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002862 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002863 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002864 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002865 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002866 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002867 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002868};
2869
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002870static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002871 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002872 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002873 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2874 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002875 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2876 .phy_read = mv88e6xxx_g2_smi_phy_read,
2877 .phy_write = mv88e6xxx_g2_smi_phy_write,
2878 .port_set_link = mv88e6xxx_port_set_link,
2879 .port_set_duplex = mv88e6xxx_port_set_duplex,
2880 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2881 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002882 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002883 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002884 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002885 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002886 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002887 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002888 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002889 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002890 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002891 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002892 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2893 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002894 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002895 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2896 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002897 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002898 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002899 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002900 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002901 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2902 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002903 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002904 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002905 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002906};
2907
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002908static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002909 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002910 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002911 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2912 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002913 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002914 .phy_read = mv88e6xxx_g2_smi_phy_read,
2915 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002916 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002917 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002918 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002919 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002920 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002921 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002922 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002923 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002924 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002925 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002926 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002927 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002928 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002929 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002930 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2931 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002932 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002933 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2934 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002935 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002936 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002937 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002938 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002939 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002940 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002941 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002942};
2943
2944static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04002945 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002946 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002947 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2948 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002949 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002950 .phy_read = mv88e6xxx_g2_smi_phy_read,
2951 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002952 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002953 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002954 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002955 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002956 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002957 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002958 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002959 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002960 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002961 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002962 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002963 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002964 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002965 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002966 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2967 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002968 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002969 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2970 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002971 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002972 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002973 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002974 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002975 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002976};
2977
Vivien Didelot16e329a2017-03-28 13:50:33 -04002978static const struct mv88e6xxx_ops mv88e6341_ops = {
2979 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002980 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002981 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2982 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2983 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2984 .phy_read = mv88e6xxx_g2_smi_phy_read,
2985 .phy_write = mv88e6xxx_g2_smi_phy_write,
2986 .port_set_link = mv88e6xxx_port_set_link,
2987 .port_set_duplex = mv88e6xxx_port_set_duplex,
2988 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2989 .port_set_speed = mv88e6390_port_set_speed,
2990 .port_tag_remap = mv88e6095_port_tag_remap,
2991 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2992 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2993 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002994 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002995 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002996 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002997 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2998 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2999 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003000 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003001 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3002 .stats_get_strings = mv88e6320_stats_get_strings,
3003 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003004 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3005 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003006 .watchdog_ops = &mv88e6390_watchdog_ops,
3007 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003008 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003009 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003010 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003011 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003012 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003013 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003014};
3015
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003016static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003017 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003018 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003019 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003020 .phy_read = mv88e6xxx_g2_smi_phy_read,
3021 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003022 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003023 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003024 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003025 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003026 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003027 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003028 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003029 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003030 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003031 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003032 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003033 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003034 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003035 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003036 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003037 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3038 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003039 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003040 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3041 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003042 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003043 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003044 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003045 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003046 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003047 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003048};
3049
3050static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003051 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003052 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003053 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003054 .phy_read = mv88e6xxx_g2_smi_phy_read,
3055 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003056 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003057 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003058 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003059 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003060 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003061 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003062 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003063 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003064 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003065 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003066 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003067 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003068 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003069 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003070 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003071 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3072 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003073 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003074 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3075 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003076 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003077 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003078 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003079 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003080 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003081 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003082 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003083};
3084
3085static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003086 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003087 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003088 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3089 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003090 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003091 .phy_read = mv88e6xxx_g2_smi_phy_read,
3092 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003093 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003094 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003095 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003096 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003097 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003098 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003099 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003100 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003101 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003102 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003103 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003104 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003105 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003106 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003107 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003108 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3109 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003110 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003111 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3112 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003113 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003114 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003115 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003116 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003117 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003118 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003119 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003120 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003121 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003122};
3123
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003124static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003125 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003126 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003127 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3128 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003129 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3130 .phy_read = mv88e6xxx_g2_smi_phy_read,
3131 .phy_write = mv88e6xxx_g2_smi_phy_write,
3132 .port_set_link = mv88e6xxx_port_set_link,
3133 .port_set_duplex = mv88e6xxx_port_set_duplex,
3134 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3135 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003136 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003137 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003138 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003139 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003140 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003141 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003142 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003143 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003144 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003145 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003146 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003147 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003148 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3149 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003150 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003151 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3152 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003153 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003154 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003155 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003156 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003157 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3158 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003159 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003160 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003161 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003162};
3163
3164static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003165 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003166 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003167 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3168 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003169 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3170 .phy_read = mv88e6xxx_g2_smi_phy_read,
3171 .phy_write = mv88e6xxx_g2_smi_phy_write,
3172 .port_set_link = mv88e6xxx_port_set_link,
3173 .port_set_duplex = mv88e6xxx_port_set_duplex,
3174 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3175 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003176 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003177 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003178 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003179 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003180 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003181 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003182 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003183 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003184 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003185 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003186 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003187 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003188 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3189 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003190 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003191 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3192 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003193 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003194 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003195 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003196 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003197 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3198 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003199 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003200 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003201 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003202};
3203
Vivien Didelotf81ec902016-05-09 13:22:58 -04003204static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3205 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003206 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003207 .family = MV88E6XXX_FAMILY_6097,
3208 .name = "Marvell 88E6085",
3209 .num_databases = 4096,
3210 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003211 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003212 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003213 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003214 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003215 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003216 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003217 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003218 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003219 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003220 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003221 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003222 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003223 },
3224
3225 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003226 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003227 .family = MV88E6XXX_FAMILY_6095,
3228 .name = "Marvell 88E6095/88E6095F",
3229 .num_databases = 256,
3230 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003231 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003232 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003233 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003234 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003235 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003236 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003237 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003238 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003239 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003240 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003241 },
3242
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003243 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003244 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003245 .family = MV88E6XXX_FAMILY_6097,
3246 .name = "Marvell 88E6097/88E6097F",
3247 .num_databases = 4096,
3248 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003249 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003250 .port_base_addr = 0x10,
3251 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003252 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003253 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003254 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003255 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003256 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003257 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003258 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003259 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003260 .ops = &mv88e6097_ops,
3261 },
3262
Vivien Didelotf81ec902016-05-09 13:22:58 -04003263 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003264 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003265 .family = MV88E6XXX_FAMILY_6165,
3266 .name = "Marvell 88E6123",
3267 .num_databases = 4096,
3268 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003269 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003270 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003271 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003272 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003273 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003274 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003275 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003276 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003277 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003278 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003279 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003280 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003281 },
3282
3283 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003284 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003285 .family = MV88E6XXX_FAMILY_6185,
3286 .name = "Marvell 88E6131",
3287 .num_databases = 256,
3288 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003289 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003290 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003291 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003292 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003293 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003294 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003295 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003296 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003297 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003298 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003299 },
3300
Vivien Didelot990e27b2017-03-28 13:50:32 -04003301 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003302 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003303 .family = MV88E6XXX_FAMILY_6341,
3304 .name = "Marvell 88E6341",
3305 .num_databases = 4096,
3306 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003307 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003308 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003309 .port_base_addr = 0x10,
3310 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003311 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003312 .age_time_coeff = 3750,
3313 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003314 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003315 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003316 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003317 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003318 .ops = &mv88e6141_ops,
3319 },
3320
Vivien Didelotf81ec902016-05-09 13:22:58 -04003321 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003322 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003323 .family = MV88E6XXX_FAMILY_6165,
3324 .name = "Marvell 88E6161",
3325 .num_databases = 4096,
3326 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003327 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003328 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003329 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003330 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003331 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003332 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003333 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003334 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003335 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003336 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003337 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003338 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003339 },
3340
3341 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003342 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003343 .family = MV88E6XXX_FAMILY_6165,
3344 .name = "Marvell 88E6165",
3345 .num_databases = 4096,
3346 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003347 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003348 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003349 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003350 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003351 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003352 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003353 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003354 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003355 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003356 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003357 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003358 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003359 },
3360
3361 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003362 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003363 .family = MV88E6XXX_FAMILY_6351,
3364 .name = "Marvell 88E6171",
3365 .num_databases = 4096,
3366 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003367 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003368 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003369 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003370 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003371 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003372 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003373 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003374 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003375 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003376 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003377 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003378 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003379 },
3380
3381 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003382 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003383 .family = MV88E6XXX_FAMILY_6352,
3384 .name = "Marvell 88E6172",
3385 .num_databases = 4096,
3386 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003387 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003388 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003389 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003390 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003391 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003392 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003393 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003394 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003395 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003396 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003397 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003398 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003399 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003400 },
3401
3402 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003403 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003404 .family = MV88E6XXX_FAMILY_6351,
3405 .name = "Marvell 88E6175",
3406 .num_databases = 4096,
3407 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003408 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003409 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003410 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003411 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003412 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003413 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003414 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003415 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003416 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003417 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003418 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003419 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003420 },
3421
3422 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003423 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003424 .family = MV88E6XXX_FAMILY_6352,
3425 .name = "Marvell 88E6176",
3426 .num_databases = 4096,
3427 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003428 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003429 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003430 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003431 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003432 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003433 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003434 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003435 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003436 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003437 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003438 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003439 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003440 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003441 },
3442
3443 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003444 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003445 .family = MV88E6XXX_FAMILY_6185,
3446 .name = "Marvell 88E6185",
3447 .num_databases = 256,
3448 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003449 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003450 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003451 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003452 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003453 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003454 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003455 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003456 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003457 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003458 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003459 },
3460
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003461 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003462 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003463 .family = MV88E6XXX_FAMILY_6390,
3464 .name = "Marvell 88E6190",
3465 .num_databases = 4096,
3466 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003467 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003468 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003469 .port_base_addr = 0x0,
3470 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003471 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003472 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003473 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003474 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003475 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003476 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003477 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003478 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003479 .ops = &mv88e6190_ops,
3480 },
3481
3482 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003483 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003484 .family = MV88E6XXX_FAMILY_6390,
3485 .name = "Marvell 88E6190X",
3486 .num_databases = 4096,
3487 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003488 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003489 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003490 .port_base_addr = 0x0,
3491 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003492 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003493 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003494 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003495 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003496 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003497 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003498 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003499 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003500 .ops = &mv88e6190x_ops,
3501 },
3502
3503 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003504 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003505 .family = MV88E6XXX_FAMILY_6390,
3506 .name = "Marvell 88E6191",
3507 .num_databases = 4096,
3508 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003509 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003510 .port_base_addr = 0x0,
3511 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003512 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003513 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003514 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003515 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003516 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003517 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003518 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003519 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003520 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003521 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003522 },
3523
Vivien Didelotf81ec902016-05-09 13:22:58 -04003524 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003525 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003526 .family = MV88E6XXX_FAMILY_6352,
3527 .name = "Marvell 88E6240",
3528 .num_databases = 4096,
3529 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003530 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003531 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003532 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003533 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003534 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003535 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003536 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003537 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003538 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003539 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003540 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003541 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003542 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003543 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003544 },
3545
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003546 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003547 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003548 .family = MV88E6XXX_FAMILY_6390,
3549 .name = "Marvell 88E6290",
3550 .num_databases = 4096,
3551 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003552 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003553 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003554 .port_base_addr = 0x0,
3555 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003556 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003557 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003558 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003559 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003560 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003561 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003562 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003563 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003564 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003565 .ops = &mv88e6290_ops,
3566 },
3567
Vivien Didelotf81ec902016-05-09 13:22:58 -04003568 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003569 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003570 .family = MV88E6XXX_FAMILY_6320,
3571 .name = "Marvell 88E6320",
3572 .num_databases = 4096,
3573 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003574 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003575 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003576 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003577 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003578 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003579 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003580 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003581 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003582 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003583 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003584 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003585 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003586 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003587 },
3588
3589 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003590 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003591 .family = MV88E6XXX_FAMILY_6320,
3592 .name = "Marvell 88E6321",
3593 .num_databases = 4096,
3594 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003595 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003596 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003597 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003598 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003599 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003600 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003601 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003602 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003603 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003604 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003605 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003606 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003607 },
3608
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003609 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003610 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003611 .family = MV88E6XXX_FAMILY_6341,
3612 .name = "Marvell 88E6341",
3613 .num_databases = 4096,
3614 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003615 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003616 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003617 .port_base_addr = 0x10,
3618 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003619 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003620 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003621 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003622 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003623 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003624 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003625 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003626 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003627 .ops = &mv88e6341_ops,
3628 },
3629
Vivien Didelotf81ec902016-05-09 13:22:58 -04003630 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003631 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003632 .family = MV88E6XXX_FAMILY_6351,
3633 .name = "Marvell 88E6350",
3634 .num_databases = 4096,
3635 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003636 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003637 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003638 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003639 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003640 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003641 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003642 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003643 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003644 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003645 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003646 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003647 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003648 },
3649
3650 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003651 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003652 .family = MV88E6XXX_FAMILY_6351,
3653 .name = "Marvell 88E6351",
3654 .num_databases = 4096,
3655 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003656 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003657 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003658 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003659 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003660 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003661 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003662 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003663 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003664 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003665 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003666 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003667 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003668 },
3669
3670 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003671 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003672 .family = MV88E6XXX_FAMILY_6352,
3673 .name = "Marvell 88E6352",
3674 .num_databases = 4096,
3675 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003676 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003677 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003678 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003679 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003680 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003681 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003682 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003683 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003684 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003685 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003686 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003687 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003688 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003689 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003690 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003691 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003692 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003693 .family = MV88E6XXX_FAMILY_6390,
3694 .name = "Marvell 88E6390",
3695 .num_databases = 4096,
3696 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003697 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003698 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003699 .port_base_addr = 0x0,
3700 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003701 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003702 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003703 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003704 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003705 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003706 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003707 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003708 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003709 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003710 .ops = &mv88e6390_ops,
3711 },
3712 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003713 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003714 .family = MV88E6XXX_FAMILY_6390,
3715 .name = "Marvell 88E6390X",
3716 .num_databases = 4096,
3717 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003718 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003719 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003720 .port_base_addr = 0x0,
3721 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003722 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003723 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003724 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003725 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003726 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003727 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003728 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003729 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003730 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003731 .ops = &mv88e6390x_ops,
3732 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003733};
3734
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003735static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003736{
Vivien Didelota439c062016-04-17 13:23:58 -04003737 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003738
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003739 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3740 if (mv88e6xxx_table[i].prod_num == prod_num)
3741 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003742
Vivien Didelotb9b37712015-10-30 19:39:48 -04003743 return NULL;
3744}
3745
Vivien Didelotfad09c72016-06-21 12:28:20 -04003746static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003747{
3748 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003749 unsigned int prod_num, rev;
3750 u16 id;
3751 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003752
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003753 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003754 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003755 mutex_unlock(&chip->reg_lock);
3756 if (err)
3757 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003758
Vivien Didelot107fcc12017-06-12 12:37:36 -04003759 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3760 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003761
3762 info = mv88e6xxx_lookup_info(prod_num);
3763 if (!info)
3764 return -ENODEV;
3765
Vivien Didelotcaac8542016-06-20 13:14:09 -04003766 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003767 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003768
Vivien Didelotca070c12016-09-02 14:45:34 -04003769 err = mv88e6xxx_g2_require(chip);
3770 if (err)
3771 return err;
3772
Vivien Didelotfad09c72016-06-21 12:28:20 -04003773 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3774 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003775
3776 return 0;
3777}
3778
Vivien Didelotfad09c72016-06-21 12:28:20 -04003779static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003780{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003781 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003782
Vivien Didelotfad09c72016-06-21 12:28:20 -04003783 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3784 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003785 return NULL;
3786
Vivien Didelotfad09c72016-06-21 12:28:20 -04003787 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003788
Vivien Didelotfad09c72016-06-21 12:28:20 -04003789 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003790 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003791
Vivien Didelotfad09c72016-06-21 12:28:20 -04003792 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003793}
3794
Vivien Didelotfad09c72016-06-21 12:28:20 -04003795static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003796 struct mii_bus *bus, int sw_addr)
3797{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003798 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003799 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003800 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003801 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003802 else
3803 return -EINVAL;
3804
Vivien Didelotfad09c72016-06-21 12:28:20 -04003805 chip->bus = bus;
3806 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003807
3808 return 0;
3809}
3810
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08003811static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
3812 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02003813{
Vivien Didelot04bed142016-08-31 18:06:13 -04003814 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003815
Andrew Lunn443d5a12016-12-03 04:35:18 +01003816 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003817}
3818
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003819#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003820static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3821 struct device *host_dev, int sw_addr,
3822 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003823{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003824 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003825 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003826 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003827
Vivien Didelota439c062016-04-17 13:23:58 -04003828 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003829 if (!bus)
3830 return NULL;
3831
Vivien Didelotfad09c72016-06-21 12:28:20 -04003832 chip = mv88e6xxx_alloc_chip(dsa_dev);
3833 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003834 return NULL;
3835
Vivien Didelotcaac8542016-06-20 13:14:09 -04003836 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003837 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003838
Vivien Didelotfad09c72016-06-21 12:28:20 -04003839 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003840 if (err)
3841 goto free;
3842
Vivien Didelotfad09c72016-06-21 12:28:20 -04003843 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003844 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003845 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003846
Andrew Lunndc30c352016-10-16 19:56:49 +02003847 mutex_lock(&chip->reg_lock);
3848 err = mv88e6xxx_switch_reset(chip);
3849 mutex_unlock(&chip->reg_lock);
3850 if (err)
3851 goto free;
3852
Vivien Didelote57e5e72016-08-15 17:19:00 -04003853 mv88e6xxx_phy_init(chip);
3854
Andrew Lunna3c53be52017-01-24 14:53:50 +01003855 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003856 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003857 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003858
Vivien Didelotfad09c72016-06-21 12:28:20 -04003859 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003860
Vivien Didelotfad09c72016-06-21 12:28:20 -04003861 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003862free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003863 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003864
3865 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003866}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003867#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02003868
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003869static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003870 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003871{
3872 /* We don't need any dynamic resource from the kernel (yet),
3873 * so skip the prepare phase.
3874 */
3875
3876 return 0;
3877}
3878
3879static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003880 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003881{
Vivien Didelot04bed142016-08-31 18:06:13 -04003882 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003883
3884 mutex_lock(&chip->reg_lock);
3885 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003886 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003887 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3888 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003889 mutex_unlock(&chip->reg_lock);
3890}
3891
3892static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3893 const struct switchdev_obj_port_mdb *mdb)
3894{
Vivien Didelot04bed142016-08-31 18:06:13 -04003895 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003896 int err;
3897
3898 mutex_lock(&chip->reg_lock);
3899 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003900 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003901 mutex_unlock(&chip->reg_lock);
3902
3903 return err;
3904}
3905
Florian Fainellia82f67a2017-01-08 14:52:08 -08003906static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003907#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003908 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003909#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02003910 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003911 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003912 .adjust_link = mv88e6xxx_adjust_link,
3913 .get_strings = mv88e6xxx_get_strings,
3914 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3915 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003916 .port_enable = mv88e6xxx_port_enable,
3917 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04003918 .get_mac_eee = mv88e6xxx_get_mac_eee,
3919 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003920 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003921 .get_eeprom = mv88e6xxx_get_eeprom,
3922 .set_eeprom = mv88e6xxx_set_eeprom,
3923 .get_regs_len = mv88e6xxx_get_regs_len,
3924 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003925 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003926 .port_bridge_join = mv88e6xxx_port_bridge_join,
3927 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3928 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04003929 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003930 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3931 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3932 .port_vlan_add = mv88e6xxx_port_vlan_add,
3933 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003934 .port_fdb_add = mv88e6xxx_port_fdb_add,
3935 .port_fdb_del = mv88e6xxx_port_fdb_del,
3936 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003937 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
3938 .port_mdb_add = mv88e6xxx_port_mdb_add,
3939 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04003940 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
3941 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003942 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
3943 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
3944 .port_txtstamp = mv88e6xxx_port_txtstamp,
3945 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
3946 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003947};
3948
Florian Fainelliab3d4082017-01-08 14:52:07 -08003949static struct dsa_switch_driver mv88e6xxx_switch_drv = {
3950 .ops = &mv88e6xxx_switch_ops,
3951};
3952
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003953static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003954{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003955 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003956 struct dsa_switch *ds;
3957
Vivien Didelot73b12042017-03-30 17:37:10 -04003958 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003959 if (!ds)
3960 return -ENOMEM;
3961
Vivien Didelotfad09c72016-06-21 12:28:20 -04003962 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04003963 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04003964 ds->ageing_time_min = chip->info->age_time_coeff;
3965 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003966
3967 dev_set_drvdata(dev, ds);
3968
Vivien Didelot23c9ee42017-05-26 18:12:51 -04003969 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003970}
3971
Vivien Didelotfad09c72016-06-21 12:28:20 -04003972static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003973{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003974 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003975}
3976
Vivien Didelot57d32312016-06-20 13:13:58 -04003977static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003978{
3979 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003980 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003981 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003982 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003983 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02003984 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003985
Vivien Didelotcaac8542016-06-20 13:14:09 -04003986 compat_info = of_device_get_match_data(dev);
3987 if (!compat_info)
3988 return -EINVAL;
3989
Vivien Didelotfad09c72016-06-21 12:28:20 -04003990 chip = mv88e6xxx_alloc_chip(dev);
3991 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003992 return -ENOMEM;
3993
Vivien Didelotfad09c72016-06-21 12:28:20 -04003994 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003995
Vivien Didelotfad09c72016-06-21 12:28:20 -04003996 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003997 if (err)
3998 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003999
Andrew Lunnb4308f02016-11-21 23:26:55 +01004000 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
4001 if (IS_ERR(chip->reset))
4002 return PTR_ERR(chip->reset);
4003
Vivien Didelotfad09c72016-06-21 12:28:20 -04004004 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004005 if (err)
4006 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004007
Vivien Didelote57e5e72016-08-15 17:19:00 -04004008 mv88e6xxx_phy_init(chip);
4009
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004010 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004011 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004012 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004013
Andrew Lunndc30c352016-10-16 19:56:49 +02004014 mutex_lock(&chip->reg_lock);
4015 err = mv88e6xxx_switch_reset(chip);
4016 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004017 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004018 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004019
Andrew Lunndc30c352016-10-16 19:56:49 +02004020 chip->irq = of_irq_get(np, 0);
4021 if (chip->irq == -EPROBE_DEFER) {
4022 err = chip->irq;
4023 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004024 }
4025
Andrew Lunndc30c352016-10-16 19:56:49 +02004026 if (chip->irq > 0) {
4027 /* Has to be performed before the MDIO bus is created,
4028 * because the PHYs will link there interrupts to these
4029 * interrupt controllers
4030 */
4031 mutex_lock(&chip->reg_lock);
4032 err = mv88e6xxx_g1_irq_setup(chip);
4033 mutex_unlock(&chip->reg_lock);
4034
4035 if (err)
4036 goto out;
4037
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004038 if (chip->info->g2_irqs > 0) {
Andrew Lunndc30c352016-10-16 19:56:49 +02004039 err = mv88e6xxx_g2_irq_setup(chip);
4040 if (err)
4041 goto out_g1_irq;
4042 }
Andrew Lunn09776442018-01-14 02:32:44 +01004043
4044 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4045 if (err)
4046 goto out_g2_irq;
Andrew Lunn62eb1162018-01-14 02:32:45 +01004047
4048 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4049 if (err)
4050 goto out_g1_atu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004051 }
4052
Andrew Lunna3c53be52017-01-24 14:53:50 +01004053 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004054 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004055 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004056
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004057 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004058 if (err)
4059 goto out_mdio;
4060
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004061 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004062
4063out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004064 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004065out_g1_vtu_prob_irq:
Andrew Lunnae14caf2018-01-18 17:42:50 +01004066 if (chip->irq > 0)
4067 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004068out_g1_atu_prob_irq:
Andrew Lunnae14caf2018-01-18 17:42:50 +01004069 if (chip->irq > 0)
4070 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004071out_g2_irq:
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004072 if (chip->info->g2_irqs > 0 && chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004073 mv88e6xxx_g2_irq_free(chip);
4074out_g1_irq:
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004075 if (chip->irq > 0) {
4076 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004077 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004078 mutex_unlock(&chip->reg_lock);
4079 }
Andrew Lunndc30c352016-10-16 19:56:49 +02004080out:
4081 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004082}
4083
4084static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4085{
4086 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004087 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004088
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004089 if (chip->info->ptp_support) {
4090 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004091 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004092 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004093
Andrew Lunn930188c2016-08-22 16:01:03 +02004094 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004095 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004096 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004097
Andrew Lunn467126442016-11-20 20:14:15 +01004098 if (chip->irq > 0) {
Andrew Lunn62eb1162018-01-14 02:32:45 +01004099 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004100 mv88e6xxx_g1_atu_prob_irq_free(chip);
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004101 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004102 mv88e6xxx_g2_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004103 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004104 mv88e6xxx_g1_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004105 mutex_unlock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004106 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004107}
4108
4109static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004110 {
4111 .compatible = "marvell,mv88e6085",
4112 .data = &mv88e6xxx_table[MV88E6085],
4113 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004114 {
4115 .compatible = "marvell,mv88e6190",
4116 .data = &mv88e6xxx_table[MV88E6190],
4117 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004118 { /* sentinel */ },
4119};
4120
4121MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4122
4123static struct mdio_driver mv88e6xxx_driver = {
4124 .probe = mv88e6xxx_probe,
4125 .remove = mv88e6xxx_remove,
4126 .mdiodrv.driver = {
4127 .name = "mv88e6085",
4128 .of_match_table = mv88e6xxx_of_match,
4129 },
4130};
4131
Ben Hutchings98e67302011-11-25 14:36:19 +00004132static int __init mv88e6xxx_init(void)
4133{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004134 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004135 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004136}
4137module_init(mv88e6xxx_init);
4138
4139static void __exit mv88e6xxx_cleanup(void)
4140{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004141 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004142 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004143}
4144module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004145
4146MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4147MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4148MODULE_LICENSE("GPL");