blob: af63710e93c1e9ce4c01063843544fd21390bb4d [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 Lunne0d8b612016-11-21 23:27:04 +0100717 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
718 bank1_select,
719 histogram);
Andrew Lunn052f9472016-11-21 23:27:03 +0100720 j++;
721 }
722 }
723}
724
725static void mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
726 uint64_t *data)
727{
728 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100729 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400730 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100731}
732
733static void mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
734 uint64_t *data)
735{
736 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100737 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400738 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
739 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100740}
741
742static void mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
743 uint64_t *data)
744{
745 return mv88e6xxx_stats_get_stats(chip, port, data,
746 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400747 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
748 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100749}
750
751static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
752 uint64_t *data)
753{
754 if (chip->info->ops->stats_get_stats)
755 chip->info->ops->stats_get_stats(chip, port, data);
756}
757
Vivien Didelotf81ec902016-05-09 13:22:58 -0400758static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
759 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000760{
Vivien Didelot04bed142016-08-31 18:06:13 -0400761 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000762 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000763
Vivien Didelotfad09c72016-06-21 12:28:20 -0400764 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000765
Andrew Lunna605a0f2016-11-21 23:26:58 +0100766 ret = mv88e6xxx_stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000767 if (ret < 0) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400768 mutex_unlock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000769 return;
770 }
Andrew Lunn052f9472016-11-21 23:27:03 +0100771
772 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000773
Vivien Didelotfad09c72016-06-21 12:28:20 -0400774 mutex_unlock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000775}
Ben Hutchings98e67302011-11-25 14:36:19 +0000776
Andrew Lunnde2273872016-11-21 23:27:01 +0100777static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
778{
779 if (chip->info->ops->stats_set_histogram)
780 return chip->info->ops->stats_set_histogram(chip);
781
782 return 0;
783}
784
Vivien Didelotf81ec902016-05-09 13:22:58 -0400785static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700786{
787 return 32 * sizeof(u16);
788}
789
Vivien Didelotf81ec902016-05-09 13:22:58 -0400790static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
791 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700792{
Vivien Didelot04bed142016-08-31 18:06:13 -0400793 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200794 int err;
795 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700796 u16 *p = _p;
797 int i;
798
799 regs->version = 0;
800
801 memset(p, 0xff, 32 * sizeof(u16));
802
Vivien Didelotfad09c72016-06-21 12:28:20 -0400803 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -0400804
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700805 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700806
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200807 err = mv88e6xxx_port_read(chip, port, i, &reg);
808 if (!err)
809 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700810 }
Vivien Didelot23062512016-05-09 13:22:45 -0400811
Vivien Didelotfad09c72016-06-21 12:28:20 -0400812 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700813}
814
Vivien Didelot08f50062017-08-01 16:32:41 -0400815static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
816 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800817{
Vivien Didelot5480db62017-08-01 16:32:40 -0400818 /* Nothing to do on the port's MAC */
819 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800820}
821
Vivien Didelot08f50062017-08-01 16:32:41 -0400822static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
823 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800824{
Vivien Didelot5480db62017-08-01 16:32:40 -0400825 /* Nothing to do on the port's MAC */
826 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800827}
828
Vivien Didelote5887a22017-03-30 17:37:11 -0400829static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700830{
Vivien Didelote5887a22017-03-30 17:37:11 -0400831 struct dsa_switch *ds = NULL;
832 struct net_device *br;
833 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500834 int i;
835
Vivien Didelote5887a22017-03-30 17:37:11 -0400836 if (dev < DSA_MAX_SWITCHES)
837 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500838
Vivien Didelote5887a22017-03-30 17:37:11 -0400839 /* Prevent frames from unknown switch or port */
840 if (!ds || port >= ds->num_ports)
841 return 0;
842
843 /* Frames from DSA links and CPU ports can egress any local port */
844 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
845 return mv88e6xxx_port_mask(chip);
846
847 br = ds->ports[port].bridge_dev;
848 pvlan = 0;
849
850 /* Frames from user ports can egress any local DSA links and CPU ports,
851 * as well as any local member of their bridge group.
852 */
853 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
854 if (dsa_is_cpu_port(chip->ds, i) ||
855 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -0400856 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -0400857 pvlan |= BIT(i);
858
859 return pvlan;
860}
861
Vivien Didelot240ea3e2017-03-30 17:37:12 -0400862static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -0400863{
864 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500865
866 /* prevent frames from going back out of the port they came in on */
867 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700868
Vivien Didelot5a7921f2016-11-04 03:23:28 +0100869 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700870}
871
Vivien Didelotf81ec902016-05-09 13:22:58 -0400872static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
873 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700874{
Vivien Didelot04bed142016-08-31 18:06:13 -0400875 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -0400876 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700877
Vivien Didelotfad09c72016-06-21 12:28:20 -0400878 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -0400879 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400880 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -0400881
882 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -0400883 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700884}
885
Vivien Didelot9e907d72017-07-17 13:03:43 -0400886static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
887{
888 if (chip->info->ops->pot_clear)
889 return chip->info->ops->pot_clear(chip);
890
891 return 0;
892}
893
Vivien Didelot51c901a2017-07-17 13:03:41 -0400894static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
895{
896 if (chip->info->ops->mgmt_rsvd2cpu)
897 return chip->info->ops->mgmt_rsvd2cpu(chip);
898
899 return 0;
900}
901
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500902static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
903{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500904 int err;
905
Vivien Didelotdaefc942017-03-11 16:12:54 -0500906 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
907 if (err)
908 return err;
909
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -0500910 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
911 if (err)
912 return err;
913
Vivien Didelota2ac29d2017-03-11 16:12:49 -0500914 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
915}
916
Vivien Didelotcd8da8b2017-06-19 10:55:36 -0400917static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
918{
919 int port;
920 int err;
921
922 if (!chip->info->ops->irl_init_all)
923 return 0;
924
925 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
926 /* Disable ingress rate limiting by resetting all per port
927 * ingress rate limit resources to their initial state.
928 */
929 err = chip->info->ops->irl_init_all(chip, port);
930 if (err)
931 return err;
932 }
933
934 return 0;
935}
936
Vivien Didelot04a69a12017-10-13 14:18:05 -0400937static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
938{
939 if (chip->info->ops->set_switch_mac) {
940 u8 addr[ETH_ALEN];
941
942 eth_random_addr(addr);
943
944 return chip->info->ops->set_switch_mac(chip, addr);
945 }
946
947 return 0;
948}
949
Vivien Didelot17a15942017-03-30 17:37:09 -0400950static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
951{
952 u16 pvlan = 0;
953
954 if (!mv88e6xxx_has_pvt(chip))
955 return -EOPNOTSUPP;
956
957 /* Skip the local source device, which uses in-chip port VLAN */
958 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -0400959 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -0400960
961 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
962}
963
Vivien Didelot81228992017-03-30 17:37:08 -0400964static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
965{
Vivien Didelot17a15942017-03-30 17:37:09 -0400966 int dev, port;
967 int err;
968
Vivien Didelot81228992017-03-30 17:37:08 -0400969 if (!mv88e6xxx_has_pvt(chip))
970 return 0;
971
972 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
973 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
974 */
Vivien Didelot17a15942017-03-30 17:37:09 -0400975 err = mv88e6xxx_g2_misc_4_bit_port(chip);
976 if (err)
977 return err;
978
979 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
980 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
981 err = mv88e6xxx_pvt_map(chip, dev, port);
982 if (err)
983 return err;
984 }
985 }
986
987 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -0400988}
989
Vivien Didelot749efcb2016-09-22 16:49:24 -0400990static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
991{
992 struct mv88e6xxx_chip *chip = ds->priv;
993 int err;
994
995 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -0500996 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -0400997 mutex_unlock(&chip->reg_lock);
998
999 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001000 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001001}
1002
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001003static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1004{
1005 if (!chip->info->max_vid)
1006 return 0;
1007
1008 return mv88e6xxx_g1_vtu_flush(chip);
1009}
1010
Vivien Didelotf1394b782017-05-01 14:05:22 -04001011static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1012 struct mv88e6xxx_vtu_entry *entry)
1013{
1014 if (!chip->info->ops->vtu_getnext)
1015 return -EOPNOTSUPP;
1016
1017 return chip->info->ops->vtu_getnext(chip, entry);
1018}
1019
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001020static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1021 struct mv88e6xxx_vtu_entry *entry)
1022{
1023 if (!chip->info->ops->vtu_loadpurge)
1024 return -EOPNOTSUPP;
1025
1026 return chip->info->ops->vtu_loadpurge(chip, entry);
1027}
1028
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001029static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001030{
1031 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001032 struct mv88e6xxx_vtu_entry vlan = {
1033 .vid = chip->info->max_vid,
1034 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001035 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001036
1037 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1038
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001039 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001040 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001041 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001042 if (err)
1043 return err;
1044
1045 set_bit(*fid, fid_bitmap);
1046 }
1047
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001048 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001049 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001050 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001051 if (err)
1052 return err;
1053
1054 if (!vlan.valid)
1055 break;
1056
1057 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001058 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001059
1060 /* The reset value 0x000 is used to indicate that multiple address
1061 * databases are not needed. Return the next positive available.
1062 */
1063 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001064 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001065 return -ENOSPC;
1066
1067 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001068 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001069}
1070
Vivien Didelot567aa592017-05-01 14:05:25 -04001071static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1072 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001073{
1074 int err;
1075
1076 if (!vid)
1077 return -EINVAL;
1078
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001079 entry->vid = vid - 1;
1080 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001081
Vivien Didelotf1394b782017-05-01 14:05:22 -04001082 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001083 if (err)
1084 return err;
1085
Vivien Didelot567aa592017-05-01 14:05:25 -04001086 if (entry->vid == vid && entry->valid)
1087 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001088
Vivien Didelot567aa592017-05-01 14:05:25 -04001089 if (new) {
1090 int i;
1091
1092 /* Initialize a fresh VLAN entry */
1093 memset(entry, 0, sizeof(*entry));
1094 entry->valid = true;
1095 entry->vid = vid;
1096
Vivien Didelot553a7682017-06-07 18:12:16 -04001097 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001098 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001099 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001100 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001101
1102 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001103 }
1104
Vivien Didelot567aa592017-05-01 14:05:25 -04001105 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1106 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001107}
1108
Vivien Didelotda9c3592016-02-12 12:09:40 -05001109static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1110 u16 vid_begin, u16 vid_end)
1111{
Vivien Didelot04bed142016-08-31 18:06:13 -04001112 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001113 struct mv88e6xxx_vtu_entry vlan = {
1114 .vid = vid_begin - 1,
1115 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001116 int i, err;
1117
Andrew Lunndb06ae412017-09-25 23:32:20 +02001118 /* DSA and CPU ports have to be members of multiple vlans */
1119 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1120 return 0;
1121
Vivien Didelotda9c3592016-02-12 12:09:40 -05001122 if (!vid_begin)
1123 return -EOPNOTSUPP;
1124
Vivien Didelotfad09c72016-06-21 12:28:20 -04001125 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001126
Vivien Didelotda9c3592016-02-12 12:09:40 -05001127 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001128 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001129 if (err)
1130 goto unlock;
1131
1132 if (!vlan.valid)
1133 break;
1134
1135 if (vlan.vid > vid_end)
1136 break;
1137
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001138 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001139 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1140 continue;
1141
Andrew Lunncd886462017-11-09 22:29:53 +01001142 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001143 continue;
1144
Vivien Didelotbd00e052017-05-01 14:05:11 -04001145 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001146 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001147 continue;
1148
Vivien Didelotc8652c82017-10-16 11:12:19 -04001149 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001150 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001151 break; /* same bridge, check next VLAN */
1152
Vivien Didelotc8652c82017-10-16 11:12:19 -04001153 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001154 continue;
1155
Andrew Lunn743fcc22017-11-09 22:29:54 +01001156 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1157 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001158 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001159 err = -EOPNOTSUPP;
1160 goto unlock;
1161 }
1162 } while (vlan.vid < vid_end);
1163
1164unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001165 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001166
1167 return err;
1168}
1169
Vivien Didelotf81ec902016-05-09 13:22:58 -04001170static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1171 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001172{
Vivien Didelot04bed142016-08-31 18:06:13 -04001173 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001174 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1175 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001176 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001177
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001178 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001179 return -EOPNOTSUPP;
1180
Vivien Didelotfad09c72016-06-21 12:28:20 -04001181 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001182 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001183 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001184
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001185 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001186}
1187
Vivien Didelot57d32312016-06-20 13:13:58 -04001188static int
1189mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001190 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001191{
Vivien Didelot04bed142016-08-31 18:06:13 -04001192 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001193 int err;
1194
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001195 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001196 return -EOPNOTSUPP;
1197
Vivien Didelotda9c3592016-02-12 12:09:40 -05001198 /* If the requested port doesn't belong to the same bridge as the VLAN
1199 * members, do not support it (yet) and fallback to software VLAN.
1200 */
1201 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1202 vlan->vid_end);
1203 if (err)
1204 return err;
1205
Vivien Didelot76e398a2015-11-01 12:33:55 -05001206 /* We don't need any dynamic resource from the kernel (yet),
1207 * so skip the prepare phase.
1208 */
1209 return 0;
1210}
1211
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001212static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1213 const unsigned char *addr, u16 vid,
1214 u8 state)
1215{
1216 struct mv88e6xxx_vtu_entry vlan;
1217 struct mv88e6xxx_atu_entry entry;
1218 int err;
1219
1220 /* Null VLAN ID corresponds to the port private database */
1221 if (vid == 0)
1222 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1223 else
1224 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1225 if (err)
1226 return err;
1227
1228 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1229 ether_addr_copy(entry.mac, addr);
1230 eth_addr_dec(entry.mac);
1231
1232 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1233 if (err)
1234 return err;
1235
1236 /* Initialize a fresh ATU entry if it isn't found */
1237 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1238 !ether_addr_equal(entry.mac, addr)) {
1239 memset(&entry, 0, sizeof(entry));
1240 ether_addr_copy(entry.mac, addr);
1241 }
1242
1243 /* Purge the ATU entry only if no port is using it anymore */
1244 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1245 entry.portvec &= ~BIT(port);
1246 if (!entry.portvec)
1247 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1248 } else {
1249 entry.portvec |= BIT(port);
1250 entry.state = state;
1251 }
1252
1253 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1254}
1255
Andrew Lunn87fa8862017-11-09 22:29:56 +01001256static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1257 u16 vid)
1258{
1259 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1260 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1261
1262 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1263}
1264
1265static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1266{
1267 int port;
1268 int err;
1269
1270 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1271 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1272 if (err)
1273 return err;
1274 }
1275
1276 return 0;
1277}
1278
Vivien Didelotfad09c72016-06-21 12:28:20 -04001279static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001280 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001281{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001282 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001283 int err;
1284
Vivien Didelot567aa592017-05-01 14:05:25 -04001285 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001286 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001287 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001288
Vivien Didelotc91498e2017-06-07 18:12:13 -04001289 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001290
Andrew Lunn87fa8862017-11-09 22:29:56 +01001291 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1292 if (err)
1293 return err;
1294
1295 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001296}
1297
Vivien Didelotf81ec902016-05-09 13:22:58 -04001298static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001299 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001300{
Vivien Didelot04bed142016-08-31 18:06:13 -04001301 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001302 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1303 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001304 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001305 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001306
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001307 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001308 return;
1309
Vivien Didelotc91498e2017-06-07 18:12:13 -04001310 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001311 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001312 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001313 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001314 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001315 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001316
Vivien Didelotfad09c72016-06-21 12:28:20 -04001317 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001318
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001319 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001320 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001321 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1322 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001323
Vivien Didelot77064f32016-11-04 03:23:30 +01001324 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001325 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1326 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001327
Vivien Didelotfad09c72016-06-21 12:28:20 -04001328 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001329}
1330
Vivien Didelotfad09c72016-06-21 12:28:20 -04001331static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001332 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001333{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001334 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001335 int i, err;
1336
Vivien Didelot567aa592017-05-01 14:05:25 -04001337 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001338 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001339 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001340
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001341 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001342 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001343 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001344
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001345 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001346
1347 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001348 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001349 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001350 if (vlan.member[i] !=
1351 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001352 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001353 break;
1354 }
1355 }
1356
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001357 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001358 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001359 return err;
1360
Vivien Didelote606ca32017-03-11 16:12:55 -05001361 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001362}
1363
Vivien Didelotf81ec902016-05-09 13:22:58 -04001364static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1365 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001366{
Vivien Didelot04bed142016-08-31 18:06:13 -04001367 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001368 u16 pvid, vid;
1369 int err = 0;
1370
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001371 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001372 return -EOPNOTSUPP;
1373
Vivien Didelotfad09c72016-06-21 12:28:20 -04001374 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001375
Vivien Didelot77064f32016-11-04 03:23:30 +01001376 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001377 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001378 goto unlock;
1379
Vivien Didelot76e398a2015-11-01 12:33:55 -05001380 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001381 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001382 if (err)
1383 goto unlock;
1384
1385 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001386 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001387 if (err)
1388 goto unlock;
1389 }
1390 }
1391
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001392unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001393 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001394
1395 return err;
1396}
1397
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001398static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1399 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001400{
Vivien Didelot04bed142016-08-31 18:06:13 -04001401 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001402 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001403
Vivien Didelotfad09c72016-06-21 12:28:20 -04001404 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001405 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1406 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001407 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001408
1409 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001410}
1411
Vivien Didelotf81ec902016-05-09 13:22:58 -04001412static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001413 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001414{
Vivien Didelot04bed142016-08-31 18:06:13 -04001415 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001416 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001417
Vivien Didelotfad09c72016-06-21 12:28:20 -04001418 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001419 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001420 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001421 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001422
Vivien Didelot83dabd12016-08-31 11:50:04 -04001423 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001424}
1425
Vivien Didelot83dabd12016-08-31 11:50:04 -04001426static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1427 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001428 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001429{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001430 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001431 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001432 int err;
1433
Vivien Didelot27c0e602017-06-15 12:14:01 -04001434 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001435 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001436
1437 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001438 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001439 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001440 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001441
Vivien Didelot27c0e602017-06-15 12:14:01 -04001442 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001443 break;
1444
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001445 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001446 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001447
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001448 if (!is_unicast_ether_addr(addr.mac))
1449 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001450
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001451 is_static = (addr.state ==
1452 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1453 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001454 if (err)
1455 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001456 } while (!is_broadcast_ether_addr(addr.mac));
1457
1458 return err;
1459}
1460
Vivien Didelot83dabd12016-08-31 11:50:04 -04001461static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001462 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001463{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001464 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001465 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001466 };
1467 u16 fid;
1468 int err;
1469
1470 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001471 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001472 if (err)
1473 return err;
1474
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001475 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001476 if (err)
1477 return err;
1478
1479 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001480 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001481 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001482 if (err)
1483 return err;
1484
1485 if (!vlan.valid)
1486 break;
1487
1488 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001489 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001490 if (err)
1491 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001492 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001493
1494 return err;
1495}
1496
Vivien Didelotf81ec902016-05-09 13:22:58 -04001497static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001498 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001499{
Vivien Didelot04bed142016-08-31 18:06:13 -04001500 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001501 int err;
1502
Vivien Didelotfad09c72016-06-21 12:28:20 -04001503 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001504 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001505 mutex_unlock(&chip->reg_lock);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001506
1507 return err;
1508}
1509
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001510static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1511 struct net_device *br)
1512{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001513 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001514 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001515 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001516 int err;
1517
1518 /* Remap the Port VLAN of each local bridge group member */
1519 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1520 if (chip->ds->ports[port].bridge_dev == br) {
1521 err = mv88e6xxx_port_vlan_map(chip, port);
1522 if (err)
1523 return err;
1524 }
1525 }
1526
Vivien Didelote96a6e02017-03-30 17:37:13 -04001527 if (!mv88e6xxx_has_pvt(chip))
1528 return 0;
1529
1530 /* Remap the Port VLAN of each cross-chip bridge group member */
1531 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1532 ds = chip->ds->dst->ds[dev];
1533 if (!ds)
1534 break;
1535
1536 for (port = 0; port < ds->num_ports; ++port) {
1537 if (ds->ports[port].bridge_dev == br) {
1538 err = mv88e6xxx_pvt_map(chip, dev, port);
1539 if (err)
1540 return err;
1541 }
1542 }
1543 }
1544
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001545 return 0;
1546}
1547
Vivien Didelotf81ec902016-05-09 13:22:58 -04001548static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001549 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001550{
Vivien Didelot04bed142016-08-31 18:06:13 -04001551 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001552 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001553
Vivien Didelotfad09c72016-06-21 12:28:20 -04001554 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001555 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001556 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001557
Vivien Didelot466dfa02016-02-26 13:16:05 -05001558 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001559}
1560
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001561static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1562 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001563{
Vivien Didelot04bed142016-08-31 18:06:13 -04001564 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001565
Vivien Didelotfad09c72016-06-21 12:28:20 -04001566 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001567 if (mv88e6xxx_bridge_map(chip, br) ||
1568 mv88e6xxx_port_vlan_map(chip, port))
1569 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001570 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001571}
1572
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001573static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1574 int port, struct net_device *br)
1575{
1576 struct mv88e6xxx_chip *chip = ds->priv;
1577 int err;
1578
1579 if (!mv88e6xxx_has_pvt(chip))
1580 return 0;
1581
1582 mutex_lock(&chip->reg_lock);
1583 err = mv88e6xxx_pvt_map(chip, dev, port);
1584 mutex_unlock(&chip->reg_lock);
1585
1586 return err;
1587}
1588
1589static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1590 int port, struct net_device *br)
1591{
1592 struct mv88e6xxx_chip *chip = ds->priv;
1593
1594 if (!mv88e6xxx_has_pvt(chip))
1595 return;
1596
1597 mutex_lock(&chip->reg_lock);
1598 if (mv88e6xxx_pvt_map(chip, dev, port))
1599 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1600 mutex_unlock(&chip->reg_lock);
1601}
1602
Vivien Didelot17e708b2016-12-05 17:30:27 -05001603static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1604{
1605 if (chip->info->ops->reset)
1606 return chip->info->ops->reset(chip);
1607
1608 return 0;
1609}
1610
Vivien Didelot309eca62016-12-05 17:30:26 -05001611static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1612{
1613 struct gpio_desc *gpiod = chip->reset;
1614
1615 /* If there is a GPIO connected to the reset pin, toggle it */
1616 if (gpiod) {
1617 gpiod_set_value_cansleep(gpiod, 1);
1618 usleep_range(10000, 20000);
1619 gpiod_set_value_cansleep(gpiod, 0);
1620 usleep_range(10000, 20000);
1621 }
1622}
1623
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001624static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1625{
1626 int i, err;
1627
1628 /* Set all ports to the Disabled state */
1629 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001630 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001631 if (err)
1632 return err;
1633 }
1634
1635 /* Wait for transmit queues to drain,
1636 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1637 */
1638 usleep_range(2000, 4000);
1639
1640 return 0;
1641}
1642
Vivien Didelotfad09c72016-06-21 12:28:20 -04001643static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001644{
Vivien Didelota935c052016-09-29 12:21:53 -04001645 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001646
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001647 err = mv88e6xxx_disable_ports(chip);
1648 if (err)
1649 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001650
Vivien Didelot309eca62016-12-05 17:30:26 -05001651 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001652
Vivien Didelot17e708b2016-12-05 17:30:27 -05001653 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001654}
1655
Vivien Didelot43145572017-03-11 16:12:59 -05001656static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001657 enum mv88e6xxx_frame_mode frame,
1658 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001659{
1660 int err;
1661
Vivien Didelot43145572017-03-11 16:12:59 -05001662 if (!chip->info->ops->port_set_frame_mode)
1663 return -EOPNOTSUPP;
1664
1665 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001666 if (err)
1667 return err;
1668
Vivien Didelot43145572017-03-11 16:12:59 -05001669 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1670 if (err)
1671 return err;
1672
1673 if (chip->info->ops->port_set_ether_type)
1674 return chip->info->ops->port_set_ether_type(chip, port, etype);
1675
1676 return 0;
1677}
1678
1679static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1680{
1681 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001682 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001683 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001684}
1685
1686static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1687{
1688 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001689 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001690 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001691}
1692
1693static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1694{
1695 return mv88e6xxx_set_port_mode(chip, port,
1696 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001697 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1698 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001699}
1700
1701static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1702{
1703 if (dsa_is_dsa_port(chip->ds, port))
1704 return mv88e6xxx_set_port_mode_dsa(chip, port);
1705
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001706 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001707 return mv88e6xxx_set_port_mode_normal(chip, port);
1708
1709 /* Setup CPU port mode depending on its supported tag format */
1710 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1711 return mv88e6xxx_set_port_mode_dsa(chip, port);
1712
1713 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1714 return mv88e6xxx_set_port_mode_edsa(chip, port);
1715
1716 return -EINVAL;
1717}
1718
Vivien Didelotea698f42017-03-11 16:12:50 -05001719static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1720{
1721 bool message = dsa_is_dsa_port(chip->ds, port);
1722
1723 return mv88e6xxx_port_set_message_port(chip, port, message);
1724}
1725
Vivien Didelot601aeed2017-03-11 16:13:00 -05001726static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1727{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001728 struct dsa_switch *ds = chip->ds;
1729 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05001730
1731 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001732 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05001733 if (chip->info->ops->port_set_egress_floods)
1734 return chip->info->ops->port_set_egress_floods(chip, port,
1735 flood, flood);
1736
1737 return 0;
1738}
1739
Andrew Lunn6d917822017-05-26 01:03:21 +02001740static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1741 bool on)
1742{
Vivien Didelot523a8902017-05-26 18:02:42 -04001743 if (chip->info->ops->serdes_power)
1744 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001745
Vivien Didelot523a8902017-05-26 18:02:42 -04001746 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001747}
1748
Vivien Didelotfa371c82017-12-05 15:34:10 -05001749static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
1750{
1751 struct dsa_switch *ds = chip->ds;
1752 int upstream_port;
1753 int err;
1754
Vivien Didelot07073c72017-12-05 15:34:13 -05001755 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05001756 if (chip->info->ops->port_set_upstream_port) {
1757 err = chip->info->ops->port_set_upstream_port(chip, port,
1758 upstream_port);
1759 if (err)
1760 return err;
1761 }
1762
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05001763 if (port == upstream_port) {
1764 if (chip->info->ops->set_cpu_port) {
1765 err = chip->info->ops->set_cpu_port(chip,
1766 upstream_port);
1767 if (err)
1768 return err;
1769 }
1770
1771 if (chip->info->ops->set_egress_port) {
1772 err = chip->info->ops->set_egress_port(chip,
1773 upstream_port);
1774 if (err)
1775 return err;
1776 }
1777 }
1778
Vivien Didelotfa371c82017-12-05 15:34:10 -05001779 return 0;
1780}
1781
Vivien Didelotfad09c72016-06-21 12:28:20 -04001782static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001783{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001784 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001785 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001786 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001787
Vivien Didelotd78343d2016-11-04 03:23:36 +01001788 /* MAC Forcing register: don't force link, speed, duplex or flow control
1789 * state to any particular values on physical ports, but force the CPU
1790 * port and all DSA ports to their maximum bandwidth and full duplex.
1791 */
1792 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1793 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1794 SPEED_MAX, DUPLEX_FULL,
1795 PHY_INTERFACE_MODE_NA);
1796 else
1797 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1798 SPEED_UNFORCED, DUPLEX_UNFORCED,
1799 PHY_INTERFACE_MODE_NA);
1800 if (err)
1801 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001802
1803 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1804 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1805 * tunneling, determine priority by looking at 802.1p and IP
1806 * priority fields (IP prio has precedence), and set STP state
1807 * to Forwarding.
1808 *
1809 * If this is the CPU link, use DSA or EDSA tagging depending
1810 * on which tagging mode was configured.
1811 *
1812 * If this is a link to another switch, use DSA tagging mode.
1813 *
1814 * If this is the upstream port for this switch, enable
1815 * forwarding of unknown unicasts and multicasts.
1816 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001817 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1818 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1819 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1820 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001821 if (err)
1822 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001823
Vivien Didelot601aeed2017-03-11 16:13:00 -05001824 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001825 if (err)
1826 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001827
Vivien Didelot601aeed2017-03-11 16:13:00 -05001828 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001829 if (err)
1830 return err;
1831
Andrew Lunn04aca992017-05-26 01:03:24 +02001832 /* Enable the SERDES interface for DSA and CPU ports. Normal
1833 * ports SERDES are enabled when the port is enabled, thus
1834 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001835 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001836 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1837 err = mv88e6xxx_serdes_power(chip, port, true);
1838 if (err)
1839 return err;
1840 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001841
Vivien Didelot8efdda42015-08-13 12:52:23 -04001842 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001843 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001844 * untagged frames on this port, do a destination address lookup on all
1845 * received packets as usual, disable ARP mirroring and don't send a
1846 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001847 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001848 err = mv88e6xxx_port_set_map_da(chip, port);
1849 if (err)
1850 return err;
1851
Vivien Didelotfa371c82017-12-05 15:34:10 -05001852 err = mv88e6xxx_setup_upstream_port(chip, port);
1853 if (err)
1854 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001855
Andrew Lunna23b2962017-02-04 20:15:28 +01001856 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001857 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01001858 if (err)
1859 return err;
1860
Vivien Didelotcd782652017-06-08 18:34:13 -04001861 if (chip->info->ops->port_set_jumbo_size) {
1862 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01001863 if (err)
1864 return err;
1865 }
1866
Andrew Lunn54d792f2015-05-06 01:09:47 +02001867 /* Port Association Vector: when learning source addresses
1868 * of packets, add the address to the address database using
1869 * a port bitmap that has only the bit for this port set and
1870 * the other bits clear.
1871 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001872 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04001873 /* Disable learning for CPU port */
1874 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04001875 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05001876
Vivien Didelot2a4614e2017-06-12 12:37:43 -04001877 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
1878 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001879 if (err)
1880 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001881
1882 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04001883 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
1884 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001885 if (err)
1886 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001887
Vivien Didelot08984322017-06-08 18:34:12 -04001888 if (chip->info->ops->port_pause_limit) {
1889 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01001890 if (err)
1891 return err;
1892 }
1893
Vivien Didelotc8c94892017-03-11 16:13:01 -05001894 if (chip->info->ops->port_disable_learn_limit) {
1895 err = chip->info->ops->port_disable_learn_limit(chip, port);
1896 if (err)
1897 return err;
1898 }
1899
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05001900 if (chip->info->ops->port_disable_pri_override) {
1901 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001902 if (err)
1903 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01001904 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02001905
Andrew Lunnef0a7312016-12-03 04:35:16 +01001906 if (chip->info->ops->port_tag_remap) {
1907 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001908 if (err)
1909 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001910 }
1911
Andrew Lunnef70b112016-12-03 04:45:18 +01001912 if (chip->info->ops->port_egress_rate_limiting) {
1913 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001914 if (err)
1915 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001916 }
1917
Vivien Didelotea698f42017-03-11 16:12:50 -05001918 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001919 if (err)
1920 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001921
Vivien Didelot207afda2016-04-14 14:42:09 -04001922 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001923 * database, and allow bidirectional communication between the
1924 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07001925 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001926 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001927 if (err)
1928 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001929
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001930 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001931 if (err)
1932 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07001933
1934 /* Default VLAN ID and priority: don't set a default VLAN
1935 * ID, and set the default packet priority to zero.
1936 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04001937 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02001938}
1939
Andrew Lunn04aca992017-05-26 01:03:24 +02001940static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
1941 struct phy_device *phydev)
1942{
1943 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04001944 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02001945
1946 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001947 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02001948 mutex_unlock(&chip->reg_lock);
1949
1950 return err;
1951}
1952
1953static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
1954 struct phy_device *phydev)
1955{
1956 struct mv88e6xxx_chip *chip = ds->priv;
1957
1958 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04001959 if (mv88e6xxx_serdes_power(chip, port, false))
1960 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02001961 mutex_unlock(&chip->reg_lock);
1962}
1963
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001964static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
1965 unsigned int ageing_time)
1966{
Vivien Didelot04bed142016-08-31 18:06:13 -04001967 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001968 int err;
1969
1970 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05001971 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04001972 mutex_unlock(&chip->reg_lock);
1973
1974 return err;
1975}
1976
Vivien Didelot97299342016-07-18 20:45:30 -04001977static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04001978{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001979 struct dsa_switch *ds = chip->ds;
Vivien Didelot08a01262016-05-09 13:22:50 -04001980 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04001981
Vivien Didelot50484ff2016-05-09 13:22:54 -04001982 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04001983 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
1984 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04001985 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04001986 if (err)
1987 return err;
1988
Vivien Didelot08a01262016-05-09 13:22:50 -04001989 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04001990 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001991 if (err)
1992 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001993 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04001994 if (err)
1995 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001996 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04001997 if (err)
1998 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04001999 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002000 if (err)
2001 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002002 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002003 if (err)
2004 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002005 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002006 if (err)
2007 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002008 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002009 if (err)
2010 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002011 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002012 if (err)
2013 return err;
2014
2015 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002016 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002017 if (err)
2018 return err;
2019
Andrew Lunnde2273872016-11-21 23:27:01 +01002020 /* Initialize the statistics unit */
2021 err = mv88e6xxx_stats_set_histogram(chip);
2022 if (err)
2023 return err;
2024
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002025 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002026}
2027
Vivien Didelotf81ec902016-05-09 13:22:58 -04002028static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002029{
Vivien Didelot04bed142016-08-31 18:06:13 -04002030 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002031 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002032 int i;
2033
Vivien Didelotfad09c72016-06-21 12:28:20 -04002034 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002035 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002036
Vivien Didelotfad09c72016-06-21 12:28:20 -04002037 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002038
Vivien Didelot97299342016-07-18 20:45:30 -04002039 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002040 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002041 if (dsa_is_unused_port(ds, i))
2042 continue;
2043
Vivien Didelot97299342016-07-18 20:45:30 -04002044 err = mv88e6xxx_setup_port(chip, i);
2045 if (err)
2046 goto unlock;
2047 }
2048
2049 /* Setup Switch Global 1 Registers */
2050 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002051 if (err)
2052 goto unlock;
2053
Vivien Didelot97299342016-07-18 20:45:30 -04002054 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002055 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002056 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002057 if (err)
2058 goto unlock;
2059 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002060
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002061 err = mv88e6xxx_irl_setup(chip);
2062 if (err)
2063 goto unlock;
2064
Vivien Didelot04a69a12017-10-13 14:18:05 -04002065 err = mv88e6xxx_mac_setup(chip);
2066 if (err)
2067 goto unlock;
2068
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002069 err = mv88e6xxx_phy_setup(chip);
2070 if (err)
2071 goto unlock;
2072
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002073 err = mv88e6xxx_vtu_setup(chip);
2074 if (err)
2075 goto unlock;
2076
Vivien Didelot81228992017-03-30 17:37:08 -04002077 err = mv88e6xxx_pvt_setup(chip);
2078 if (err)
2079 goto unlock;
2080
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002081 err = mv88e6xxx_atu_setup(chip);
2082 if (err)
2083 goto unlock;
2084
Andrew Lunn87fa8862017-11-09 22:29:56 +01002085 err = mv88e6xxx_broadcast_setup(chip, 0);
2086 if (err)
2087 goto unlock;
2088
Vivien Didelot9e907d72017-07-17 13:03:43 -04002089 err = mv88e6xxx_pot_setup(chip);
2090 if (err)
2091 goto unlock;
2092
Vivien Didelot51c901a2017-07-17 13:03:41 -04002093 err = mv88e6xxx_rsvd2cpu_setup(chip);
2094 if (err)
2095 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002096
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002097 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002098 if (chip->info->ptp_support) {
2099 err = mv88e6xxx_ptp_setup(chip);
2100 if (err)
2101 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002102
2103 err = mv88e6xxx_hwtstamp_setup(chip);
2104 if (err)
2105 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002106 }
2107
Vivien Didelot6b17e862015-08-13 12:52:18 -04002108unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002109 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002110
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002111 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002112}
2113
Vivien Didelote57e5e72016-08-15 17:19:00 -04002114static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002115{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002116 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2117 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002118 u16 val;
2119 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002120
Andrew Lunnee26a222017-01-24 14:53:48 +01002121 if (!chip->info->ops->phy_read)
2122 return -EOPNOTSUPP;
2123
Vivien Didelotfad09c72016-06-21 12:28:20 -04002124 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002125 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002126 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002127
Andrew Lunnda9f3302017-02-01 03:40:05 +01002128 if (reg == MII_PHYSID2) {
2129 /* Some internal PHYS don't have a model number. Use
2130 * the mv88e6390 family model number instead.
2131 */
2132 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002133 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002134 }
2135
Vivien Didelote57e5e72016-08-15 17:19:00 -04002136 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002137}
2138
Vivien Didelote57e5e72016-08-15 17:19:00 -04002139static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002140{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002141 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2142 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002143 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002144
Andrew Lunnee26a222017-01-24 14:53:48 +01002145 if (!chip->info->ops->phy_write)
2146 return -EOPNOTSUPP;
2147
Vivien Didelotfad09c72016-06-21 12:28:20 -04002148 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002149 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002150 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002151
2152 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002153}
2154
Vivien Didelotfad09c72016-06-21 12:28:20 -04002155static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002156 struct device_node *np,
2157 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002158{
2159 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002160 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002161 struct mii_bus *bus;
2162 int err;
2163
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002164 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002165 if (!bus)
2166 return -ENOMEM;
2167
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002168 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002169 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002170 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002171 INIT_LIST_HEAD(&mdio_bus->list);
2172 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002173
Andrew Lunnb516d452016-06-04 21:17:06 +02002174 if (np) {
2175 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002176 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002177 } else {
2178 bus->name = "mv88e6xxx SMI";
2179 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2180 }
2181
2182 bus->read = mv88e6xxx_mdio_read;
2183 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002184 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002185
Andrew Lunna3c53be52017-01-24 14:53:50 +01002186 if (np)
2187 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002188 else
2189 err = mdiobus_register(bus);
2190 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002191 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002192 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002193 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002194
2195 if (external)
2196 list_add_tail(&mdio_bus->list, &chip->mdios);
2197 else
2198 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002199
2200 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002201}
2202
Andrew Lunna3c53be52017-01-24 14:53:50 +01002203static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2204 { .compatible = "marvell,mv88e6xxx-mdio-external",
2205 .data = (void *)true },
2206 { },
2207};
2208
Andrew Lunn3126aee2017-12-07 01:05:57 +01002209static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2210
2211{
2212 struct mv88e6xxx_mdio_bus *mdio_bus;
2213 struct mii_bus *bus;
2214
2215 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2216 bus = mdio_bus->bus;
2217
2218 mdiobus_unregister(bus);
2219 }
2220}
2221
Andrew Lunna3c53be52017-01-24 14:53:50 +01002222static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2223 struct device_node *np)
2224{
2225 const struct of_device_id *match;
2226 struct device_node *child;
2227 int err;
2228
2229 /* Always register one mdio bus for the internal/default mdio
2230 * bus. This maybe represented in the device tree, but is
2231 * optional.
2232 */
2233 child = of_get_child_by_name(np, "mdio");
2234 err = mv88e6xxx_mdio_register(chip, child, false);
2235 if (err)
2236 return err;
2237
2238 /* Walk the device tree, and see if there are any other nodes
2239 * which say they are compatible with the external mdio
2240 * bus.
2241 */
2242 for_each_available_child_of_node(np, child) {
2243 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2244 if (match) {
2245 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002246 if (err) {
2247 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002248 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002249 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002250 }
2251 }
2252
2253 return 0;
2254}
2255
Vivien Didelot855b1932016-07-20 18:18:35 -04002256static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2257{
Vivien Didelot04bed142016-08-31 18:06:13 -04002258 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002259
2260 return chip->eeprom_len;
2261}
2262
Vivien Didelot855b1932016-07-20 18:18:35 -04002263static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2264 struct ethtool_eeprom *eeprom, u8 *data)
2265{
Vivien Didelot04bed142016-08-31 18:06:13 -04002266 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002267 int err;
2268
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002269 if (!chip->info->ops->get_eeprom)
2270 return -EOPNOTSUPP;
2271
Vivien Didelot855b1932016-07-20 18:18:35 -04002272 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002273 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002274 mutex_unlock(&chip->reg_lock);
2275
2276 if (err)
2277 return err;
2278
2279 eeprom->magic = 0xc3ec4951;
2280
2281 return 0;
2282}
2283
Vivien Didelot855b1932016-07-20 18:18:35 -04002284static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2285 struct ethtool_eeprom *eeprom, u8 *data)
2286{
Vivien Didelot04bed142016-08-31 18:06:13 -04002287 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002288 int err;
2289
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002290 if (!chip->info->ops->set_eeprom)
2291 return -EOPNOTSUPP;
2292
Vivien Didelot855b1932016-07-20 18:18:35 -04002293 if (eeprom->magic != 0xc3ec4951)
2294 return -EINVAL;
2295
2296 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002297 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002298 mutex_unlock(&chip->reg_lock);
2299
2300 return err;
2301}
2302
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002303static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002304 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002305 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002306 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002307 .phy_read = mv88e6185_phy_ppu_read,
2308 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002309 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002310 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002311 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002312 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002313 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002314 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002315 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002316 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002317 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002318 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002319 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002320 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002321 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002322 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2323 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002324 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002325 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2326 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002327 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002328 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002329 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002330 .ppu_enable = mv88e6185_g1_ppu_enable,
2331 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002332 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002333 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002334 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002335};
2336
2337static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002338 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002339 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002340 .phy_read = mv88e6185_phy_ppu_read,
2341 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002342 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002343 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002344 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002345 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002346 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002347 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002348 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002349 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002350 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2351 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002352 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002353 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002354 .ppu_enable = mv88e6185_g1_ppu_enable,
2355 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002356 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002357 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002358 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002359};
2360
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002361static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002362 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002363 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002364 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2365 .phy_read = mv88e6xxx_g2_smi_phy_read,
2366 .phy_write = mv88e6xxx_g2_smi_phy_write,
2367 .port_set_link = mv88e6xxx_port_set_link,
2368 .port_set_duplex = mv88e6xxx_port_set_duplex,
2369 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002370 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002371 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002372 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002373 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002374 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002375 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002376 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002377 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002378 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002379 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002380 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002381 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2382 .stats_get_strings = mv88e6095_stats_get_strings,
2383 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002384 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2385 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002386 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002387 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002388 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002389 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002390 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002391 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002392};
2393
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002394static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002395 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002396 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002397 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002398 .phy_read = mv88e6xxx_g2_smi_phy_read,
2399 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002400 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002401 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002402 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002403 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002404 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002405 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002406 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002407 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002408 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002409 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2410 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002411 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002412 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2413 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002414 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002415 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002416 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002417 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002418 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002419 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002420};
2421
2422static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002423 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002424 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002425 .phy_read = mv88e6185_phy_ppu_read,
2426 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002427 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002428 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002429 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002430 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002431 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002432 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002433 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002434 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002435 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002436 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002437 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002438 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002439 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002440 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2441 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002442 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002443 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2444 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002445 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002446 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002447 .ppu_enable = mv88e6185_g1_ppu_enable,
2448 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002449 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002450 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002451 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002452};
2453
Vivien Didelot990e27b2017-03-28 13:50:32 -04002454static const struct mv88e6xxx_ops mv88e6141_ops = {
2455 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002456 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002457 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2458 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2459 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2460 .phy_read = mv88e6xxx_g2_smi_phy_read,
2461 .phy_write = mv88e6xxx_g2_smi_phy_write,
2462 .port_set_link = mv88e6xxx_port_set_link,
2463 .port_set_duplex = mv88e6xxx_port_set_duplex,
2464 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2465 .port_set_speed = mv88e6390_port_set_speed,
2466 .port_tag_remap = mv88e6095_port_tag_remap,
2467 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2468 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2469 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002470 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002471 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002472 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002473 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2474 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2475 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002476 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002477 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2478 .stats_get_strings = mv88e6320_stats_get_strings,
2479 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002480 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2481 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002482 .watchdog_ops = &mv88e6390_watchdog_ops,
2483 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002484 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002485 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002486 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002487 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002488 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002489};
2490
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002491static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002492 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002493 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002494 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002495 .phy_read = mv88e6xxx_g2_smi_phy_read,
2496 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002497 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002498 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002499 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002500 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002501 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002502 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002503 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002504 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002505 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002506 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002507 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002508 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002509 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002510 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002511 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2512 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002513 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002514 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2515 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002516 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002517 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002518 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002519 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002520 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002521 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002522};
2523
2524static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002525 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002526 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002527 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002528 .phy_read = mv88e6165_phy_read,
2529 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002530 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002531 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002532 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002533 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002534 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002535 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002536 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002537 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2538 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002539 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002540 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2541 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002542 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002543 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002544 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002545 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002546 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002547 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002548};
2549
2550static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002551 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002552 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002553 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002554 .phy_read = mv88e6xxx_g2_smi_phy_read,
2555 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002556 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002557 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002558 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002559 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002560 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002561 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002562 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002563 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002564 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002565 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002566 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002567 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002568 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002569 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002570 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002571 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2572 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002573 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002574 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2575 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002576 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002577 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002578 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002579 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002580 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002581 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002582};
2583
2584static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002585 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002586 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002587 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2588 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002589 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002590 .phy_read = mv88e6xxx_g2_smi_phy_read,
2591 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002592 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002593 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002594 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002595 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002596 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002597 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002598 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002599 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002600 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002601 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002602 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002603 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002604 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002605 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002606 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002607 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2608 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002609 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002610 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2611 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002612 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002613 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002614 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002615 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002616 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002617 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002618 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002619 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002620};
2621
2622static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002623 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002624 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002625 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002626 .phy_read = mv88e6xxx_g2_smi_phy_read,
2627 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002628 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002629 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002630 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002631 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002632 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002633 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002634 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002635 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002636 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002637 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002638 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002639 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002640 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002641 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002642 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002643 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2644 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002645 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002646 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2647 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002648 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002649 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002650 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002651 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002652 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002653 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002654};
2655
2656static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002657 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002658 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002659 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2660 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002661 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002662 .phy_read = mv88e6xxx_g2_smi_phy_read,
2663 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002664 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002665 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002666 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002667 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002668 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002669 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002670 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002671 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002672 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002673 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002674 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002675 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002676 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002677 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002678 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002679 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2680 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002681 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002682 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2683 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002684 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002685 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002686 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002687 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002688 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002689 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002690 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002691 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002692};
2693
2694static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002695 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002696 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002697 .phy_read = mv88e6185_phy_ppu_read,
2698 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002699 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002700 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002701 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002702 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002703 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002704 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002705 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002706 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002707 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002708 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2709 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002710 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002711 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2712 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002713 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002714 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002715 .ppu_enable = mv88e6185_g1_ppu_enable,
2716 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002717 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002718 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002719 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002720};
2721
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002722static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002723 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002724 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002725 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2726 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002727 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2728 .phy_read = mv88e6xxx_g2_smi_phy_read,
2729 .phy_write = mv88e6xxx_g2_smi_phy_write,
2730 .port_set_link = mv88e6xxx_port_set_link,
2731 .port_set_duplex = mv88e6xxx_port_set_duplex,
2732 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2733 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002734 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002735 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002736 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002737 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002738 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002739 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002740 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002741 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002742 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002743 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2744 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002745 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002746 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2747 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002748 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002749 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002750 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002751 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002752 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2753 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002754 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002755 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002756};
2757
2758static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002759 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002760 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002761 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2762 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002763 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2764 .phy_read = mv88e6xxx_g2_smi_phy_read,
2765 .phy_write = mv88e6xxx_g2_smi_phy_write,
2766 .port_set_link = mv88e6xxx_port_set_link,
2767 .port_set_duplex = mv88e6xxx_port_set_duplex,
2768 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2769 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002770 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002771 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002772 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002773 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002774 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002775 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002776 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002777 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002778 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002779 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2780 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002781 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002782 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2783 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002784 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002785 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002786 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002787 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002788 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2789 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002790 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002791 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002792};
2793
2794static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002795 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002796 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002797 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2798 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002799 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2800 .phy_read = mv88e6xxx_g2_smi_phy_read,
2801 .phy_write = mv88e6xxx_g2_smi_phy_write,
2802 .port_set_link = mv88e6xxx_port_set_link,
2803 .port_set_duplex = mv88e6xxx_port_set_duplex,
2804 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2805 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002806 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002807 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002808 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002809 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002810 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002811 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002812 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002813 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002814 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002815 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2816 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002817 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002818 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2819 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002820 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002821 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002822 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002823 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002824 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2825 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002826 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002827};
2828
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002829static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002830 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002831 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002832 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2833 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002834 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002835 .phy_read = mv88e6xxx_g2_smi_phy_read,
2836 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002837 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002838 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002839 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002840 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002841 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002842 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002843 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002844 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002845 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002846 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002847 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002848 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002849 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002850 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002851 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002852 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2853 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002854 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002855 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2856 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002857 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002858 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002859 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002860 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002861 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002862 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002863 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002864 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002865 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002866};
2867
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002868static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002869 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002870 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002871 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2872 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002873 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2874 .phy_read = mv88e6xxx_g2_smi_phy_read,
2875 .phy_write = mv88e6xxx_g2_smi_phy_write,
2876 .port_set_link = mv88e6xxx_port_set_link,
2877 .port_set_duplex = mv88e6xxx_port_set_duplex,
2878 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2879 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002880 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002881 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002882 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002883 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002884 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01002885 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002886 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002887 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002888 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002889 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002890 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2891 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002892 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002893 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2894 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002895 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002896 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002897 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002898 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002899 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2900 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002901 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002902 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002903 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002904};
2905
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002906static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002907 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002908 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002909 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2910 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002911 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002912 .phy_read = mv88e6xxx_g2_smi_phy_read,
2913 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002914 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002915 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002916 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002917 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002918 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002919 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002920 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002921 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002922 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002923 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002924 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002925 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002926 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002927 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002928 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2929 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002930 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002931 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2932 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002933 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002934 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002935 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002936 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002937 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002938 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002939 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002940};
2941
2942static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04002943 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002944 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002945 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2946 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002947 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002948 .phy_read = mv88e6xxx_g2_smi_phy_read,
2949 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002950 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002951 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002952 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002953 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002954 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002955 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002956 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002957 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002958 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002959 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002960 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002961 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002962 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002963 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002964 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2965 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002966 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002967 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2968 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002969 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002970 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002971 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002972 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01002973 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002974};
2975
Vivien Didelot16e329a2017-03-28 13:50:33 -04002976static const struct mv88e6xxx_ops mv88e6341_ops = {
2977 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002978 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002979 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2980 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2981 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2982 .phy_read = mv88e6xxx_g2_smi_phy_read,
2983 .phy_write = mv88e6xxx_g2_smi_phy_write,
2984 .port_set_link = mv88e6xxx_port_set_link,
2985 .port_set_duplex = mv88e6xxx_port_set_duplex,
2986 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2987 .port_set_speed = mv88e6390_port_set_speed,
2988 .port_tag_remap = mv88e6095_port_tag_remap,
2989 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2990 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2991 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002992 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002993 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002994 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002995 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2996 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2997 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002998 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04002999 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3000 .stats_get_strings = mv88e6320_stats_get_strings,
3001 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003002 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3003 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003004 .watchdog_ops = &mv88e6390_watchdog_ops,
3005 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003006 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003007 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003008 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003009 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003010 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003011 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003012};
3013
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003014static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003015 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003016 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003017 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003018 .phy_read = mv88e6xxx_g2_smi_phy_read,
3019 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003020 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003021 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003022 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003023 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003024 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003025 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003026 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003027 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003028 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003029 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003030 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003031 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003032 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003033 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003034 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003035 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3036 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003037 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003038 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3039 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003040 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003041 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003042 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003043 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003044 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003045 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003046};
3047
3048static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003049 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003050 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003051 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003052 .phy_read = mv88e6xxx_g2_smi_phy_read,
3053 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003054 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003055 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003056 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003057 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003058 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003059 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003060 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003061 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003062 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003063 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003064 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003065 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003066 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003067 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003068 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003069 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3070 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003071 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003072 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3073 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003074 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003075 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003076 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003077 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003078 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003079 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003080 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003081};
3082
3083static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003084 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003085 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003086 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3087 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003088 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003089 .phy_read = mv88e6xxx_g2_smi_phy_read,
3090 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003091 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003092 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003093 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003094 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003095 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003096 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003097 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003098 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003099 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003100 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003101 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003102 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003103 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003104 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003105 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003106 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3107 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003108 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003109 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3110 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003111 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003112 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003113 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003114 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003115 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003116 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003117 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003118 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003119 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003120};
3121
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003122static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003123 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003124 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003125 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3126 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003127 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3128 .phy_read = mv88e6xxx_g2_smi_phy_read,
3129 .phy_write = mv88e6xxx_g2_smi_phy_write,
3130 .port_set_link = mv88e6xxx_port_set_link,
3131 .port_set_duplex = mv88e6xxx_port_set_duplex,
3132 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3133 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003134 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003135 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003136 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003137 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003138 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003139 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003140 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003141 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003142 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003143 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003144 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003145 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003146 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3147 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003148 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003149 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3150 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003151 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003152 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003153 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003154 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003155 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3156 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003157 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003158 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003159 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003160};
3161
3162static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003163 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003164 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003165 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3166 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003167 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3168 .phy_read = mv88e6xxx_g2_smi_phy_read,
3169 .phy_write = mv88e6xxx_g2_smi_phy_write,
3170 .port_set_link = mv88e6xxx_port_set_link,
3171 .port_set_duplex = mv88e6xxx_port_set_duplex,
3172 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3173 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003174 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003175 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003176 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003177 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003178 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003179 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003180 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003181 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003182 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003183 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003184 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003185 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003186 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3187 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003188 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003189 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3190 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003191 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003192 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003193 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003194 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003195 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3196 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003197 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003198 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003199 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003200};
3201
Vivien Didelotf81ec902016-05-09 13:22:58 -04003202static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3203 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003204 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003205 .family = MV88E6XXX_FAMILY_6097,
3206 .name = "Marvell 88E6085",
3207 .num_databases = 4096,
3208 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003209 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003210 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003211 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003212 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003213 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003214 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003215 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003216 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003217 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003218 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003219 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003220 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003221 },
3222
3223 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003224 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003225 .family = MV88E6XXX_FAMILY_6095,
3226 .name = "Marvell 88E6095/88E6095F",
3227 .num_databases = 256,
3228 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003229 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003230 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003231 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003232 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003233 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003234 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003235 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003236 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003237 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003238 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003239 },
3240
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003241 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003242 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003243 .family = MV88E6XXX_FAMILY_6097,
3244 .name = "Marvell 88E6097/88E6097F",
3245 .num_databases = 4096,
3246 .num_ports = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003247 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003248 .port_base_addr = 0x10,
3249 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003250 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003251 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003252 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003253 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003254 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003255 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003256 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003257 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003258 .ops = &mv88e6097_ops,
3259 },
3260
Vivien Didelotf81ec902016-05-09 13:22:58 -04003261 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003262 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003263 .family = MV88E6XXX_FAMILY_6165,
3264 .name = "Marvell 88E6123",
3265 .num_databases = 4096,
3266 .num_ports = 3,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003267 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003268 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003269 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003270 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003271 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003272 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003273 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003274 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003275 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003276 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003277 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003278 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003279 },
3280
3281 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003282 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003283 .family = MV88E6XXX_FAMILY_6185,
3284 .name = "Marvell 88E6131",
3285 .num_databases = 256,
3286 .num_ports = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003287 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003288 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003289 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003290 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003291 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003292 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003293 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003294 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003295 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003296 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003297 },
3298
Vivien Didelot990e27b2017-03-28 13:50:32 -04003299 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003300 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003301 .family = MV88E6XXX_FAMILY_6341,
3302 .name = "Marvell 88E6341",
3303 .num_databases = 4096,
3304 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003305 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003306 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003307 .port_base_addr = 0x10,
3308 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003309 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003310 .age_time_coeff = 3750,
3311 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003312 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003313 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003314 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003315 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003316 .ops = &mv88e6141_ops,
3317 },
3318
Vivien Didelotf81ec902016-05-09 13:22:58 -04003319 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003320 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003321 .family = MV88E6XXX_FAMILY_6165,
3322 .name = "Marvell 88E6161",
3323 .num_databases = 4096,
3324 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003325 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003326 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003327 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003328 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003329 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003330 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003331 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003332 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003333 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003334 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003335 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003336 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003337 },
3338
3339 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003340 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003341 .family = MV88E6XXX_FAMILY_6165,
3342 .name = "Marvell 88E6165",
3343 .num_databases = 4096,
3344 .num_ports = 6,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003345 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003346 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003347 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003348 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003349 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003350 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003351 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003352 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003353 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003354 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003355 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003356 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003357 },
3358
3359 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003360 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003361 .family = MV88E6XXX_FAMILY_6351,
3362 .name = "Marvell 88E6171",
3363 .num_databases = 4096,
3364 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003365 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003366 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003367 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003368 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003369 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003370 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003371 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003372 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003373 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003374 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003375 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003376 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003377 },
3378
3379 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003380 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003381 .family = MV88E6XXX_FAMILY_6352,
3382 .name = "Marvell 88E6172",
3383 .num_databases = 4096,
3384 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003385 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003386 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003387 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003388 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003389 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003390 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003391 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003392 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003393 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003394 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003395 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003396 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003397 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003398 },
3399
3400 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003401 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003402 .family = MV88E6XXX_FAMILY_6351,
3403 .name = "Marvell 88E6175",
3404 .num_databases = 4096,
3405 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003406 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003407 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003408 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003409 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003410 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003411 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003412 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003413 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003414 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003415 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003416 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003417 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003418 },
3419
3420 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003421 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003422 .family = MV88E6XXX_FAMILY_6352,
3423 .name = "Marvell 88E6176",
3424 .num_databases = 4096,
3425 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003426 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003427 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003428 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003429 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003430 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003431 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003432 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003433 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003434 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003435 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003436 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003437 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003438 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003439 },
3440
3441 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003442 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003443 .family = MV88E6XXX_FAMILY_6185,
3444 .name = "Marvell 88E6185",
3445 .num_databases = 256,
3446 .num_ports = 10,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003447 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003448 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003449 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003450 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003451 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003452 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003453 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003454 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003455 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003456 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003457 },
3458
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003459 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003460 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003461 .family = MV88E6XXX_FAMILY_6390,
3462 .name = "Marvell 88E6190",
3463 .num_databases = 4096,
3464 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003465 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003466 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003467 .port_base_addr = 0x0,
3468 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003469 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003470 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003471 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003472 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003473 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003474 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003475 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003476 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003477 .ops = &mv88e6190_ops,
3478 },
3479
3480 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003481 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003482 .family = MV88E6XXX_FAMILY_6390,
3483 .name = "Marvell 88E6190X",
3484 .num_databases = 4096,
3485 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003486 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003487 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003488 .port_base_addr = 0x0,
3489 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003490 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003491 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003492 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003493 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003494 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003495 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003496 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003497 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003498 .ops = &mv88e6190x_ops,
3499 },
3500
3501 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003502 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003503 .family = MV88E6XXX_FAMILY_6390,
3504 .name = "Marvell 88E6191",
3505 .num_databases = 4096,
3506 .num_ports = 11, /* 10 + Z80 */
Vivien Didelot931d1822017-05-01 14:05:27 -04003507 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003508 .port_base_addr = 0x0,
3509 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003510 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003511 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003512 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003513 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003514 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003515 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003516 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003517 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003518 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003519 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003520 },
3521
Vivien Didelotf81ec902016-05-09 13:22:58 -04003522 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003523 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003524 .family = MV88E6XXX_FAMILY_6352,
3525 .name = "Marvell 88E6240",
3526 .num_databases = 4096,
3527 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003528 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003529 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003530 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003531 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003532 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003533 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003534 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003535 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003536 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003537 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003538 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003539 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003540 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003541 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003542 },
3543
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003544 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003545 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003546 .family = MV88E6XXX_FAMILY_6390,
3547 .name = "Marvell 88E6290",
3548 .num_databases = 4096,
3549 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003550 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003551 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003552 .port_base_addr = 0x0,
3553 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003554 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003555 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003556 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003557 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003558 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003559 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003560 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003561 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003562 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003563 .ops = &mv88e6290_ops,
3564 },
3565
Vivien Didelotf81ec902016-05-09 13:22:58 -04003566 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003567 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003568 .family = MV88E6XXX_FAMILY_6320,
3569 .name = "Marvell 88E6320",
3570 .num_databases = 4096,
3571 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003572 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003573 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003574 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003575 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003576 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003577 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003578 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003579 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003580 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003581 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003582 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003583 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003584 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003585 },
3586
3587 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003588 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003589 .family = MV88E6XXX_FAMILY_6320,
3590 .name = "Marvell 88E6321",
3591 .num_databases = 4096,
3592 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003593 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003594 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003595 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003596 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003597 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003598 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003599 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003600 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003601 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003602 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003603 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003604 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003605 },
3606
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003607 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003608 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003609 .family = MV88E6XXX_FAMILY_6341,
3610 .name = "Marvell 88E6341",
3611 .num_databases = 4096,
3612 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003613 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003614 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003615 .port_base_addr = 0x10,
3616 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003617 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003618 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003619 .atu_move_port_mask = 0x1f,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003620 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003621 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003622 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003623 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003624 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003625 .ops = &mv88e6341_ops,
3626 },
3627
Vivien Didelotf81ec902016-05-09 13:22:58 -04003628 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003629 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003630 .family = MV88E6XXX_FAMILY_6351,
3631 .name = "Marvell 88E6350",
3632 .num_databases = 4096,
3633 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003634 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003635 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003636 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003637 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003638 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003639 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003640 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003641 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003642 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003643 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003644 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003645 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003646 },
3647
3648 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003649 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003650 .family = MV88E6XXX_FAMILY_6351,
3651 .name = "Marvell 88E6351",
3652 .num_databases = 4096,
3653 .num_ports = 7,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003654 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003655 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003656 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003657 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003658 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003659 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003660 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003661 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003662 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003663 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003664 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003665 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003666 },
3667
3668 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003669 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003670 .family = MV88E6XXX_FAMILY_6352,
3671 .name = "Marvell 88E6352",
3672 .num_databases = 4096,
3673 .num_ports = 7,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003674 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003675 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003676 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003677 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003678 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003679 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003680 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003681 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003682 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003683 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003684 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003685 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003686 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003687 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003688 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003689 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003690 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003691 .family = MV88E6XXX_FAMILY_6390,
3692 .name = "Marvell 88E6390",
3693 .num_databases = 4096,
3694 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003695 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003696 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003697 .port_base_addr = 0x0,
3698 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003699 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003700 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003701 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003702 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003703 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003704 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003705 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003706 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003707 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003708 .ops = &mv88e6390_ops,
3709 },
3710 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003711 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003712 .family = MV88E6XXX_FAMILY_6390,
3713 .name = "Marvell 88E6390X",
3714 .num_databases = 4096,
3715 .num_ports = 11, /* 10 + Z80 */
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003716 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003717 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003718 .port_base_addr = 0x0,
3719 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003720 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003721 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003722 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003723 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003724 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003725 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003726 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003727 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003728 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003729 .ops = &mv88e6390x_ops,
3730 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003731};
3732
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003733static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003734{
Vivien Didelota439c062016-04-17 13:23:58 -04003735 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003736
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003737 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3738 if (mv88e6xxx_table[i].prod_num == prod_num)
3739 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003740
Vivien Didelotb9b37712015-10-30 19:39:48 -04003741 return NULL;
3742}
3743
Vivien Didelotfad09c72016-06-21 12:28:20 -04003744static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003745{
3746 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003747 unsigned int prod_num, rev;
3748 u16 id;
3749 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003750
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003751 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003752 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003753 mutex_unlock(&chip->reg_lock);
3754 if (err)
3755 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003756
Vivien Didelot107fcc12017-06-12 12:37:36 -04003757 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3758 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003759
3760 info = mv88e6xxx_lookup_info(prod_num);
3761 if (!info)
3762 return -ENODEV;
3763
Vivien Didelotcaac8542016-06-20 13:14:09 -04003764 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003765 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003766
Vivien Didelotca070c12016-09-02 14:45:34 -04003767 err = mv88e6xxx_g2_require(chip);
3768 if (err)
3769 return err;
3770
Vivien Didelotfad09c72016-06-21 12:28:20 -04003771 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3772 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003773
3774 return 0;
3775}
3776
Vivien Didelotfad09c72016-06-21 12:28:20 -04003777static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003778{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003779 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003780
Vivien Didelotfad09c72016-06-21 12:28:20 -04003781 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3782 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003783 return NULL;
3784
Vivien Didelotfad09c72016-06-21 12:28:20 -04003785 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003786
Vivien Didelotfad09c72016-06-21 12:28:20 -04003787 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003788 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003789
Vivien Didelotfad09c72016-06-21 12:28:20 -04003790 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003791}
3792
Vivien Didelotfad09c72016-06-21 12:28:20 -04003793static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003794 struct mii_bus *bus, int sw_addr)
3795{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003796 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003797 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003798 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003799 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003800 else
3801 return -EINVAL;
3802
Vivien Didelotfad09c72016-06-21 12:28:20 -04003803 chip->bus = bus;
3804 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003805
3806 return 0;
3807}
3808
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08003809static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
3810 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02003811{
Vivien Didelot04bed142016-08-31 18:06:13 -04003812 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003813
Andrew Lunn443d5a12016-12-03 04:35:18 +01003814 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02003815}
3816
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003817#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003818static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
3819 struct device *host_dev, int sw_addr,
3820 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02003821{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003822 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003823 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003824 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003825
Vivien Didelota439c062016-04-17 13:23:58 -04003826 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02003827 if (!bus)
3828 return NULL;
3829
Vivien Didelotfad09c72016-06-21 12:28:20 -04003830 chip = mv88e6xxx_alloc_chip(dsa_dev);
3831 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003832 return NULL;
3833
Vivien Didelotcaac8542016-06-20 13:14:09 -04003834 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003835 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04003836
Vivien Didelotfad09c72016-06-21 12:28:20 -04003837 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003838 if (err)
3839 goto free;
3840
Vivien Didelotfad09c72016-06-21 12:28:20 -04003841 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003842 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003843 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04003844
Andrew Lunndc30c352016-10-16 19:56:49 +02003845 mutex_lock(&chip->reg_lock);
3846 err = mv88e6xxx_switch_reset(chip);
3847 mutex_unlock(&chip->reg_lock);
3848 if (err)
3849 goto free;
3850
Vivien Didelote57e5e72016-08-15 17:19:00 -04003851 mv88e6xxx_phy_init(chip);
3852
Andrew Lunna3c53be52017-01-24 14:53:50 +01003853 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02003854 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04003855 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02003856
Vivien Didelotfad09c72016-06-21 12:28:20 -04003857 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04003858
Vivien Didelotfad09c72016-06-21 12:28:20 -04003859 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04003860free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04003861 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04003862
3863 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02003864}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003865#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02003866
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003867static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003868 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003869{
3870 /* We don't need any dynamic resource from the kernel (yet),
3871 * so skip the prepare phase.
3872 */
3873
3874 return 0;
3875}
3876
3877static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05003878 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003879{
Vivien Didelot04bed142016-08-31 18:06:13 -04003880 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003881
3882 mutex_lock(&chip->reg_lock);
3883 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003884 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04003885 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
3886 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003887 mutex_unlock(&chip->reg_lock);
3888}
3889
3890static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
3891 const struct switchdev_obj_port_mdb *mdb)
3892{
Vivien Didelot04bed142016-08-31 18:06:13 -04003893 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003894 int err;
3895
3896 mutex_lock(&chip->reg_lock);
3897 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04003898 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003899 mutex_unlock(&chip->reg_lock);
3900
3901 return err;
3902}
3903
Florian Fainellia82f67a2017-01-08 14:52:08 -08003904static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003905#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02003906 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08003907#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02003908 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003909 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003910 .adjust_link = mv88e6xxx_adjust_link,
3911 .get_strings = mv88e6xxx_get_strings,
3912 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
3913 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02003914 .port_enable = mv88e6xxx_port_enable,
3915 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04003916 .get_mac_eee = mv88e6xxx_get_mac_eee,
3917 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003918 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003919 .get_eeprom = mv88e6xxx_get_eeprom,
3920 .set_eeprom = mv88e6xxx_set_eeprom,
3921 .get_regs_len = mv88e6xxx_get_regs_len,
3922 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003923 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003924 .port_bridge_join = mv88e6xxx_port_bridge_join,
3925 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
3926 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04003927 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003928 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
3929 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
3930 .port_vlan_add = mv88e6xxx_port_vlan_add,
3931 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003932 .port_fdb_add = mv88e6xxx_port_fdb_add,
3933 .port_fdb_del = mv88e6xxx_port_fdb_del,
3934 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04003935 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
3936 .port_mdb_add = mv88e6xxx_port_mdb_add,
3937 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04003938 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
3939 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003940 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
3941 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
3942 .port_txtstamp = mv88e6xxx_port_txtstamp,
3943 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
3944 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003945};
3946
Florian Fainelliab3d4082017-01-08 14:52:07 -08003947static struct dsa_switch_driver mv88e6xxx_switch_drv = {
3948 .ops = &mv88e6xxx_switch_ops,
3949};
3950
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08003951static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003952{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003953 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003954 struct dsa_switch *ds;
3955
Vivien Didelot73b12042017-03-30 17:37:10 -04003956 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003957 if (!ds)
3958 return -ENOMEM;
3959
Vivien Didelotfad09c72016-06-21 12:28:20 -04003960 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04003961 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04003962 ds->ageing_time_min = chip->info->age_time_coeff;
3963 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003964
3965 dev_set_drvdata(dev, ds);
3966
Vivien Didelot23c9ee42017-05-26 18:12:51 -04003967 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003968}
3969
Vivien Didelotfad09c72016-06-21 12:28:20 -04003970static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003971{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003972 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04003973}
3974
Vivien Didelot57d32312016-06-20 13:13:58 -04003975static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003976{
3977 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003978 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003979 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003980 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02003981 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02003982 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003983
Vivien Didelotcaac8542016-06-20 13:14:09 -04003984 compat_info = of_device_get_match_data(dev);
3985 if (!compat_info)
3986 return -EINVAL;
3987
Vivien Didelotfad09c72016-06-21 12:28:20 -04003988 chip = mv88e6xxx_alloc_chip(dev);
3989 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003990 return -ENOMEM;
3991
Vivien Didelotfad09c72016-06-21 12:28:20 -04003992 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04003993
Vivien Didelotfad09c72016-06-21 12:28:20 -04003994 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003995 if (err)
3996 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02003997
Andrew Lunnb4308f02016-11-21 23:26:55 +01003998 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
3999 if (IS_ERR(chip->reset))
4000 return PTR_ERR(chip->reset);
4001
Vivien Didelotfad09c72016-06-21 12:28:20 -04004002 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004003 if (err)
4004 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004005
Vivien Didelote57e5e72016-08-15 17:19:00 -04004006 mv88e6xxx_phy_init(chip);
4007
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004008 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004009 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004010 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004011
Andrew Lunndc30c352016-10-16 19:56:49 +02004012 mutex_lock(&chip->reg_lock);
4013 err = mv88e6xxx_switch_reset(chip);
4014 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004015 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004016 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004017
Andrew Lunndc30c352016-10-16 19:56:49 +02004018 chip->irq = of_irq_get(np, 0);
4019 if (chip->irq == -EPROBE_DEFER) {
4020 err = chip->irq;
4021 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004022 }
4023
Andrew Lunndc30c352016-10-16 19:56:49 +02004024 if (chip->irq > 0) {
4025 /* Has to be performed before the MDIO bus is created,
4026 * because the PHYs will link there interrupts to these
4027 * interrupt controllers
4028 */
4029 mutex_lock(&chip->reg_lock);
4030 err = mv88e6xxx_g1_irq_setup(chip);
4031 mutex_unlock(&chip->reg_lock);
4032
4033 if (err)
4034 goto out;
4035
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004036 if (chip->info->g2_irqs > 0) {
Andrew Lunndc30c352016-10-16 19:56:49 +02004037 err = mv88e6xxx_g2_irq_setup(chip);
4038 if (err)
4039 goto out_g1_irq;
4040 }
Andrew Lunn09776442018-01-14 02:32:44 +01004041
4042 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4043 if (err)
4044 goto out_g2_irq;
Andrew Lunn62eb1162018-01-14 02:32:45 +01004045
4046 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4047 if (err)
4048 goto out_g1_atu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004049 }
4050
Andrew Lunna3c53be52017-01-24 14:53:50 +01004051 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004052 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004053 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004054
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004055 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004056 if (err)
4057 goto out_mdio;
4058
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004059 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004060
4061out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004062 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004063out_g1_vtu_prob_irq:
Andrew Lunnae14caf2018-01-18 17:42:50 +01004064 if (chip->irq > 0)
4065 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004066out_g1_atu_prob_irq:
Andrew Lunnae14caf2018-01-18 17:42:50 +01004067 if (chip->irq > 0)
4068 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004069out_g2_irq:
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004070 if (chip->info->g2_irqs > 0 && chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004071 mv88e6xxx_g2_irq_free(chip);
4072out_g1_irq:
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004073 if (chip->irq > 0) {
4074 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004075 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn61f7c3f2016-11-20 20:14:19 +01004076 mutex_unlock(&chip->reg_lock);
4077 }
Andrew Lunndc30c352016-10-16 19:56:49 +02004078out:
4079 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004080}
4081
4082static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4083{
4084 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004085 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004086
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004087 if (chip->info->ptp_support) {
4088 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004089 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004090 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004091
Andrew Lunn930188c2016-08-22 16:01:03 +02004092 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004093 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004094 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004095
Andrew Lunn467126442016-11-20 20:14:15 +01004096 if (chip->irq > 0) {
Andrew Lunn62eb1162018-01-14 02:32:45 +01004097 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004098 mv88e6xxx_g1_atu_prob_irq_free(chip);
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004099 if (chip->info->g2_irqs > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004100 mv88e6xxx_g2_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004101 mutex_lock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004102 mv88e6xxx_g1_irq_free(chip);
Vivien Didelotb32ca442017-09-26 14:57:21 -04004103 mutex_unlock(&chip->reg_lock);
Andrew Lunn467126442016-11-20 20:14:15 +01004104 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004105}
4106
4107static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004108 {
4109 .compatible = "marvell,mv88e6085",
4110 .data = &mv88e6xxx_table[MV88E6085],
4111 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004112 {
4113 .compatible = "marvell,mv88e6190",
4114 .data = &mv88e6xxx_table[MV88E6190],
4115 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004116 { /* sentinel */ },
4117};
4118
4119MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4120
4121static struct mdio_driver mv88e6xxx_driver = {
4122 .probe = mv88e6xxx_probe,
4123 .remove = mv88e6xxx_remove,
4124 .mdiodrv.driver = {
4125 .name = "mv88e6085",
4126 .of_match_table = mv88e6xxx_of_match,
4127 },
4128};
4129
Ben Hutchings98e67302011-11-25 14:36:19 +00004130static int __init mv88e6xxx_init(void)
4131{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004132 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004133 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004134}
4135module_init(mv88e6xxx_init);
4136
4137static void __exit mv88e6xxx_cleanup(void)
4138{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004139 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004140 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004141}
4142module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004143
4144MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4145MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4146MODULE_LICENSE("GPL");