blob: a13a7005ffa0c6c9cc03069090e585f89d6db8b1 [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
Andrew Lunn294d7112018-02-22 22:58:32 +0100256static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200257{
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 unsigned int nhandled = 0;
259 unsigned int sub_irq;
260 unsigned int n;
261 u16 reg;
262 int err;
263
264 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400265 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200266 mutex_unlock(&chip->reg_lock);
267
268 if (err)
269 goto out;
270
271 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
272 if (reg & (1 << n)) {
273 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
274 handle_nested_irq(sub_irq);
275 ++nhandled;
276 }
277 }
278out:
279 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
280}
281
Andrew Lunn294d7112018-02-22 22:58:32 +0100282static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
283{
284 struct mv88e6xxx_chip *chip = dev_id;
285
286 return mv88e6xxx_g1_irq_thread_work(chip);
287}
288
Andrew Lunndc30c352016-10-16 19:56:49 +0200289static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
290{
291 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
292
293 mutex_lock(&chip->reg_lock);
294}
295
296static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
297{
298 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
299 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
300 u16 reg;
301 int err;
302
Vivien Didelotd77f4322017-06-15 12:14:03 -0400303 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200304 if (err)
305 goto out;
306
307 reg &= ~mask;
308 reg |= (~chip->g1_irq.masked & mask);
309
Vivien Didelotd77f4322017-06-15 12:14:03 -0400310 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200311 if (err)
312 goto out;
313
314out:
315 mutex_unlock(&chip->reg_lock);
316}
317
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530318static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200319 .name = "mv88e6xxx-g1",
320 .irq_mask = mv88e6xxx_g1_irq_mask,
321 .irq_unmask = mv88e6xxx_g1_irq_unmask,
322 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
323 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
324};
325
326static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
327 unsigned int irq,
328 irq_hw_number_t hwirq)
329{
330 struct mv88e6xxx_chip *chip = d->host_data;
331
332 irq_set_chip_data(irq, d->host_data);
333 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
334 irq_set_noprobe(irq);
335
336 return 0;
337}
338
339static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
340 .map = mv88e6xxx_g1_irq_domain_map,
341 .xlate = irq_domain_xlate_twocell,
342};
343
Andrew Lunn294d7112018-02-22 22:58:32 +0100344static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200345{
346 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100347 u16 mask;
348
Vivien Didelotd77f4322017-06-15 12:14:03 -0400349 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100350 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400351 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100352
Andreas Färber5edef2f2016-11-27 23:26:28 +0100353 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100354 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200355 irq_dispose_mapping(virq);
356 }
357
Andrew Lunna3db3d32016-11-20 20:14:14 +0100358 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200359}
360
Andrew Lunn294d7112018-02-22 22:58:32 +0100361static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
362{
Andrew Lunnb19e5c12018-03-08 21:21:36 +0100363 mv88e6xxx_g1_irq_free_common(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100364
365 free_irq(chip->irq, chip);
366}
367
368static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200369{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100370 int err, irq, virq;
371 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200372
373 chip->g1_irq.nirqs = chip->info->g1_irqs;
374 chip->g1_irq.domain = irq_domain_add_simple(
375 NULL, chip->g1_irq.nirqs, 0,
376 &mv88e6xxx_g1_irq_domain_ops, chip);
377 if (!chip->g1_irq.domain)
378 return -ENOMEM;
379
380 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
381 irq_create_mapping(chip->g1_irq.domain, irq);
382
383 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
384 chip->g1_irq.masked = ~0;
385
Vivien Didelotd77f4322017-06-15 12:14:03 -0400386 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200387 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100388 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200389
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100390 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200391
Vivien Didelotd77f4322017-06-15 12:14:03 -0400392 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200393 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100394 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200395
396 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400397 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200398 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100399 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200400
Andrew Lunndc30c352016-10-16 19:56:49 +0200401 return 0;
402
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100403out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100404 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400405 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100406
407out_mapping:
408 for (irq = 0; irq < 16; irq++) {
409 virq = irq_find_mapping(chip->g1_irq.domain, irq);
410 irq_dispose_mapping(virq);
411 }
412
413 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200414
415 return err;
416}
417
Andrew Lunn294d7112018-02-22 22:58:32 +0100418static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
419{
420 int err;
421
422 err = mv88e6xxx_g1_irq_setup_common(chip);
423 if (err)
424 return err;
425
426 err = request_threaded_irq(chip->irq, NULL,
427 mv88e6xxx_g1_irq_thread_fn,
Andrew Lunn422a9fd62018-03-25 23:43:14 +0200428 IRQF_ONESHOT,
Andrew Lunn294d7112018-02-22 22:58:32 +0100429 dev_name(chip->dev), chip);
430 if (err)
431 mv88e6xxx_g1_irq_free_common(chip);
432
433 return err;
434}
435
436static void mv88e6xxx_irq_poll(struct kthread_work *work)
437{
438 struct mv88e6xxx_chip *chip = container_of(work,
439 struct mv88e6xxx_chip,
440 irq_poll_work.work);
441 mv88e6xxx_g1_irq_thread_work(chip);
442
443 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
444 msecs_to_jiffies(100));
445}
446
447static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
448{
449 int err;
450
451 err = mv88e6xxx_g1_irq_setup_common(chip);
452 if (err)
453 return err;
454
455 kthread_init_delayed_work(&chip->irq_poll_work,
456 mv88e6xxx_irq_poll);
457
458 chip->kworker = kthread_create_worker(0, dev_name(chip->dev));
459 if (IS_ERR(chip->kworker))
460 return PTR_ERR(chip->kworker);
461
462 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
463 msecs_to_jiffies(100));
464
465 return 0;
466}
467
468static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
469{
Andrew Lunn71f74ae2018-03-25 23:43:15 +0200470 mv88e6xxx_g1_irq_free_common(chip);
471
Andrew Lunn294d7112018-02-22 22:58:32 +0100472 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
473 kthread_destroy_worker(chip->kworker);
474}
475
Vivien Didelotec561272016-09-02 14:45:33 -0400476int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400477{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200478 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400479
Andrew Lunn6441e6692016-08-19 00:01:55 +0200480 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400481 u16 val;
482 int err;
483
484 err = mv88e6xxx_read(chip, addr, reg, &val);
485 if (err)
486 return err;
487
488 if (!(val & mask))
489 return 0;
490
491 usleep_range(1000, 2000);
492 }
493
Andrew Lunn30853552016-08-19 00:01:57 +0200494 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400495 return -ETIMEDOUT;
496}
497
Vivien Didelotf22ab642016-07-18 20:45:31 -0400498/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400499int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400500{
501 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200502 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400503
504 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200505 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
506 if (err)
507 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400508
509 /* Set the Update bit to trigger a write operation */
510 val = BIT(15) | update;
511
512 return mv88e6xxx_write(chip, addr, reg, val);
513}
514
Vivien Didelotd78343d2016-11-04 03:23:36 +0100515static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
516 int link, int speed, int duplex,
517 phy_interface_t mode)
518{
519 int err;
520
521 if (!chip->info->ops->port_set_link)
522 return 0;
523
524 /* Port's MAC control must not be changed unless the link is down */
525 err = chip->info->ops->port_set_link(chip, port, 0);
526 if (err)
527 return err;
528
529 if (chip->info->ops->port_set_speed) {
530 err = chip->info->ops->port_set_speed(chip, port, speed);
531 if (err && err != -EOPNOTSUPP)
532 goto restore_link;
533 }
534
535 if (chip->info->ops->port_set_duplex) {
536 err = chip->info->ops->port_set_duplex(chip, port, duplex);
537 if (err && err != -EOPNOTSUPP)
538 goto restore_link;
539 }
540
541 if (chip->info->ops->port_set_rgmii_delay) {
542 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
543 if (err && err != -EOPNOTSUPP)
544 goto restore_link;
545 }
546
Andrew Lunnf39908d2017-02-04 20:02:50 +0100547 if (chip->info->ops->port_set_cmode) {
548 err = chip->info->ops->port_set_cmode(chip, port, mode);
549 if (err && err != -EOPNOTSUPP)
550 goto restore_link;
551 }
552
Vivien Didelotd78343d2016-11-04 03:23:36 +0100553 err = 0;
554restore_link:
555 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400556 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100557
558 return err;
559}
560
Andrew Lunndea87022015-08-31 15:56:47 +0200561/* We expect the switch to perform auto negotiation if there is a real
562 * phy. However, in the case of a fixed link phy, we force the port
563 * settings from the fixed link settings.
564 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400565static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
566 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200567{
Vivien Didelot04bed142016-08-31 18:06:13 -0400568 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200569 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200570
571 if (!phy_is_pseudo_fixed_link(phydev))
572 return;
573
Vivien Didelotfad09c72016-06-21 12:28:20 -0400574 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100575 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
576 phydev->duplex, phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400577 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100578
579 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400580 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200581}
582
Andrew Lunna605a0f2016-11-21 23:26:58 +0100583static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000584{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100585 if (!chip->info->ops->stats_snapshot)
586 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000587
Andrew Lunna605a0f2016-11-21 23:26:58 +0100588 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000589}
590
Andrew Lunne413e7e2015-04-02 04:06:38 +0200591static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100592 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
593 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
594 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
595 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
596 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
597 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
598 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
599 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
600 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
601 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
602 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
603 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
604 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
605 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
606 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
607 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
608 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
609 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
610 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
611 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
612 { "single", 4, 0x14, STATS_TYPE_BANK0, },
613 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
614 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
615 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
616 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
617 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
618 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
619 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
620 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
621 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
622 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
623 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
624 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
625 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
626 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
627 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
628 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
629 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
630 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
631 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
632 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
633 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
634 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
635 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
636 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
637 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
638 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
639 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
640 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
641 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
642 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
643 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
644 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
645 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
646 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
647 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
648 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
649 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
650 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200651};
652
Vivien Didelotfad09c72016-06-21 12:28:20 -0400653static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100654 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100655 int port, u16 bank1_select,
656 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200657{
Andrew Lunn80c46272015-06-20 18:42:30 +0200658 u32 low;
659 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100660 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200661 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200662 u64 value;
663
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100664 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100665 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200666 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
667 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800668 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200669
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200670 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100671 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200672 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
673 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800674 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200675 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200676 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100677 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100678 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100679 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100680 /* fall through */
681 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100682 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100683 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100684 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100685 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500686 break;
687 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800688 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200689 }
690 value = (((u64)high) << 16) | low;
691 return value;
692}
693
Andrew Lunn436fe172018-03-01 02:02:29 +0100694static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
695 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100696{
697 struct mv88e6xxx_hw_stat *stat;
698 int i, j;
699
700 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
701 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100702 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100703 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
704 ETH_GSTRING_LEN);
705 j++;
706 }
707 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100708
709 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100710}
711
Andrew Lunn436fe172018-03-01 02:02:29 +0100712static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
713 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100714{
Andrew Lunn436fe172018-03-01 02:02:29 +0100715 return mv88e6xxx_stats_get_strings(chip, data,
716 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100717}
718
Andrew Lunn436fe172018-03-01 02:02:29 +0100719static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
720 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100721{
Andrew Lunn436fe172018-03-01 02:02:29 +0100722 return mv88e6xxx_stats_get_strings(chip, data,
723 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100724}
725
Andrew Lunn65f60e42018-03-28 23:50:28 +0200726static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
727 "atu_member_violation",
728 "atu_miss_violation",
729 "atu_full_violation",
730 "vtu_member_violation",
731 "vtu_miss_violation",
732};
733
734static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
735{
736 unsigned int i;
737
738 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
739 strlcpy(data + i * ETH_GSTRING_LEN,
740 mv88e6xxx_atu_vtu_stats_strings[i],
741 ETH_GSTRING_LEN);
742}
743
Andrew Lunndfafe442016-11-21 23:27:02 +0100744static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700745 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100746{
Vivien Didelot04bed142016-08-31 18:06:13 -0400747 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100748 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100749
Florian Fainelli89f09042018-04-25 12:12:50 -0700750 if (stringset != ETH_SS_STATS)
751 return;
752
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100753 mutex_lock(&chip->reg_lock);
754
Andrew Lunndfafe442016-11-21 23:27:02 +0100755 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100756 count = chip->info->ops->stats_get_strings(chip, data);
757
758 if (chip->info->ops->serdes_get_strings) {
759 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200760 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100761 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100762
Andrew Lunn65f60e42018-03-28 23:50:28 +0200763 data += count * ETH_GSTRING_LEN;
764 mv88e6xxx_atu_vtu_get_strings(data);
765
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100766 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100767}
768
769static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
770 int types)
771{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100772 struct mv88e6xxx_hw_stat *stat;
773 int i, j;
774
775 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
776 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100777 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100778 j++;
779 }
780 return j;
781}
782
Andrew Lunndfafe442016-11-21 23:27:02 +0100783static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
784{
785 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
786 STATS_TYPE_PORT);
787}
788
789static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
790{
791 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
792 STATS_TYPE_BANK1);
793}
794
Florian Fainelli89f09042018-04-25 12:12:50 -0700795static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100796{
797 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100798 int serdes_count = 0;
799 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100800
Florian Fainelli89f09042018-04-25 12:12:50 -0700801 if (sset != ETH_SS_STATS)
802 return 0;
803
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100804 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100805 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100806 count = chip->info->ops->stats_get_sset_count(chip);
807 if (count < 0)
808 goto out;
809
810 if (chip->info->ops->serdes_get_sset_count)
811 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
812 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200813 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100814 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200815 goto out;
816 }
817 count += serdes_count;
818 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
819
Andrew Lunn436fe172018-03-01 02:02:29 +0100820out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100821 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100822
Andrew Lunn436fe172018-03-01 02:02:29 +0100823 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100824}
825
Andrew Lunn436fe172018-03-01 02:02:29 +0100826static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
827 uint64_t *data, int types,
828 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100829{
830 struct mv88e6xxx_hw_stat *stat;
831 int i, j;
832
833 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
834 stat = &mv88e6xxx_hw_stats[i];
835 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +0100836 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100837 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
838 bank1_select,
839 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +0100840 mutex_unlock(&chip->reg_lock);
841
Andrew Lunn052f9472016-11-21 23:27:03 +0100842 j++;
843 }
844 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100845 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100846}
847
Andrew Lunn436fe172018-03-01 02:02:29 +0100848static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
849 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100850{
851 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100852 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400853 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100854}
855
Andrew Lunn436fe172018-03-01 02:02:29 +0100856static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
857 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100858{
859 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100860 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400861 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
862 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100863}
864
Andrew Lunn436fe172018-03-01 02:02:29 +0100865static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
866 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100867{
868 return mv88e6xxx_stats_get_stats(chip, port, data,
869 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400870 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
871 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100872}
873
Andrew Lunn65f60e42018-03-28 23:50:28 +0200874static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
875 uint64_t *data)
876{
877 *data++ = chip->ports[port].atu_member_violation;
878 *data++ = chip->ports[port].atu_miss_violation;
879 *data++ = chip->ports[port].atu_full_violation;
880 *data++ = chip->ports[port].vtu_member_violation;
881 *data++ = chip->ports[port].vtu_miss_violation;
882}
883
Andrew Lunn052f9472016-11-21 23:27:03 +0100884static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
885 uint64_t *data)
886{
Andrew Lunn436fe172018-03-01 02:02:29 +0100887 int count = 0;
888
Andrew Lunn052f9472016-11-21 23:27:03 +0100889 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100890 count = chip->info->ops->stats_get_stats(chip, port, data);
891
Andrew Lunn65f60e42018-03-28 23:50:28 +0200892 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +0100893 if (chip->info->ops->serdes_get_stats) {
894 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200895 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100896 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200897 data += count;
898 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
899 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +0100900}
901
Vivien Didelotf81ec902016-05-09 13:22:58 -0400902static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
903 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000904{
Vivien Didelot04bed142016-08-31 18:06:13 -0400905 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000906 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000907
Vivien Didelotfad09c72016-06-21 12:28:20 -0400908 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000909
Andrew Lunna605a0f2016-11-21 23:26:58 +0100910 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +0100911 mutex_unlock(&chip->reg_lock);
912
913 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000914 return;
Andrew Lunn052f9472016-11-21 23:27:03 +0100915
916 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000917
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000918}
Ben Hutchings98e67302011-11-25 14:36:19 +0000919
Andrew Lunnde2273872016-11-21 23:27:01 +0100920static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
921{
922 if (chip->info->ops->stats_set_histogram)
923 return chip->info->ops->stats_set_histogram(chip);
924
925 return 0;
926}
927
Vivien Didelotf81ec902016-05-09 13:22:58 -0400928static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700929{
930 return 32 * sizeof(u16);
931}
932
Vivien Didelotf81ec902016-05-09 13:22:58 -0400933static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
934 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700935{
Vivien Didelot04bed142016-08-31 18:06:13 -0400936 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200937 int err;
938 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700939 u16 *p = _p;
940 int i;
941
942 regs->version = 0;
943
944 memset(p, 0xff, 32 * sizeof(u16));
945
Vivien Didelotfad09c72016-06-21 12:28:20 -0400946 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -0400947
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700948 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700949
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200950 err = mv88e6xxx_port_read(chip, port, i, &reg);
951 if (!err)
952 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700953 }
Vivien Didelot23062512016-05-09 13:22:45 -0400954
Vivien Didelotfad09c72016-06-21 12:28:20 -0400955 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700956}
957
Vivien Didelot08f50062017-08-01 16:32:41 -0400958static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
959 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800960{
Vivien Didelot5480db62017-08-01 16:32:40 -0400961 /* Nothing to do on the port's MAC */
962 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800963}
964
Vivien Didelot08f50062017-08-01 16:32:41 -0400965static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
966 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -0800967{
Vivien Didelot5480db62017-08-01 16:32:40 -0400968 /* Nothing to do on the port's MAC */
969 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -0800970}
971
Vivien Didelote5887a22017-03-30 17:37:11 -0400972static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -0700973{
Vivien Didelote5887a22017-03-30 17:37:11 -0400974 struct dsa_switch *ds = NULL;
975 struct net_device *br;
976 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500977 int i;
978
Vivien Didelote5887a22017-03-30 17:37:11 -0400979 if (dev < DSA_MAX_SWITCHES)
980 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -0500981
Vivien Didelote5887a22017-03-30 17:37:11 -0400982 /* Prevent frames from unknown switch or port */
983 if (!ds || port >= ds->num_ports)
984 return 0;
985
986 /* Frames from DSA links and CPU ports can egress any local port */
987 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
988 return mv88e6xxx_port_mask(chip);
989
990 br = ds->ports[port].bridge_dev;
991 pvlan = 0;
992
993 /* Frames from user ports can egress any local DSA links and CPU ports,
994 * as well as any local member of their bridge group.
995 */
996 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
997 if (dsa_is_cpu_port(chip->ds, i) ||
998 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -0400999 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001000 pvlan |= BIT(i);
1001
1002 return pvlan;
1003}
1004
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001005static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001006{
1007 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001008
1009 /* prevent frames from going back out of the port they came in on */
1010 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001011
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001012 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001013}
1014
Vivien Didelotf81ec902016-05-09 13:22:58 -04001015static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1016 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001017{
Vivien Didelot04bed142016-08-31 18:06:13 -04001018 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001019 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001020
Vivien Didelotfad09c72016-06-21 12:28:20 -04001021 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001022 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001023 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001024
1025 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001026 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001027}
1028
Vivien Didelot9e907d72017-07-17 13:03:43 -04001029static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1030{
1031 if (chip->info->ops->pot_clear)
1032 return chip->info->ops->pot_clear(chip);
1033
1034 return 0;
1035}
1036
Vivien Didelot51c901a2017-07-17 13:03:41 -04001037static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1038{
1039 if (chip->info->ops->mgmt_rsvd2cpu)
1040 return chip->info->ops->mgmt_rsvd2cpu(chip);
1041
1042 return 0;
1043}
1044
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001045static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1046{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001047 int err;
1048
Vivien Didelotdaefc942017-03-11 16:12:54 -05001049 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1050 if (err)
1051 return err;
1052
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001053 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1054 if (err)
1055 return err;
1056
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001057 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1058}
1059
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001060static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1061{
1062 int port;
1063 int err;
1064
1065 if (!chip->info->ops->irl_init_all)
1066 return 0;
1067
1068 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1069 /* Disable ingress rate limiting by resetting all per port
1070 * ingress rate limit resources to their initial state.
1071 */
1072 err = chip->info->ops->irl_init_all(chip, port);
1073 if (err)
1074 return err;
1075 }
1076
1077 return 0;
1078}
1079
Vivien Didelot04a69a12017-10-13 14:18:05 -04001080static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1081{
1082 if (chip->info->ops->set_switch_mac) {
1083 u8 addr[ETH_ALEN];
1084
1085 eth_random_addr(addr);
1086
1087 return chip->info->ops->set_switch_mac(chip, addr);
1088 }
1089
1090 return 0;
1091}
1092
Vivien Didelot17a15942017-03-30 17:37:09 -04001093static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1094{
1095 u16 pvlan = 0;
1096
1097 if (!mv88e6xxx_has_pvt(chip))
1098 return -EOPNOTSUPP;
1099
1100 /* Skip the local source device, which uses in-chip port VLAN */
1101 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001102 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001103
1104 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1105}
1106
Vivien Didelot81228992017-03-30 17:37:08 -04001107static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1108{
Vivien Didelot17a15942017-03-30 17:37:09 -04001109 int dev, port;
1110 int err;
1111
Vivien Didelot81228992017-03-30 17:37:08 -04001112 if (!mv88e6xxx_has_pvt(chip))
1113 return 0;
1114
1115 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1116 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1117 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001118 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1119 if (err)
1120 return err;
1121
1122 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1123 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1124 err = mv88e6xxx_pvt_map(chip, dev, port);
1125 if (err)
1126 return err;
1127 }
1128 }
1129
1130 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001131}
1132
Vivien Didelot749efcb2016-09-22 16:49:24 -04001133static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1134{
1135 struct mv88e6xxx_chip *chip = ds->priv;
1136 int err;
1137
1138 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001139 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001140 mutex_unlock(&chip->reg_lock);
1141
1142 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001143 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001144}
1145
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001146static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1147{
1148 if (!chip->info->max_vid)
1149 return 0;
1150
1151 return mv88e6xxx_g1_vtu_flush(chip);
1152}
1153
Vivien Didelotf1394b782017-05-01 14:05:22 -04001154static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1155 struct mv88e6xxx_vtu_entry *entry)
1156{
1157 if (!chip->info->ops->vtu_getnext)
1158 return -EOPNOTSUPP;
1159
1160 return chip->info->ops->vtu_getnext(chip, entry);
1161}
1162
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001163static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1164 struct mv88e6xxx_vtu_entry *entry)
1165{
1166 if (!chip->info->ops->vtu_loadpurge)
1167 return -EOPNOTSUPP;
1168
1169 return chip->info->ops->vtu_loadpurge(chip, entry);
1170}
1171
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001172static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001173{
1174 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001175 struct mv88e6xxx_vtu_entry vlan = {
1176 .vid = chip->info->max_vid,
1177 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001178 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001179
1180 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1181
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001182 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001183 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001184 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001185 if (err)
1186 return err;
1187
1188 set_bit(*fid, fid_bitmap);
1189 }
1190
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001191 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001192 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001193 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001194 if (err)
1195 return err;
1196
1197 if (!vlan.valid)
1198 break;
1199
1200 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001201 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001202
1203 /* The reset value 0x000 is used to indicate that multiple address
1204 * databases are not needed. Return the next positive available.
1205 */
1206 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001207 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001208 return -ENOSPC;
1209
1210 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001211 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001212}
1213
Vivien Didelot567aa592017-05-01 14:05:25 -04001214static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1215 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001216{
1217 int err;
1218
1219 if (!vid)
1220 return -EINVAL;
1221
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001222 entry->vid = vid - 1;
1223 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001224
Vivien Didelotf1394b782017-05-01 14:05:22 -04001225 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001226 if (err)
1227 return err;
1228
Vivien Didelot567aa592017-05-01 14:05:25 -04001229 if (entry->vid == vid && entry->valid)
1230 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001231
Vivien Didelot567aa592017-05-01 14:05:25 -04001232 if (new) {
1233 int i;
1234
1235 /* Initialize a fresh VLAN entry */
1236 memset(entry, 0, sizeof(*entry));
1237 entry->valid = true;
1238 entry->vid = vid;
1239
Vivien Didelot553a7682017-06-07 18:12:16 -04001240 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001241 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001242 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001243 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001244
1245 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001246 }
1247
Vivien Didelot567aa592017-05-01 14:05:25 -04001248 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1249 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001250}
1251
Vivien Didelotda9c3592016-02-12 12:09:40 -05001252static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1253 u16 vid_begin, u16 vid_end)
1254{
Vivien Didelot04bed142016-08-31 18:06:13 -04001255 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001256 struct mv88e6xxx_vtu_entry vlan = {
1257 .vid = vid_begin - 1,
1258 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001259 int i, err;
1260
Andrew Lunndb06ae412017-09-25 23:32:20 +02001261 /* DSA and CPU ports have to be members of multiple vlans */
1262 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1263 return 0;
1264
Vivien Didelotda9c3592016-02-12 12:09:40 -05001265 if (!vid_begin)
1266 return -EOPNOTSUPP;
1267
Vivien Didelotfad09c72016-06-21 12:28:20 -04001268 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001269
Vivien Didelotda9c3592016-02-12 12:09:40 -05001270 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001271 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001272 if (err)
1273 goto unlock;
1274
1275 if (!vlan.valid)
1276 break;
1277
1278 if (vlan.vid > vid_end)
1279 break;
1280
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001281 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001282 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1283 continue;
1284
Andrew Lunncd886462017-11-09 22:29:53 +01001285 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001286 continue;
1287
Vivien Didelotbd00e052017-05-01 14:05:11 -04001288 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001289 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001290 continue;
1291
Vivien Didelotc8652c82017-10-16 11:12:19 -04001292 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001293 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001294 break; /* same bridge, check next VLAN */
1295
Vivien Didelotc8652c82017-10-16 11:12:19 -04001296 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001297 continue;
1298
Andrew Lunn743fcc22017-11-09 22:29:54 +01001299 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1300 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001301 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001302 err = -EOPNOTSUPP;
1303 goto unlock;
1304 }
1305 } while (vlan.vid < vid_end);
1306
1307unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001308 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001309
1310 return err;
1311}
1312
Vivien Didelotf81ec902016-05-09 13:22:58 -04001313static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1314 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001315{
Vivien Didelot04bed142016-08-31 18:06:13 -04001316 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001317 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1318 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001319 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001320
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001321 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001322 return -EOPNOTSUPP;
1323
Vivien Didelotfad09c72016-06-21 12:28:20 -04001324 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001325 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001326 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001327
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001328 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001329}
1330
Vivien Didelot57d32312016-06-20 13:13:58 -04001331static int
1332mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001333 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001334{
Vivien Didelot04bed142016-08-31 18:06:13 -04001335 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001336 int err;
1337
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001338 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001339 return -EOPNOTSUPP;
1340
Vivien Didelotda9c3592016-02-12 12:09:40 -05001341 /* If the requested port doesn't belong to the same bridge as the VLAN
1342 * members, do not support it (yet) and fallback to software VLAN.
1343 */
1344 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1345 vlan->vid_end);
1346 if (err)
1347 return err;
1348
Vivien Didelot76e398a2015-11-01 12:33:55 -05001349 /* We don't need any dynamic resource from the kernel (yet),
1350 * so skip the prepare phase.
1351 */
1352 return 0;
1353}
1354
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001355static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1356 const unsigned char *addr, u16 vid,
1357 u8 state)
1358{
1359 struct mv88e6xxx_vtu_entry vlan;
1360 struct mv88e6xxx_atu_entry entry;
1361 int err;
1362
1363 /* Null VLAN ID corresponds to the port private database */
1364 if (vid == 0)
1365 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1366 else
1367 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1368 if (err)
1369 return err;
1370
1371 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1372 ether_addr_copy(entry.mac, addr);
1373 eth_addr_dec(entry.mac);
1374
1375 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1376 if (err)
1377 return err;
1378
1379 /* Initialize a fresh ATU entry if it isn't found */
1380 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1381 !ether_addr_equal(entry.mac, addr)) {
1382 memset(&entry, 0, sizeof(entry));
1383 ether_addr_copy(entry.mac, addr);
1384 }
1385
1386 /* Purge the ATU entry only if no port is using it anymore */
1387 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1388 entry.portvec &= ~BIT(port);
1389 if (!entry.portvec)
1390 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1391 } else {
1392 entry.portvec |= BIT(port);
1393 entry.state = state;
1394 }
1395
1396 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1397}
1398
Andrew Lunn87fa8862017-11-09 22:29:56 +01001399static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1400 u16 vid)
1401{
1402 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1403 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1404
1405 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1406}
1407
1408static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1409{
1410 int port;
1411 int err;
1412
1413 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1414 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1415 if (err)
1416 return err;
1417 }
1418
1419 return 0;
1420}
1421
Vivien Didelotfad09c72016-06-21 12:28:20 -04001422static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001423 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001424{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001425 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001426 int err;
1427
Vivien Didelot567aa592017-05-01 14:05:25 -04001428 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001429 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001430 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001431
Vivien Didelotc91498e2017-06-07 18:12:13 -04001432 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001433
Andrew Lunn87fa8862017-11-09 22:29:56 +01001434 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1435 if (err)
1436 return err;
1437
1438 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001439}
1440
Vivien Didelotf81ec902016-05-09 13:22:58 -04001441static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001442 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001443{
Vivien Didelot04bed142016-08-31 18:06:13 -04001444 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001445 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1446 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001447 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001448 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001449
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001450 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001451 return;
1452
Vivien Didelotc91498e2017-06-07 18:12:13 -04001453 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001454 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001455 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001456 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001457 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001458 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001459
Vivien Didelotfad09c72016-06-21 12:28:20 -04001460 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001461
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001462 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001463 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001464 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1465 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001466
Vivien Didelot77064f32016-11-04 03:23:30 +01001467 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001468 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1469 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001470
Vivien Didelotfad09c72016-06-21 12:28:20 -04001471 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001472}
1473
Vivien Didelotfad09c72016-06-21 12:28:20 -04001474static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001475 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001476{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001477 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001478 int i, err;
1479
Vivien Didelot567aa592017-05-01 14:05:25 -04001480 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001481 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001482 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001483
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001484 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001485 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001486 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001487
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001488 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001489
1490 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001491 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001492 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001493 if (vlan.member[i] !=
1494 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001495 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001496 break;
1497 }
1498 }
1499
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001500 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001501 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001502 return err;
1503
Vivien Didelote606ca32017-03-11 16:12:55 -05001504 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001505}
1506
Vivien Didelotf81ec902016-05-09 13:22:58 -04001507static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1508 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001509{
Vivien Didelot04bed142016-08-31 18:06:13 -04001510 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001511 u16 pvid, vid;
1512 int err = 0;
1513
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001514 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001515 return -EOPNOTSUPP;
1516
Vivien Didelotfad09c72016-06-21 12:28:20 -04001517 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001518
Vivien Didelot77064f32016-11-04 03:23:30 +01001519 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001520 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001521 goto unlock;
1522
Vivien Didelot76e398a2015-11-01 12:33:55 -05001523 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001524 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001525 if (err)
1526 goto unlock;
1527
1528 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001529 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001530 if (err)
1531 goto unlock;
1532 }
1533 }
1534
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001535unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001536 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001537
1538 return err;
1539}
1540
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001541static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1542 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001543{
Vivien Didelot04bed142016-08-31 18:06:13 -04001544 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001545 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001546
Vivien Didelotfad09c72016-06-21 12:28:20 -04001547 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001548 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1549 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001550 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001551
1552 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001553}
1554
Vivien Didelotf81ec902016-05-09 13:22:58 -04001555static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001556 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001557{
Vivien Didelot04bed142016-08-31 18:06:13 -04001558 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001559 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001560
Vivien Didelotfad09c72016-06-21 12:28:20 -04001561 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001562 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001563 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001564 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001565
Vivien Didelot83dabd12016-08-31 11:50:04 -04001566 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001567}
1568
Vivien Didelot83dabd12016-08-31 11:50:04 -04001569static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1570 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001571 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001572{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001573 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001574 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001575 int err;
1576
Vivien Didelot27c0e602017-06-15 12:14:01 -04001577 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001578 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001579
1580 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001581 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001582 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001583 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001584 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001585 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001586
Vivien Didelot27c0e602017-06-15 12:14:01 -04001587 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001588 break;
1589
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001590 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001591 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001592
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001593 if (!is_unicast_ether_addr(addr.mac))
1594 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001595
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001596 is_static = (addr.state ==
1597 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1598 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001599 if (err)
1600 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001601 } while (!is_broadcast_ether_addr(addr.mac));
1602
1603 return err;
1604}
1605
Vivien Didelot83dabd12016-08-31 11:50:04 -04001606static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001607 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001608{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001609 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001610 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001611 };
1612 u16 fid;
1613 int err;
1614
1615 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001616 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001617 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001618 mutex_unlock(&chip->reg_lock);
1619
Vivien Didelot83dabd12016-08-31 11:50:04 -04001620 if (err)
1621 return err;
1622
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001623 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001624 if (err)
1625 return err;
1626
1627 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001628 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001629 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001630 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001631 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001632 if (err)
1633 return err;
1634
1635 if (!vlan.valid)
1636 break;
1637
1638 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001639 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001640 if (err)
1641 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001642 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001643
1644 return err;
1645}
1646
Vivien Didelotf81ec902016-05-09 13:22:58 -04001647static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001648 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001649{
Vivien Didelot04bed142016-08-31 18:06:13 -04001650 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001651
Andrew Lunna61e5402018-02-15 14:38:35 +01001652 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001653}
1654
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001655static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1656 struct net_device *br)
1657{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001658 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001659 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001660 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001661 int err;
1662
1663 /* Remap the Port VLAN of each local bridge group member */
1664 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1665 if (chip->ds->ports[port].bridge_dev == br) {
1666 err = mv88e6xxx_port_vlan_map(chip, port);
1667 if (err)
1668 return err;
1669 }
1670 }
1671
Vivien Didelote96a6e02017-03-30 17:37:13 -04001672 if (!mv88e6xxx_has_pvt(chip))
1673 return 0;
1674
1675 /* Remap the Port VLAN of each cross-chip bridge group member */
1676 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1677 ds = chip->ds->dst->ds[dev];
1678 if (!ds)
1679 break;
1680
1681 for (port = 0; port < ds->num_ports; ++port) {
1682 if (ds->ports[port].bridge_dev == br) {
1683 err = mv88e6xxx_pvt_map(chip, dev, port);
1684 if (err)
1685 return err;
1686 }
1687 }
1688 }
1689
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001690 return 0;
1691}
1692
Vivien Didelotf81ec902016-05-09 13:22:58 -04001693static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001694 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001695{
Vivien Didelot04bed142016-08-31 18:06:13 -04001696 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001697 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001698
Vivien Didelotfad09c72016-06-21 12:28:20 -04001699 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001700 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001701 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001702
Vivien Didelot466dfa02016-02-26 13:16:05 -05001703 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001704}
1705
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001706static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1707 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001708{
Vivien Didelot04bed142016-08-31 18:06:13 -04001709 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001710
Vivien Didelotfad09c72016-06-21 12:28:20 -04001711 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001712 if (mv88e6xxx_bridge_map(chip, br) ||
1713 mv88e6xxx_port_vlan_map(chip, port))
1714 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001715 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001716}
1717
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001718static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1719 int port, struct net_device *br)
1720{
1721 struct mv88e6xxx_chip *chip = ds->priv;
1722 int err;
1723
1724 if (!mv88e6xxx_has_pvt(chip))
1725 return 0;
1726
1727 mutex_lock(&chip->reg_lock);
1728 err = mv88e6xxx_pvt_map(chip, dev, port);
1729 mutex_unlock(&chip->reg_lock);
1730
1731 return err;
1732}
1733
1734static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1735 int port, struct net_device *br)
1736{
1737 struct mv88e6xxx_chip *chip = ds->priv;
1738
1739 if (!mv88e6xxx_has_pvt(chip))
1740 return;
1741
1742 mutex_lock(&chip->reg_lock);
1743 if (mv88e6xxx_pvt_map(chip, dev, port))
1744 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1745 mutex_unlock(&chip->reg_lock);
1746}
1747
Vivien Didelot17e708b2016-12-05 17:30:27 -05001748static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1749{
1750 if (chip->info->ops->reset)
1751 return chip->info->ops->reset(chip);
1752
1753 return 0;
1754}
1755
Vivien Didelot309eca62016-12-05 17:30:26 -05001756static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1757{
1758 struct gpio_desc *gpiod = chip->reset;
1759
1760 /* If there is a GPIO connected to the reset pin, toggle it */
1761 if (gpiod) {
1762 gpiod_set_value_cansleep(gpiod, 1);
1763 usleep_range(10000, 20000);
1764 gpiod_set_value_cansleep(gpiod, 0);
1765 usleep_range(10000, 20000);
1766 }
1767}
1768
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001769static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1770{
1771 int i, err;
1772
1773 /* Set all ports to the Disabled state */
1774 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001775 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001776 if (err)
1777 return err;
1778 }
1779
1780 /* Wait for transmit queues to drain,
1781 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1782 */
1783 usleep_range(2000, 4000);
1784
1785 return 0;
1786}
1787
Vivien Didelotfad09c72016-06-21 12:28:20 -04001788static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001789{
Vivien Didelota935c052016-09-29 12:21:53 -04001790 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001791
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001792 err = mv88e6xxx_disable_ports(chip);
1793 if (err)
1794 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001795
Vivien Didelot309eca62016-12-05 17:30:26 -05001796 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001797
Vivien Didelot17e708b2016-12-05 17:30:27 -05001798 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001799}
1800
Vivien Didelot43145572017-03-11 16:12:59 -05001801static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001802 enum mv88e6xxx_frame_mode frame,
1803 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001804{
1805 int err;
1806
Vivien Didelot43145572017-03-11 16:12:59 -05001807 if (!chip->info->ops->port_set_frame_mode)
1808 return -EOPNOTSUPP;
1809
1810 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001811 if (err)
1812 return err;
1813
Vivien Didelot43145572017-03-11 16:12:59 -05001814 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1815 if (err)
1816 return err;
1817
1818 if (chip->info->ops->port_set_ether_type)
1819 return chip->info->ops->port_set_ether_type(chip, port, etype);
1820
1821 return 0;
1822}
1823
1824static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1825{
1826 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001827 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001828 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001829}
1830
1831static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1832{
1833 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001834 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001835 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001836}
1837
1838static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1839{
1840 return mv88e6xxx_set_port_mode(chip, port,
1841 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001842 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1843 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001844}
1845
1846static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1847{
1848 if (dsa_is_dsa_port(chip->ds, port))
1849 return mv88e6xxx_set_port_mode_dsa(chip, port);
1850
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001851 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001852 return mv88e6xxx_set_port_mode_normal(chip, port);
1853
1854 /* Setup CPU port mode depending on its supported tag format */
1855 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1856 return mv88e6xxx_set_port_mode_dsa(chip, port);
1857
1858 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1859 return mv88e6xxx_set_port_mode_edsa(chip, port);
1860
1861 return -EINVAL;
1862}
1863
Vivien Didelotea698f42017-03-11 16:12:50 -05001864static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1865{
1866 bool message = dsa_is_dsa_port(chip->ds, port);
1867
1868 return mv88e6xxx_port_set_message_port(chip, port, message);
1869}
1870
Vivien Didelot601aeed2017-03-11 16:13:00 -05001871static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
1872{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001873 struct dsa_switch *ds = chip->ds;
1874 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05001875
1876 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05001877 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05001878 if (chip->info->ops->port_set_egress_floods)
1879 return chip->info->ops->port_set_egress_floods(chip, port,
1880 flood, flood);
1881
1882 return 0;
1883}
1884
Andrew Lunn6d917822017-05-26 01:03:21 +02001885static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
1886 bool on)
1887{
Vivien Didelot523a8902017-05-26 18:02:42 -04001888 if (chip->info->ops->serdes_power)
1889 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02001890
Vivien Didelot523a8902017-05-26 18:02:42 -04001891 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02001892}
1893
Vivien Didelotfa371c82017-12-05 15:34:10 -05001894static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
1895{
1896 struct dsa_switch *ds = chip->ds;
1897 int upstream_port;
1898 int err;
1899
Vivien Didelot07073c72017-12-05 15:34:13 -05001900 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05001901 if (chip->info->ops->port_set_upstream_port) {
1902 err = chip->info->ops->port_set_upstream_port(chip, port,
1903 upstream_port);
1904 if (err)
1905 return err;
1906 }
1907
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05001908 if (port == upstream_port) {
1909 if (chip->info->ops->set_cpu_port) {
1910 err = chip->info->ops->set_cpu_port(chip,
1911 upstream_port);
1912 if (err)
1913 return err;
1914 }
1915
1916 if (chip->info->ops->set_egress_port) {
1917 err = chip->info->ops->set_egress_port(chip,
1918 upstream_port);
1919 if (err)
1920 return err;
1921 }
1922 }
1923
Vivien Didelotfa371c82017-12-05 15:34:10 -05001924 return 0;
1925}
1926
Vivien Didelotfad09c72016-06-21 12:28:20 -04001927static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07001928{
Vivien Didelotfad09c72016-06-21 12:28:20 -04001929 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001930 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001931 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07001932
Vivien Didelotd78343d2016-11-04 03:23:36 +01001933 /* MAC Forcing register: don't force link, speed, duplex or flow control
1934 * state to any particular values on physical ports, but force the CPU
1935 * port and all DSA ports to their maximum bandwidth and full duplex.
1936 */
1937 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1938 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
1939 SPEED_MAX, DUPLEX_FULL,
1940 PHY_INTERFACE_MODE_NA);
1941 else
1942 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
1943 SPEED_UNFORCED, DUPLEX_UNFORCED,
1944 PHY_INTERFACE_MODE_NA);
1945 if (err)
1946 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001947
1948 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
1949 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
1950 * tunneling, determine priority by looking at 802.1p and IP
1951 * priority fields (IP prio has precedence), and set STP state
1952 * to Forwarding.
1953 *
1954 * If this is the CPU link, use DSA or EDSA tagging depending
1955 * on which tagging mode was configured.
1956 *
1957 * If this is a link to another switch, use DSA tagging mode.
1958 *
1959 * If this is the upstream port for this switch, enable
1960 * forwarding of unknown unicasts and multicasts.
1961 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04001962 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
1963 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
1964 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
1965 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001966 if (err)
1967 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02001968
Vivien Didelot601aeed2017-03-11 16:13:00 -05001969 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001970 if (err)
1971 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02001972
Vivien Didelot601aeed2017-03-11 16:13:00 -05001973 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05001974 if (err)
1975 return err;
1976
Andrew Lunn04aca992017-05-26 01:03:24 +02001977 /* Enable the SERDES interface for DSA and CPU ports. Normal
1978 * ports SERDES are enabled when the port is enabled, thus
1979 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001980 */
Andrew Lunn04aca992017-05-26 01:03:24 +02001981 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
1982 err = mv88e6xxx_serdes_power(chip, port, true);
1983 if (err)
1984 return err;
1985 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00001986
Vivien Didelot8efdda42015-08-13 12:52:23 -04001987 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05001988 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04001989 * untagged frames on this port, do a destination address lookup on all
1990 * received packets as usual, disable ARP mirroring and don't send a
1991 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02001992 */
Andrew Lunna23b2962017-02-04 20:15:28 +01001993 err = mv88e6xxx_port_set_map_da(chip, port);
1994 if (err)
1995 return err;
1996
Vivien Didelotfa371c82017-12-05 15:34:10 -05001997 err = mv88e6xxx_setup_upstream_port(chip, port);
1998 if (err)
1999 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002000
Andrew Lunna23b2962017-02-04 20:15:28 +01002001 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002002 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002003 if (err)
2004 return err;
2005
Vivien Didelotcd782652017-06-08 18:34:13 -04002006 if (chip->info->ops->port_set_jumbo_size) {
2007 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002008 if (err)
2009 return err;
2010 }
2011
Andrew Lunn54d792f2015-05-06 01:09:47 +02002012 /* Port Association Vector: when learning source addresses
2013 * of packets, add the address to the address database using
2014 * a port bitmap that has only the bit for this port set and
2015 * the other bits clear.
2016 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002017 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002018 /* Disable learning for CPU port */
2019 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002020 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002021
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002022 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2023 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002024 if (err)
2025 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002026
2027 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002028 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2029 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002030 if (err)
2031 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002032
Vivien Didelot08984322017-06-08 18:34:12 -04002033 if (chip->info->ops->port_pause_limit) {
2034 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002035 if (err)
2036 return err;
2037 }
2038
Vivien Didelotc8c94892017-03-11 16:13:01 -05002039 if (chip->info->ops->port_disable_learn_limit) {
2040 err = chip->info->ops->port_disable_learn_limit(chip, port);
2041 if (err)
2042 return err;
2043 }
2044
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002045 if (chip->info->ops->port_disable_pri_override) {
2046 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002047 if (err)
2048 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002049 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002050
Andrew Lunnef0a7312016-12-03 04:35:16 +01002051 if (chip->info->ops->port_tag_remap) {
2052 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002053 if (err)
2054 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002055 }
2056
Andrew Lunnef70b112016-12-03 04:45:18 +01002057 if (chip->info->ops->port_egress_rate_limiting) {
2058 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002059 if (err)
2060 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002061 }
2062
Vivien Didelotea698f42017-03-11 16:12:50 -05002063 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002064 if (err)
2065 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002066
Vivien Didelot207afda2016-04-14 14:42:09 -04002067 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002068 * database, and allow bidirectional communication between the
2069 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002070 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002071 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002072 if (err)
2073 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002074
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002075 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002076 if (err)
2077 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002078
2079 /* Default VLAN ID and priority: don't set a default VLAN
2080 * ID, and set the default packet priority to zero.
2081 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002082 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002083}
2084
Andrew Lunn04aca992017-05-26 01:03:24 +02002085static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2086 struct phy_device *phydev)
2087{
2088 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002089 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002090
2091 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002092 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02002093 mutex_unlock(&chip->reg_lock);
2094
2095 return err;
2096}
2097
2098static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2099 struct phy_device *phydev)
2100{
2101 struct mv88e6xxx_chip *chip = ds->priv;
2102
2103 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002104 if (mv88e6xxx_serdes_power(chip, port, false))
2105 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02002106 mutex_unlock(&chip->reg_lock);
2107}
2108
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002109static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2110 unsigned int ageing_time)
2111{
Vivien Didelot04bed142016-08-31 18:06:13 -04002112 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002113 int err;
2114
2115 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002116 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002117 mutex_unlock(&chip->reg_lock);
2118
2119 return err;
2120}
2121
Vivien Didelot97299342016-07-18 20:45:30 -04002122static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002123{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002124 struct dsa_switch *ds = chip->ds;
Vivien Didelot08a01262016-05-09 13:22:50 -04002125 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002126
Vivien Didelot50484ff2016-05-09 13:22:54 -04002127 /* Disable remote management, and set the switch's DSA device number. */
Vivien Didelotd77f4322017-06-15 12:14:03 -04002128 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL2,
2129 MV88E6XXX_G1_CTL2_MULTIPLE_CASCADE |
Vivien Didelota935c052016-09-29 12:21:53 -04002130 (ds->index & 0x1f));
Vivien Didelot50484ff2016-05-09 13:22:54 -04002131 if (err)
2132 return err;
2133
Vivien Didelot08a01262016-05-09 13:22:50 -04002134 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002135 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002136 if (err)
2137 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002138 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002139 if (err)
2140 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002141 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002142 if (err)
2143 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002144 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002145 if (err)
2146 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002147 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002148 if (err)
2149 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002150 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002151 if (err)
2152 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002153 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002154 if (err)
2155 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002156 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002157 if (err)
2158 return err;
2159
2160 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002161 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002162 if (err)
2163 return err;
2164
Andrew Lunnde2273872016-11-21 23:27:01 +01002165 /* Initialize the statistics unit */
2166 err = mv88e6xxx_stats_set_histogram(chip);
2167 if (err)
2168 return err;
2169
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002170 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002171}
2172
Vivien Didelotf81ec902016-05-09 13:22:58 -04002173static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002174{
Vivien Didelot04bed142016-08-31 18:06:13 -04002175 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002176 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002177 int i;
2178
Vivien Didelotfad09c72016-06-21 12:28:20 -04002179 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002180 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002181
Vivien Didelotfad09c72016-06-21 12:28:20 -04002182 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002183
Vivien Didelot97299342016-07-18 20:45:30 -04002184 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002185 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002186 if (dsa_is_unused_port(ds, i))
2187 continue;
2188
Vivien Didelot97299342016-07-18 20:45:30 -04002189 err = mv88e6xxx_setup_port(chip, i);
2190 if (err)
2191 goto unlock;
2192 }
2193
2194 /* Setup Switch Global 1 Registers */
2195 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002196 if (err)
2197 goto unlock;
2198
Vivien Didelot97299342016-07-18 20:45:30 -04002199 /* Setup Switch Global 2 Registers */
Vivien Didelot9069c132017-07-17 13:03:44 -04002200 if (chip->info->global2_addr) {
Vivien Didelot97299342016-07-18 20:45:30 -04002201 err = mv88e6xxx_g2_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002202 if (err)
2203 goto unlock;
2204 }
Andrew Lunn54d792f2015-05-06 01:09:47 +02002205
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002206 err = mv88e6xxx_irl_setup(chip);
2207 if (err)
2208 goto unlock;
2209
Vivien Didelot04a69a12017-10-13 14:18:05 -04002210 err = mv88e6xxx_mac_setup(chip);
2211 if (err)
2212 goto unlock;
2213
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002214 err = mv88e6xxx_phy_setup(chip);
2215 if (err)
2216 goto unlock;
2217
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002218 err = mv88e6xxx_vtu_setup(chip);
2219 if (err)
2220 goto unlock;
2221
Vivien Didelot81228992017-03-30 17:37:08 -04002222 err = mv88e6xxx_pvt_setup(chip);
2223 if (err)
2224 goto unlock;
2225
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002226 err = mv88e6xxx_atu_setup(chip);
2227 if (err)
2228 goto unlock;
2229
Andrew Lunn87fa8862017-11-09 22:29:56 +01002230 err = mv88e6xxx_broadcast_setup(chip, 0);
2231 if (err)
2232 goto unlock;
2233
Vivien Didelot9e907d72017-07-17 13:03:43 -04002234 err = mv88e6xxx_pot_setup(chip);
2235 if (err)
2236 goto unlock;
2237
Vivien Didelot51c901a2017-07-17 13:03:41 -04002238 err = mv88e6xxx_rsvd2cpu_setup(chip);
2239 if (err)
2240 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002241
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002242 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002243 if (chip->info->ptp_support) {
2244 err = mv88e6xxx_ptp_setup(chip);
2245 if (err)
2246 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002247
2248 err = mv88e6xxx_hwtstamp_setup(chip);
2249 if (err)
2250 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002251 }
2252
Vivien Didelot6b17e862015-08-13 12:52:18 -04002253unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002254 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002255
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002256 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002257}
2258
Vivien Didelote57e5e72016-08-15 17:19:00 -04002259static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002260{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002261 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2262 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002263 u16 val;
2264 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002265
Andrew Lunnee26a222017-01-24 14:53:48 +01002266 if (!chip->info->ops->phy_read)
2267 return -EOPNOTSUPP;
2268
Vivien Didelotfad09c72016-06-21 12:28:20 -04002269 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002270 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002271 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002272
Andrew Lunnda9f3302017-02-01 03:40:05 +01002273 if (reg == MII_PHYSID2) {
2274 /* Some internal PHYS don't have a model number. Use
2275 * the mv88e6390 family model number instead.
2276 */
2277 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002278 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002279 }
2280
Vivien Didelote57e5e72016-08-15 17:19:00 -04002281 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002282}
2283
Vivien Didelote57e5e72016-08-15 17:19:00 -04002284static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002285{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002286 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2287 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002288 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002289
Andrew Lunnee26a222017-01-24 14:53:48 +01002290 if (!chip->info->ops->phy_write)
2291 return -EOPNOTSUPP;
2292
Vivien Didelotfad09c72016-06-21 12:28:20 -04002293 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002294 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002295 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002296
2297 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002298}
2299
Vivien Didelotfad09c72016-06-21 12:28:20 -04002300static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002301 struct device_node *np,
2302 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002303{
2304 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002305 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002306 struct mii_bus *bus;
2307 int err;
2308
Andrew Lunn2510bab2018-02-22 01:51:49 +01002309 if (external) {
2310 mutex_lock(&chip->reg_lock);
2311 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2312 mutex_unlock(&chip->reg_lock);
2313
2314 if (err)
2315 return err;
2316 }
2317
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002318 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002319 if (!bus)
2320 return -ENOMEM;
2321
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002322 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002323 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002324 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002325 INIT_LIST_HEAD(&mdio_bus->list);
2326 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002327
Andrew Lunnb516d452016-06-04 21:17:06 +02002328 if (np) {
2329 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002330 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002331 } else {
2332 bus->name = "mv88e6xxx SMI";
2333 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2334 }
2335
2336 bus->read = mv88e6xxx_mdio_read;
2337 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002338 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002339
Andrew Lunn6f882842018-03-17 20:32:05 +01002340 if (!external) {
2341 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2342 if (err)
2343 return err;
2344 }
2345
Andrew Lunna3c53be52017-01-24 14:53:50 +01002346 if (np)
2347 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002348 else
2349 err = mdiobus_register(bus);
2350 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002351 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002352 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002353 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002354 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002355
2356 if (external)
2357 list_add_tail(&mdio_bus->list, &chip->mdios);
2358 else
2359 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002360
2361 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002362}
2363
Andrew Lunna3c53be52017-01-24 14:53:50 +01002364static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2365 { .compatible = "marvell,mv88e6xxx-mdio-external",
2366 .data = (void *)true },
2367 { },
2368};
2369
Andrew Lunn3126aee2017-12-07 01:05:57 +01002370static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2371
2372{
2373 struct mv88e6xxx_mdio_bus *mdio_bus;
2374 struct mii_bus *bus;
2375
2376 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2377 bus = mdio_bus->bus;
2378
Andrew Lunn6f882842018-03-17 20:32:05 +01002379 if (!mdio_bus->external)
2380 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2381
Andrew Lunn3126aee2017-12-07 01:05:57 +01002382 mdiobus_unregister(bus);
2383 }
2384}
2385
Andrew Lunna3c53be52017-01-24 14:53:50 +01002386static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2387 struct device_node *np)
2388{
2389 const struct of_device_id *match;
2390 struct device_node *child;
2391 int err;
2392
2393 /* Always register one mdio bus for the internal/default mdio
2394 * bus. This maybe represented in the device tree, but is
2395 * optional.
2396 */
2397 child = of_get_child_by_name(np, "mdio");
2398 err = mv88e6xxx_mdio_register(chip, child, false);
2399 if (err)
2400 return err;
2401
2402 /* Walk the device tree, and see if there are any other nodes
2403 * which say they are compatible with the external mdio
2404 * bus.
2405 */
2406 for_each_available_child_of_node(np, child) {
2407 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2408 if (match) {
2409 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002410 if (err) {
2411 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002412 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002413 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002414 }
2415 }
2416
2417 return 0;
2418}
2419
Vivien Didelot855b1932016-07-20 18:18:35 -04002420static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2421{
Vivien Didelot04bed142016-08-31 18:06:13 -04002422 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002423
2424 return chip->eeprom_len;
2425}
2426
Vivien Didelot855b1932016-07-20 18:18:35 -04002427static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2428 struct ethtool_eeprom *eeprom, u8 *data)
2429{
Vivien Didelot04bed142016-08-31 18:06:13 -04002430 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002431 int err;
2432
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002433 if (!chip->info->ops->get_eeprom)
2434 return -EOPNOTSUPP;
2435
Vivien Didelot855b1932016-07-20 18:18:35 -04002436 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002437 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002438 mutex_unlock(&chip->reg_lock);
2439
2440 if (err)
2441 return err;
2442
2443 eeprom->magic = 0xc3ec4951;
2444
2445 return 0;
2446}
2447
Vivien Didelot855b1932016-07-20 18:18:35 -04002448static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2449 struct ethtool_eeprom *eeprom, u8 *data)
2450{
Vivien Didelot04bed142016-08-31 18:06:13 -04002451 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002452 int err;
2453
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002454 if (!chip->info->ops->set_eeprom)
2455 return -EOPNOTSUPP;
2456
Vivien Didelot855b1932016-07-20 18:18:35 -04002457 if (eeprom->magic != 0xc3ec4951)
2458 return -EINVAL;
2459
2460 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002461 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002462 mutex_unlock(&chip->reg_lock);
2463
2464 return err;
2465}
2466
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002467static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002468 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002469 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002470 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002471 .phy_read = mv88e6185_phy_ppu_read,
2472 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002473 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002474 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002475 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002476 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002477 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002478 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002479 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002480 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002481 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002482 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002483 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002484 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002485 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002486 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2487 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002488 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002489 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2490 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002491 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002492 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002493 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002494 .ppu_enable = mv88e6185_g1_ppu_enable,
2495 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002496 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002497 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002498 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002499};
2500
2501static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002502 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002503 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002504 .phy_read = mv88e6185_phy_ppu_read,
2505 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002506 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002507 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002508 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002509 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002510 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002511 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002512 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002513 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002514 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2515 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002516 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002517 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002518 .ppu_enable = mv88e6185_g1_ppu_enable,
2519 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002520 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002521 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002522 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002523};
2524
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002525static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002526 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002527 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002528 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2529 .phy_read = mv88e6xxx_g2_smi_phy_read,
2530 .phy_write = mv88e6xxx_g2_smi_phy_write,
2531 .port_set_link = mv88e6xxx_port_set_link,
2532 .port_set_duplex = mv88e6xxx_port_set_duplex,
2533 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002534 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002535 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002536 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002537 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002538 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002539 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002540 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002541 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002542 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002543 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002544 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002545 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2546 .stats_get_strings = mv88e6095_stats_get_strings,
2547 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002548 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2549 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002550 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002551 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002552 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002553 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002554 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002555 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002556};
2557
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002558static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002559 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002560 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002561 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002562 .phy_read = mv88e6xxx_g2_smi_phy_read,
2563 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002564 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002565 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002566 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002567 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002568 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002569 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002570 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002571 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002572 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002573 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2574 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002575 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002576 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2577 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002578 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002579 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002580 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002581 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002582 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002583 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002584};
2585
2586static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002587 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002588 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002589 .phy_read = mv88e6185_phy_ppu_read,
2590 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002591 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002592 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002593 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002594 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002595 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002596 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002597 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002598 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002599 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002600 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002601 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002602 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002603 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002604 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2605 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002606 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002607 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2608 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002609 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002610 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002611 .ppu_enable = mv88e6185_g1_ppu_enable,
2612 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002613 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002614 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002615 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002616};
2617
Vivien Didelot990e27b2017-03-28 13:50:32 -04002618static const struct mv88e6xxx_ops mv88e6141_ops = {
2619 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002620 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002621 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2622 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2623 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2624 .phy_read = mv88e6xxx_g2_smi_phy_read,
2625 .phy_write = mv88e6xxx_g2_smi_phy_write,
2626 .port_set_link = mv88e6xxx_port_set_link,
2627 .port_set_duplex = mv88e6xxx_port_set_duplex,
2628 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2629 .port_set_speed = mv88e6390_port_set_speed,
2630 .port_tag_remap = mv88e6095_port_tag_remap,
2631 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2632 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2633 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002634 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002635 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002636 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002637 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2638 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2639 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002640 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002641 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2642 .stats_get_strings = mv88e6320_stats_get_strings,
2643 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002644 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2645 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002646 .watchdog_ops = &mv88e6390_watchdog_ops,
2647 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002648 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002649 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002650 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002651 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002652 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002653};
2654
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002655static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002656 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002657 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002658 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002659 .phy_read = mv88e6xxx_g2_smi_phy_read,
2660 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002661 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002662 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002663 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002664 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002665 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002666 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002667 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002668 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002669 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002670 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002671 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002672 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002673 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002674 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002675 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2676 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002677 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002678 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2679 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002680 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002681 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002682 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002683 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002684 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002685 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002686};
2687
2688static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002689 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002690 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002691 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002692 .phy_read = mv88e6165_phy_read,
2693 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002694 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002695 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002696 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002697 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002698 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002699 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002700 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002701 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2702 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002703 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002704 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2705 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002706 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002707 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002708 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002709 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002710 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002711 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002712};
2713
2714static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002715 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002716 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002717 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002718 .phy_read = mv88e6xxx_g2_smi_phy_read,
2719 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002720 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002721 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002722 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002723 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002724 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002725 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002726 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002727 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002728 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002729 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002730 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002731 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002732 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002733 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002734 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002735 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2736 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002737 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002738 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2739 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002740 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002741 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002742 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002743 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002744 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002745 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002746};
2747
2748static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002749 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002750 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002751 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2752 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002753 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002754 .phy_read = mv88e6xxx_g2_smi_phy_read,
2755 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002756 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002757 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002758 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002759 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002760 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002761 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002762 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002763 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002764 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002765 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002766 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002767 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002768 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002769 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002770 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002771 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2772 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002773 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002774 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2775 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002776 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002777 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002778 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002779 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002780 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002781 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002782 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002783 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002784};
2785
2786static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002787 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002788 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002789 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002790 .phy_read = mv88e6xxx_g2_smi_phy_read,
2791 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002792 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002793 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002794 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002795 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002796 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002797 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002798 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002799 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002800 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002801 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002802 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002803 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002804 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002805 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002806 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002807 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2808 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002809 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002810 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2811 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002812 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002813 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002814 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002815 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002816 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002817 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002818};
2819
2820static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002821 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002822 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002823 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2824 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002825 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002826 .phy_read = mv88e6xxx_g2_smi_phy_read,
2827 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002828 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002829 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002830 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002831 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002832 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002833 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002834 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002835 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002836 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002837 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002838 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002839 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002840 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002841 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002842 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002843 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2844 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002845 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002846 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2847 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002848 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002849 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002850 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002851 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002852 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002853 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002854 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002855 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002856};
2857
2858static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002859 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002860 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002861 .phy_read = mv88e6185_phy_ppu_read,
2862 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002863 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002864 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002865 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002866 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002867 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01002868 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01002869 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002870 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002871 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002872 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2873 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002874 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002875 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2876 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002877 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002878 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002879 .ppu_enable = mv88e6185_g1_ppu_enable,
2880 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002881 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002882 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002883 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002884};
2885
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002886static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002887 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002888 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002889 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2890 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002891 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2892 .phy_read = mv88e6xxx_g2_smi_phy_read,
2893 .phy_write = mv88e6xxx_g2_smi_phy_write,
2894 .port_set_link = mv88e6xxx_port_set_link,
2895 .port_set_duplex = mv88e6xxx_port_set_duplex,
2896 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2897 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002898 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002899 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002900 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002901 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002902 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002903 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002904 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002905 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002906 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002907 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2908 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002909 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002910 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2911 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002912 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002913 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002914 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002915 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002916 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2917 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002918 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002919 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002920};
2921
2922static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002923 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002924 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002925 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2926 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002927 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2928 .phy_read = mv88e6xxx_g2_smi_phy_read,
2929 .phy_write = mv88e6xxx_g2_smi_phy_write,
2930 .port_set_link = mv88e6xxx_port_set_link,
2931 .port_set_duplex = mv88e6xxx_port_set_duplex,
2932 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2933 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002934 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002935 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002936 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002937 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002938 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002939 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002940 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002941 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002942 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002943 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2944 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002945 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002946 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2947 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002948 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002949 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002950 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002951 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002952 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2953 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002954 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002955 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002956};
2957
2958static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002959 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002960 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05002961 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2962 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002963 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2964 .phy_read = mv88e6xxx_g2_smi_phy_read,
2965 .phy_write = mv88e6xxx_g2_smi_phy_write,
2966 .port_set_link = mv88e6xxx_port_set_link,
2967 .port_set_duplex = mv88e6xxx_port_set_duplex,
2968 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2969 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002970 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002971 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002972 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002973 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04002974 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002975 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002976 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01002977 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01002978 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002979 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2980 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01002981 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002982 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2983 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01002984 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01002985 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002986 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002987 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04002988 .vtu_getnext = mv88e6390_g1_vtu_getnext,
2989 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02002990 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01002991};
2992
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002993static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002994 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002995 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002996 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2997 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002998 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002999 .phy_read = mv88e6xxx_g2_smi_phy_read,
3000 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003001 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003002 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003003 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003004 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003005 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003006 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003007 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003008 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003009 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003010 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003011 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003012 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003013 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003014 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003015 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003016 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3017 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003018 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003019 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3020 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003021 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003022 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003023 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003024 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003025 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003026 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003027 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003028 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003029 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003030};
3031
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003032static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003033 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003034 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003035 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3036 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003037 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3038 .phy_read = mv88e6xxx_g2_smi_phy_read,
3039 .phy_write = mv88e6xxx_g2_smi_phy_write,
3040 .port_set_link = mv88e6xxx_port_set_link,
3041 .port_set_duplex = mv88e6xxx_port_set_duplex,
3042 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3043 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003044 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003045 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003046 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003047 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003048 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003049 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003050 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003051 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003052 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003053 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003054 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3055 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003056 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003057 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3058 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003059 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003060 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003061 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003062 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003063 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3064 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003065 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003066 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003067 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003068};
3069
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003070static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003071 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003072 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003073 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3074 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003075 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003076 .phy_read = mv88e6xxx_g2_smi_phy_read,
3077 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003078 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003079 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003080 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003081 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003082 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003083 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003084 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003085 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003086 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003087 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003088 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003089 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003090 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003091 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003092 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3093 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003094 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003095 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3096 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003097 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003098 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003099 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003100 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003101 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003102 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003103 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003104};
3105
3106static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003107 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003108 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003109 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3110 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003111 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003112 .phy_read = mv88e6xxx_g2_smi_phy_read,
3113 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003114 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003115 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003116 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003117 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003118 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003119 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003120 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003121 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003122 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003123 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003124 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003125 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003126 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003127 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003128 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3129 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003130 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003131 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3132 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003133 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003134 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003135 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003136 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003137 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003138};
3139
Vivien Didelot16e329a2017-03-28 13:50:33 -04003140static const struct mv88e6xxx_ops mv88e6341_ops = {
3141 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003142 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003143 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3144 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3145 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3146 .phy_read = mv88e6xxx_g2_smi_phy_read,
3147 .phy_write = mv88e6xxx_g2_smi_phy_write,
3148 .port_set_link = mv88e6xxx_port_set_link,
3149 .port_set_duplex = mv88e6xxx_port_set_duplex,
3150 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3151 .port_set_speed = mv88e6390_port_set_speed,
3152 .port_tag_remap = mv88e6095_port_tag_remap,
3153 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3154 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3155 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003156 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003157 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003158 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003159 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3160 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3161 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003162 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003163 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3164 .stats_get_strings = mv88e6320_stats_get_strings,
3165 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003166 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3167 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003168 .watchdog_ops = &mv88e6390_watchdog_ops,
3169 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003170 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003171 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003172 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003173 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003174 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003175 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003176};
3177
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003178static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003179 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003180 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003181 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003182 .phy_read = mv88e6xxx_g2_smi_phy_read,
3183 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003184 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003185 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003186 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003187 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003188 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003189 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003190 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003191 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003192 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003193 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003194 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003195 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003196 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003197 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003198 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003199 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3200 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003201 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003202 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3203 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003204 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003205 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003206 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003207 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003208 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003209 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003210};
3211
3212static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003213 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003214 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003215 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003216 .phy_read = mv88e6xxx_g2_smi_phy_read,
3217 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003218 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003219 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003220 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003221 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003222 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003223 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003224 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003225 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003226 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003227 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003228 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003229 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003230 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003231 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003232 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003233 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3234 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003235 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003236 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3237 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003238 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003239 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003240 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003241 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003242 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003243 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003244 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003245};
3246
3247static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003248 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003249 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003250 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3251 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003252 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003253 .phy_read = mv88e6xxx_g2_smi_phy_read,
3254 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003255 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003256 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003257 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003258 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003259 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003260 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003261 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003262 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003263 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003264 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003265 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003266 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003267 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003268 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003269 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003270 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3271 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003272 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003273 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3274 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003275 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003276 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003277 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003278 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003279 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003280 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003281 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003282 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003283 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003284 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3285 .serdes_get_strings = mv88e6352_serdes_get_strings,
3286 .serdes_get_stats = mv88e6352_serdes_get_stats,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003287};
3288
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003289static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003290 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003291 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003292 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3293 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003294 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3295 .phy_read = mv88e6xxx_g2_smi_phy_read,
3296 .phy_write = mv88e6xxx_g2_smi_phy_write,
3297 .port_set_link = mv88e6xxx_port_set_link,
3298 .port_set_duplex = mv88e6xxx_port_set_duplex,
3299 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3300 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003301 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003302 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003303 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003304 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003305 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003306 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003307 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003308 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003309 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003310 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003311 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003312 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003313 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3314 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003315 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003316 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3317 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003318 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003319 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003320 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003321 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003322 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3323 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003324 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003325 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003326 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003327};
3328
3329static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003330 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003331 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003332 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3333 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003334 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3335 .phy_read = mv88e6xxx_g2_smi_phy_read,
3336 .phy_write = mv88e6xxx_g2_smi_phy_write,
3337 .port_set_link = mv88e6xxx_port_set_link,
3338 .port_set_duplex = mv88e6xxx_port_set_duplex,
3339 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3340 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003341 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003342 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003343 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003344 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003345 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003346 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003347 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003348 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003349 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003350 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003351 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003352 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003353 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3354 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003355 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003356 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3357 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003358 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003359 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003360 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003361 .reset = mv88e6352_g1_reset,
Vivien Didelot931d1822017-05-01 14:05:27 -04003362 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3363 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003364 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003365 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003366 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003367};
3368
Vivien Didelotf81ec902016-05-09 13:22:58 -04003369static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3370 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003371 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003372 .family = MV88E6XXX_FAMILY_6097,
3373 .name = "Marvell 88E6085",
3374 .num_databases = 4096,
3375 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003376 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003377 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003378 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003379 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003380 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003381 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003382 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003383 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003384 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003385 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003386 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003387 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003388 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003389 },
3390
3391 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003392 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003393 .family = MV88E6XXX_FAMILY_6095,
3394 .name = "Marvell 88E6095/88E6095F",
3395 .num_databases = 256,
3396 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003397 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003398 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003399 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003400 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003401 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003402 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003403 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003404 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003405 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003406 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003407 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003408 },
3409
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003410 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003411 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003412 .family = MV88E6XXX_FAMILY_6097,
3413 .name = "Marvell 88E6097/88E6097F",
3414 .num_databases = 4096,
3415 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003416 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003417 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003418 .port_base_addr = 0x10,
3419 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003420 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003421 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003422 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003423 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003424 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003425 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003426 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003427 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003428 .ops = &mv88e6097_ops,
3429 },
3430
Vivien Didelotf81ec902016-05-09 13:22:58 -04003431 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003432 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003433 .family = MV88E6XXX_FAMILY_6165,
3434 .name = "Marvell 88E6123",
3435 .num_databases = 4096,
3436 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003437 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003438 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003439 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003440 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003441 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003442 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003443 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003444 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003445 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003446 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003447 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003448 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003449 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003450 },
3451
3452 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003453 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003454 .family = MV88E6XXX_FAMILY_6185,
3455 .name = "Marvell 88E6131",
3456 .num_databases = 256,
3457 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003458 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003459 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003460 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003461 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003462 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003463 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003464 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003465 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003466 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003467 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003468 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003469 },
3470
Vivien Didelot990e27b2017-03-28 13:50:32 -04003471 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003472 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003473 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003474 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003475 .num_databases = 4096,
3476 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003477 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003478 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003479 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003480 .port_base_addr = 0x10,
3481 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003482 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003483 .age_time_coeff = 3750,
3484 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003485 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003486 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003487 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003488 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003489 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003490 .ops = &mv88e6141_ops,
3491 },
3492
Vivien Didelotf81ec902016-05-09 13:22:58 -04003493 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003494 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003495 .family = MV88E6XXX_FAMILY_6165,
3496 .name = "Marvell 88E6161",
3497 .num_databases = 4096,
3498 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003499 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003500 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003501 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003502 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003503 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003504 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003505 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003506 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003507 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003508 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003509 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003510 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003511 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003512 },
3513
3514 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003515 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003516 .family = MV88E6XXX_FAMILY_6165,
3517 .name = "Marvell 88E6165",
3518 .num_databases = 4096,
3519 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003520 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003521 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003522 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003523 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003524 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003525 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003526 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003527 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003528 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003529 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003530 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003531 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003532 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003533 },
3534
3535 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003536 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003537 .family = MV88E6XXX_FAMILY_6351,
3538 .name = "Marvell 88E6171",
3539 .num_databases = 4096,
3540 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003541 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003542 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003543 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003544 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003545 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003546 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003547 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003548 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003549 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003550 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003551 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003552 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003553 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003554 },
3555
3556 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003557 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003558 .family = MV88E6XXX_FAMILY_6352,
3559 .name = "Marvell 88E6172",
3560 .num_databases = 4096,
3561 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003562 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003563 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003564 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003565 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003566 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003567 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003568 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003569 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003570 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003571 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003572 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003573 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003574 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003575 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003576 },
3577
3578 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003579 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003580 .family = MV88E6XXX_FAMILY_6351,
3581 .name = "Marvell 88E6175",
3582 .num_databases = 4096,
3583 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003584 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003585 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003586 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003587 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003588 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003589 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003590 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003591 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003592 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003593 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003594 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003595 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003596 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003597 },
3598
3599 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003600 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003601 .family = MV88E6XXX_FAMILY_6352,
3602 .name = "Marvell 88E6176",
3603 .num_databases = 4096,
3604 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003605 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003606 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003607 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003608 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003609 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003610 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003611 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003612 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003613 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003614 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003615 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003616 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003617 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003618 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003619 },
3620
3621 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003622 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003623 .family = MV88E6XXX_FAMILY_6185,
3624 .name = "Marvell 88E6185",
3625 .num_databases = 256,
3626 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003627 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003628 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003629 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003630 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003631 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003632 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003633 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003634 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003635 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003636 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003637 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003638 },
3639
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003640 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003641 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003642 .family = MV88E6XXX_FAMILY_6390,
3643 .name = "Marvell 88E6190",
3644 .num_databases = 4096,
3645 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003646 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003647 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003648 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003649 .port_base_addr = 0x0,
3650 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003651 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003652 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003653 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003654 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003655 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003656 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003657 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003658 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003659 .ops = &mv88e6190_ops,
3660 },
3661
3662 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003663 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003664 .family = MV88E6XXX_FAMILY_6390,
3665 .name = "Marvell 88E6190X",
3666 .num_databases = 4096,
3667 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003668 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003669 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003670 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003671 .port_base_addr = 0x0,
3672 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003673 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003674 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003675 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003676 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003677 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003678 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003679 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003680 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003681 .ops = &mv88e6190x_ops,
3682 },
3683
3684 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003685 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003686 .family = MV88E6XXX_FAMILY_6390,
3687 .name = "Marvell 88E6191",
3688 .num_databases = 4096,
3689 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003690 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04003691 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003692 .port_base_addr = 0x0,
3693 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003694 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003695 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003696 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003697 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003698 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003699 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003700 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003701 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003702 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003703 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003704 },
3705
Vivien Didelotf81ec902016-05-09 13:22:58 -04003706 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003707 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003708 .family = MV88E6XXX_FAMILY_6352,
3709 .name = "Marvell 88E6240",
3710 .num_databases = 4096,
3711 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003712 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003713 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003714 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003715 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003716 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003717 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003718 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003719 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003720 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003721 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003722 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003723 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003724 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003725 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003726 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003727 },
3728
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003729 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003730 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003731 .family = MV88E6XXX_FAMILY_6390,
3732 .name = "Marvell 88E6290",
3733 .num_databases = 4096,
3734 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003735 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003736 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003737 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003738 .port_base_addr = 0x0,
3739 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003740 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003741 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003742 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003743 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003744 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003745 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003746 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003747 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003748 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003749 .ops = &mv88e6290_ops,
3750 },
3751
Vivien Didelotf81ec902016-05-09 13:22:58 -04003752 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003753 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003754 .family = MV88E6XXX_FAMILY_6320,
3755 .name = "Marvell 88E6320",
3756 .num_databases = 4096,
3757 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003758 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003759 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003760 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003761 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003762 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003763 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003764 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003765 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003766 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003767 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003768 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003769 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003770 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003771 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003772 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003773 },
3774
3775 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003776 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003777 .family = MV88E6XXX_FAMILY_6320,
3778 .name = "Marvell 88E6321",
3779 .num_databases = 4096,
3780 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003781 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003782 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003783 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003784 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003785 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003786 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003787 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003788 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003789 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003790 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003791 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003792 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003793 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003794 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003795 },
3796
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003797 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003798 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003799 .family = MV88E6XXX_FAMILY_6341,
3800 .name = "Marvell 88E6341",
3801 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01003802 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003803 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003804 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003805 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003806 .port_base_addr = 0x10,
3807 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003808 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003809 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003810 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003811 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003812 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003813 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003814 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003815 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003816 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003817 .ops = &mv88e6341_ops,
3818 },
3819
Vivien Didelotf81ec902016-05-09 13:22:58 -04003820 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003821 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003822 .family = MV88E6XXX_FAMILY_6351,
3823 .name = "Marvell 88E6350",
3824 .num_databases = 4096,
3825 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003826 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003827 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003828 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003829 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003830 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003831 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003832 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003833 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003834 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003835 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003836 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003837 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003838 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003839 },
3840
3841 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003842 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003843 .family = MV88E6XXX_FAMILY_6351,
3844 .name = "Marvell 88E6351",
3845 .num_databases = 4096,
3846 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003847 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003848 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003849 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003850 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003851 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003852 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003853 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003854 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003855 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003856 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003857 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003858 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003859 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003860 },
3861
3862 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003863 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003864 .family = MV88E6XXX_FAMILY_6352,
3865 .name = "Marvell 88E6352",
3866 .num_databases = 4096,
3867 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003868 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003869 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003870 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003871 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003872 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003873 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003874 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003875 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003876 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003877 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003878 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003879 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003880 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003881 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003882 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003883 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003884 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003885 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003886 .family = MV88E6XXX_FAMILY_6390,
3887 .name = "Marvell 88E6390",
3888 .num_databases = 4096,
3889 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003890 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003891 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003892 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003893 .port_base_addr = 0x0,
3894 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003895 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003896 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003897 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003898 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003899 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003900 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003901 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003902 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003903 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003904 .ops = &mv88e6390_ops,
3905 },
3906 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003907 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003908 .family = MV88E6XXX_FAMILY_6390,
3909 .name = "Marvell 88E6390X",
3910 .num_databases = 4096,
3911 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003912 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003913 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003914 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003915 .port_base_addr = 0x0,
3916 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003917 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003918 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003919 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003920 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003921 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003922 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003923 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003924 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003925 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003926 .ops = &mv88e6390x_ops,
3927 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04003928};
3929
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003930static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04003931{
Vivien Didelota439c062016-04-17 13:23:58 -04003932 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04003933
Vivien Didelot5f7c0362016-06-20 13:14:04 -04003934 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
3935 if (mv88e6xxx_table[i].prod_num == prod_num)
3936 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04003937
Vivien Didelotb9b37712015-10-30 19:39:48 -04003938 return NULL;
3939}
3940
Vivien Didelotfad09c72016-06-21 12:28:20 -04003941static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003942{
3943 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003944 unsigned int prod_num, rev;
3945 u16 id;
3946 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003947
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003948 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04003949 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04003950 mutex_unlock(&chip->reg_lock);
3951 if (err)
3952 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003953
Vivien Didelot107fcc12017-06-12 12:37:36 -04003954 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
3955 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003956
3957 info = mv88e6xxx_lookup_info(prod_num);
3958 if (!info)
3959 return -ENODEV;
3960
Vivien Didelotcaac8542016-06-20 13:14:09 -04003961 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04003962 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003963
Vivien Didelotca070c12016-09-02 14:45:34 -04003964 err = mv88e6xxx_g2_require(chip);
3965 if (err)
3966 return err;
3967
Vivien Didelotfad09c72016-06-21 12:28:20 -04003968 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
3969 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04003970
3971 return 0;
3972}
3973
Vivien Didelotfad09c72016-06-21 12:28:20 -04003974static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04003975{
Vivien Didelotfad09c72016-06-21 12:28:20 -04003976 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003977
Vivien Didelotfad09c72016-06-21 12:28:20 -04003978 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
3979 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04003980 return NULL;
3981
Vivien Didelotfad09c72016-06-21 12:28:20 -04003982 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04003983
Vivien Didelotfad09c72016-06-21 12:28:20 -04003984 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003985 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04003986
Vivien Didelotfad09c72016-06-21 12:28:20 -04003987 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04003988}
3989
Vivien Didelotfad09c72016-06-21 12:28:20 -04003990static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04003991 struct mii_bus *bus, int sw_addr)
3992{
Vivien Didelot914b32f2016-06-20 13:14:11 -04003993 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003994 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003995 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04003996 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04003997 else
3998 return -EINVAL;
3999
Vivien Didelotfad09c72016-06-21 12:28:20 -04004000 chip->bus = bus;
4001 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004002
4003 return 0;
4004}
4005
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004006static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4007 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004008{
Vivien Didelot04bed142016-08-31 18:06:13 -04004009 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004010
Andrew Lunn443d5a12016-12-03 04:35:18 +01004011 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004012}
4013
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004014#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004015static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4016 struct device *host_dev, int sw_addr,
4017 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004018{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004019 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004020 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004021 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004022
Vivien Didelota439c062016-04-17 13:23:58 -04004023 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004024 if (!bus)
4025 return NULL;
4026
Vivien Didelotfad09c72016-06-21 12:28:20 -04004027 chip = mv88e6xxx_alloc_chip(dsa_dev);
4028 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004029 return NULL;
4030
Vivien Didelotcaac8542016-06-20 13:14:09 -04004031 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004032 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004033
Vivien Didelotfad09c72016-06-21 12:28:20 -04004034 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004035 if (err)
4036 goto free;
4037
Vivien Didelotfad09c72016-06-21 12:28:20 -04004038 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004039 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004040 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004041
Andrew Lunndc30c352016-10-16 19:56:49 +02004042 mutex_lock(&chip->reg_lock);
4043 err = mv88e6xxx_switch_reset(chip);
4044 mutex_unlock(&chip->reg_lock);
4045 if (err)
4046 goto free;
4047
Vivien Didelote57e5e72016-08-15 17:19:00 -04004048 mv88e6xxx_phy_init(chip);
4049
Andrew Lunna3c53be52017-01-24 14:53:50 +01004050 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004051 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004052 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004053
Vivien Didelotfad09c72016-06-21 12:28:20 -04004054 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004055
Vivien Didelotfad09c72016-06-21 12:28:20 -04004056 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004057free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004058 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004059
4060 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004061}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004062#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004063
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004064static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004065 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004066{
4067 /* We don't need any dynamic resource from the kernel (yet),
4068 * so skip the prepare phase.
4069 */
4070
4071 return 0;
4072}
4073
4074static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004075 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004076{
Vivien Didelot04bed142016-08-31 18:06:13 -04004077 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004078
4079 mutex_lock(&chip->reg_lock);
4080 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004081 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004082 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4083 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004084 mutex_unlock(&chip->reg_lock);
4085}
4086
4087static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4088 const struct switchdev_obj_port_mdb *mdb)
4089{
Vivien Didelot04bed142016-08-31 18:06:13 -04004090 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004091 int err;
4092
4093 mutex_lock(&chip->reg_lock);
4094 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004095 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004096 mutex_unlock(&chip->reg_lock);
4097
4098 return err;
4099}
4100
Florian Fainellia82f67a2017-01-08 14:52:08 -08004101static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004102#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004103 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004104#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004105 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004106 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004107 .adjust_link = mv88e6xxx_adjust_link,
4108 .get_strings = mv88e6xxx_get_strings,
4109 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4110 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004111 .port_enable = mv88e6xxx_port_enable,
4112 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004113 .get_mac_eee = mv88e6xxx_get_mac_eee,
4114 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004115 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004116 .get_eeprom = mv88e6xxx_get_eeprom,
4117 .set_eeprom = mv88e6xxx_set_eeprom,
4118 .get_regs_len = mv88e6xxx_get_regs_len,
4119 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004120 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004121 .port_bridge_join = mv88e6xxx_port_bridge_join,
4122 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4123 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004124 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004125 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4126 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4127 .port_vlan_add = mv88e6xxx_port_vlan_add,
4128 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004129 .port_fdb_add = mv88e6xxx_port_fdb_add,
4130 .port_fdb_del = mv88e6xxx_port_fdb_del,
4131 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004132 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4133 .port_mdb_add = mv88e6xxx_port_mdb_add,
4134 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004135 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4136 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004137 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4138 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4139 .port_txtstamp = mv88e6xxx_port_txtstamp,
4140 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4141 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004142};
4143
Florian Fainelliab3d4082017-01-08 14:52:07 -08004144static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4145 .ops = &mv88e6xxx_switch_ops,
4146};
4147
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004148static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004149{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004150 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004151 struct dsa_switch *ds;
4152
Vivien Didelot73b12042017-03-30 17:37:10 -04004153 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004154 if (!ds)
4155 return -ENOMEM;
4156
Vivien Didelotfad09c72016-06-21 12:28:20 -04004157 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004158 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004159 ds->ageing_time_min = chip->info->age_time_coeff;
4160 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004161
4162 dev_set_drvdata(dev, ds);
4163
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004164 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004165}
4166
Vivien Didelotfad09c72016-06-21 12:28:20 -04004167static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004168{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004169 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004170}
4171
Vivien Didelot57d32312016-06-20 13:13:58 -04004172static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004173{
4174 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004175 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004176 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004177 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004178 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02004179 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004180
Vivien Didelotcaac8542016-06-20 13:14:09 -04004181 compat_info = of_device_get_match_data(dev);
4182 if (!compat_info)
4183 return -EINVAL;
4184
Vivien Didelotfad09c72016-06-21 12:28:20 -04004185 chip = mv88e6xxx_alloc_chip(dev);
4186 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004187 return -ENOMEM;
4188
Vivien Didelotfad09c72016-06-21 12:28:20 -04004189 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004190
Vivien Didelotfad09c72016-06-21 12:28:20 -04004191 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004192 if (err)
4193 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004194
Andrew Lunnb4308f02016-11-21 23:26:55 +01004195 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
4196 if (IS_ERR(chip->reset))
4197 return PTR_ERR(chip->reset);
4198
Vivien Didelotfad09c72016-06-21 12:28:20 -04004199 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004200 if (err)
4201 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004202
Vivien Didelote57e5e72016-08-15 17:19:00 -04004203 mv88e6xxx_phy_init(chip);
4204
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004205 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004206 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004207 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004208
Andrew Lunndc30c352016-10-16 19:56:49 +02004209 mutex_lock(&chip->reg_lock);
4210 err = mv88e6xxx_switch_reset(chip);
4211 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004212 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004213 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004214
Andrew Lunndc30c352016-10-16 19:56:49 +02004215 chip->irq = of_irq_get(np, 0);
4216 if (chip->irq == -EPROBE_DEFER) {
4217 err = chip->irq;
4218 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004219 }
4220
Andrew Lunn294d7112018-02-22 22:58:32 +01004221 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004222 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004223 * controllers
4224 */
4225 mutex_lock(&chip->reg_lock);
4226 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004227 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004228 else
4229 err = mv88e6xxx_irq_poll_setup(chip);
4230 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004231
Andrew Lunn294d7112018-02-22 22:58:32 +01004232 if (err)
4233 goto out;
4234
4235 if (chip->info->g2_irqs > 0) {
4236 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004237 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004238 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004239 }
4240
Andrew Lunn294d7112018-02-22 22:58:32 +01004241 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4242 if (err)
4243 goto out_g2_irq;
4244
4245 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4246 if (err)
4247 goto out_g1_atu_prob_irq;
4248
Andrew Lunna3c53be52017-01-24 14:53:50 +01004249 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004250 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004251 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004252
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004253 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004254 if (err)
4255 goto out_mdio;
4256
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004257 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004258
4259out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004260 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004261out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004262 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004263out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004264 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004265out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004266 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004267 mv88e6xxx_g2_irq_free(chip);
4268out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004269 mutex_lock(&chip->reg_lock);
4270 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004271 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004272 else
4273 mv88e6xxx_irq_poll_free(chip);
4274 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004275out:
4276 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004277}
4278
4279static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4280{
4281 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004282 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004283
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004284 if (chip->info->ptp_support) {
4285 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004286 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004287 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004288
Andrew Lunn930188c2016-08-22 16:01:03 +02004289 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004290 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004291 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004292
Andrew Lunn76f38f12018-03-17 20:21:09 +01004293 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4294 mv88e6xxx_g1_atu_prob_irq_free(chip);
4295
4296 if (chip->info->g2_irqs > 0)
4297 mv88e6xxx_g2_irq_free(chip);
4298
4299 mutex_lock(&chip->reg_lock);
4300 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004301 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004302 else
4303 mv88e6xxx_irq_poll_free(chip);
4304 mutex_unlock(&chip->reg_lock);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004305}
4306
4307static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004308 {
4309 .compatible = "marvell,mv88e6085",
4310 .data = &mv88e6xxx_table[MV88E6085],
4311 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004312 {
4313 .compatible = "marvell,mv88e6190",
4314 .data = &mv88e6xxx_table[MV88E6190],
4315 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004316 { /* sentinel */ },
4317};
4318
4319MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4320
4321static struct mdio_driver mv88e6xxx_driver = {
4322 .probe = mv88e6xxx_probe,
4323 .remove = mv88e6xxx_remove,
4324 .mdiodrv.driver = {
4325 .name = "mv88e6085",
4326 .of_match_table = mv88e6xxx_of_match,
4327 },
4328};
4329
Ben Hutchings98e67302011-11-25 14:36:19 +00004330static int __init mv88e6xxx_init(void)
4331{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004332 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004333 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004334}
4335module_init(mv88e6xxx_init);
4336
4337static void __exit mv88e6xxx_cleanup(void)
4338{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004339 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004340 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004341}
4342module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004343
4344MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4345MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4346MODULE_LICENSE("GPL");