blob: b23c11d9f4b20d400f77140142607ce42599011f [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>
Russell Kingc9a23562018-05-10 13:17:35 -070034#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000035#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040036
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040037#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040038#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040039#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010040#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020041#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010042#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010043#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020044#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000045
Vivien Didelotfad09c72016-06-21 12:28:20 -040046static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040047{
Vivien Didelotfad09c72016-06-21 12:28:20 -040048 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
49 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040050 dump_stack();
51 }
52}
53
Vivien Didelot914b32f2016-06-20 13:14:11 -040054/* The switch ADDR[4:1] configuration pins define the chip SMI device address
55 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
56 *
57 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
58 * is the only device connected to the SMI master. In this mode it responds to
59 * all 32 possible SMI addresses, and thus maps directly the internal devices.
60 *
61 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
62 * multiple devices to share the SMI interface. In this mode it responds to only
63 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000064 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040065
Vivien Didelotfad09c72016-06-21 12:28:20 -040066static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040067 int addr, int reg, u16 *val)
68{
Vivien Didelotfad09c72016-06-21 12:28:20 -040069 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040070 return -EOPNOTSUPP;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073}
74
Vivien Didelotfad09c72016-06-21 12:28:20 -040075static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040076 int addr, int reg, u16 val)
77{
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 return -EOPNOTSUPP;
80
Vivien Didelotfad09c72016-06-21 12:28:20 -040081 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040082}
83
Vivien Didelotfad09c72016-06-21 12:28:20 -040084static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040085 int addr, int reg, u16 *val)
86{
87 int ret;
88
Vivien Didelotfad09c72016-06-21 12:28:20 -040089 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040090 if (ret < 0)
91 return ret;
92
93 *val = ret & 0xffff;
94
95 return 0;
96}
97
Vivien Didelotfad09c72016-06-21 12:28:20 -040098static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040099 int addr, int reg, u16 val)
100{
101 int ret;
102
Vivien Didelotfad09c72016-06-21 12:28:20 -0400103 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400104 if (ret < 0)
105 return ret;
106
107 return 0;
108}
109
Vivien Didelotc08026a2016-09-29 12:21:59 -0400110static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400111 .read = mv88e6xxx_smi_single_chip_read,
112 .write = mv88e6xxx_smi_single_chip_write,
113};
114
Vivien Didelotfad09c72016-06-21 12:28:20 -0400115static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000116{
117 int ret;
118 int i;
119
120 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400121 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000122 if (ret < 0)
123 return ret;
124
Andrew Lunncca8b132015-04-02 04:06:39 +0200125 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000126 return 0;
127 }
128
129 return -ETIMEDOUT;
130}
131
Vivien Didelotfad09c72016-06-21 12:28:20 -0400132static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400133 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000134{
135 int ret;
136
Barry Grussling3675c8d2013-01-08 16:05:53 +0000137 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400138 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000139 if (ret < 0)
140 return ret;
141
Barry Grussling3675c8d2013-01-08 16:05:53 +0000142 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400143 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200144 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000145 if (ret < 0)
146 return ret;
147
Barry Grussling3675c8d2013-01-08 16:05:53 +0000148 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400149 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000150 if (ret < 0)
151 return ret;
152
Barry Grussling3675c8d2013-01-08 16:05:53 +0000153 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400154 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000155 if (ret < 0)
156 return ret;
157
Vivien Didelot914b32f2016-06-20 13:14:11 -0400158 *val = ret & 0xffff;
159
160 return 0;
161}
162
Vivien Didelotfad09c72016-06-21 12:28:20 -0400163static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400164 int addr, int reg, u16 val)
165{
166 int ret;
167
168 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400169 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400170 if (ret < 0)
171 return ret;
172
173 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400174 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400175 if (ret < 0)
176 return ret;
177
178 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400179 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400180 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
181 if (ret < 0)
182 return ret;
183
184 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400185 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400186 if (ret < 0)
187 return ret;
188
189 return 0;
190}
191
Vivien Didelotc08026a2016-09-29 12:21:59 -0400192static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400193 .read = mv88e6xxx_smi_multi_chip_read,
194 .write = mv88e6xxx_smi_multi_chip_write,
195};
196
Vivien Didelotec561272016-09-02 14:45:33 -0400197int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400198{
199 int err;
200
Vivien Didelotfad09c72016-06-21 12:28:20 -0400201 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400202
Vivien Didelotfad09c72016-06-21 12:28:20 -0400203 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400204 if (err)
205 return err;
206
Vivien Didelotfad09c72016-06-21 12:28:20 -0400207 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400208 addr, reg, *val);
209
210 return 0;
211}
212
Vivien Didelotec561272016-09-02 14:45:33 -0400213int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400214{
215 int err;
216
Vivien Didelotfad09c72016-06-21 12:28:20 -0400217 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400218
Vivien Didelotfad09c72016-06-21 12:28:20 -0400219 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400220 if (err)
221 return err;
222
Vivien Didelotfad09c72016-06-21 12:28:20 -0400223 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400224 addr, reg, val);
225
226 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000227}
228
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200229struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100230{
231 struct mv88e6xxx_mdio_bus *mdio_bus;
232
233 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
234 list);
235 if (!mdio_bus)
236 return NULL;
237
238 return mdio_bus->bus;
239}
240
Andrew Lunndc30c352016-10-16 19:56:49 +0200241static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
242{
243 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
244 unsigned int n = d->hwirq;
245
246 chip->g1_irq.masked |= (1 << n);
247}
248
249static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
250{
251 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
252 unsigned int n = d->hwirq;
253
254 chip->g1_irq.masked &= ~(1 << n);
255}
256
Andrew Lunn294d7112018-02-22 22:58:32 +0100257static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200258{
Andrew Lunndc30c352016-10-16 19:56:49 +0200259 unsigned int nhandled = 0;
260 unsigned int sub_irq;
261 unsigned int n;
262 u16 reg;
263 int err;
264
265 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400266 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200267 mutex_unlock(&chip->reg_lock);
268
269 if (err)
270 goto out;
271
272 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
273 if (reg & (1 << n)) {
274 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
275 handle_nested_irq(sub_irq);
276 ++nhandled;
277 }
278 }
279out:
280 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
281}
282
Andrew Lunn294d7112018-02-22 22:58:32 +0100283static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
284{
285 struct mv88e6xxx_chip *chip = dev_id;
286
287 return mv88e6xxx_g1_irq_thread_work(chip);
288}
289
Andrew Lunndc30c352016-10-16 19:56:49 +0200290static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
291{
292 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
293
294 mutex_lock(&chip->reg_lock);
295}
296
297static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
298{
299 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
300 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
301 u16 reg;
302 int err;
303
Vivien Didelotd77f4322017-06-15 12:14:03 -0400304 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200305 if (err)
306 goto out;
307
308 reg &= ~mask;
309 reg |= (~chip->g1_irq.masked & mask);
310
Vivien Didelotd77f4322017-06-15 12:14:03 -0400311 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200312 if (err)
313 goto out;
314
315out:
316 mutex_unlock(&chip->reg_lock);
317}
318
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530319static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200320 .name = "mv88e6xxx-g1",
321 .irq_mask = mv88e6xxx_g1_irq_mask,
322 .irq_unmask = mv88e6xxx_g1_irq_unmask,
323 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
324 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
325};
326
327static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
328 unsigned int irq,
329 irq_hw_number_t hwirq)
330{
331 struct mv88e6xxx_chip *chip = d->host_data;
332
333 irq_set_chip_data(irq, d->host_data);
334 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
335 irq_set_noprobe(irq);
336
337 return 0;
338}
339
340static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
341 .map = mv88e6xxx_g1_irq_domain_map,
342 .xlate = irq_domain_xlate_twocell,
343};
344
Andrew Lunn294d7112018-02-22 22:58:32 +0100345static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200346{
347 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100348 u16 mask;
349
Vivien Didelotd77f4322017-06-15 12:14:03 -0400350 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100351 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400352 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100353
Andreas Färber5edef2f2016-11-27 23:26:28 +0100354 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100355 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200356 irq_dispose_mapping(virq);
357 }
358
Andrew Lunna3db3d32016-11-20 20:14:14 +0100359 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200360}
361
Andrew Lunn294d7112018-02-22 22:58:32 +0100362static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
363{
Andrew Lunnb19e5c12018-03-08 21:21:36 +0100364 mv88e6xxx_g1_irq_free_common(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100365
366 free_irq(chip->irq, chip);
367}
368
369static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200370{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100371 int err, irq, virq;
372 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200373
374 chip->g1_irq.nirqs = chip->info->g1_irqs;
375 chip->g1_irq.domain = irq_domain_add_simple(
376 NULL, chip->g1_irq.nirqs, 0,
377 &mv88e6xxx_g1_irq_domain_ops, chip);
378 if (!chip->g1_irq.domain)
379 return -ENOMEM;
380
381 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
382 irq_create_mapping(chip->g1_irq.domain, irq);
383
384 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
385 chip->g1_irq.masked = ~0;
386
Vivien Didelotd77f4322017-06-15 12:14:03 -0400387 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200388 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100389 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200390
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100391 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200392
Vivien Didelotd77f4322017-06-15 12:14:03 -0400393 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200394 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100395 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200396
397 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400398 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200399 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100400 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200401
Andrew Lunndc30c352016-10-16 19:56:49 +0200402 return 0;
403
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100404out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100405 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400406 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100407
408out_mapping:
409 for (irq = 0; irq < 16; irq++) {
410 virq = irq_find_mapping(chip->g1_irq.domain, irq);
411 irq_dispose_mapping(virq);
412 }
413
414 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200415
416 return err;
417}
418
Andrew Lunn294d7112018-02-22 22:58:32 +0100419static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
420{
421 int err;
422
423 err = mv88e6xxx_g1_irq_setup_common(chip);
424 if (err)
425 return err;
426
427 err = request_threaded_irq(chip->irq, NULL,
428 mv88e6xxx_g1_irq_thread_fn,
Andrew Lunn422a9fd62018-03-25 23:43:14 +0200429 IRQF_ONESHOT,
Andrew Lunn294d7112018-02-22 22:58:32 +0100430 dev_name(chip->dev), chip);
431 if (err)
432 mv88e6xxx_g1_irq_free_common(chip);
433
434 return err;
435}
436
437static void mv88e6xxx_irq_poll(struct kthread_work *work)
438{
439 struct mv88e6xxx_chip *chip = container_of(work,
440 struct mv88e6xxx_chip,
441 irq_poll_work.work);
442 mv88e6xxx_g1_irq_thread_work(chip);
443
444 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
445 msecs_to_jiffies(100));
446}
447
448static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
449{
450 int err;
451
452 err = mv88e6xxx_g1_irq_setup_common(chip);
453 if (err)
454 return err;
455
456 kthread_init_delayed_work(&chip->irq_poll_work,
457 mv88e6xxx_irq_poll);
458
459 chip->kworker = kthread_create_worker(0, dev_name(chip->dev));
460 if (IS_ERR(chip->kworker))
461 return PTR_ERR(chip->kworker);
462
463 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
464 msecs_to_jiffies(100));
465
466 return 0;
467}
468
469static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
470{
Andrew Lunn71f74ae2018-03-25 23:43:15 +0200471 mv88e6xxx_g1_irq_free_common(chip);
472
Andrew Lunn294d7112018-02-22 22:58:32 +0100473 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
474 kthread_destroy_worker(chip->kworker);
475}
476
Vivien Didelotec561272016-09-02 14:45:33 -0400477int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400478{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200479 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400480
Andrew Lunn6441e6692016-08-19 00:01:55 +0200481 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400482 u16 val;
483 int err;
484
485 err = mv88e6xxx_read(chip, addr, reg, &val);
486 if (err)
487 return err;
488
489 if (!(val & mask))
490 return 0;
491
492 usleep_range(1000, 2000);
493 }
494
Andrew Lunn30853552016-08-19 00:01:57 +0200495 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400496 return -ETIMEDOUT;
497}
498
Vivien Didelotf22ab642016-07-18 20:45:31 -0400499/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400500int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400501{
502 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200503 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400504
505 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200506 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
507 if (err)
508 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400509
510 /* Set the Update bit to trigger a write operation */
511 val = BIT(15) | update;
512
513 return mv88e6xxx_write(chip, addr, reg, val);
514}
515
Vivien Didelotd78343d2016-11-04 03:23:36 +0100516static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
517 int link, int speed, int duplex,
518 phy_interface_t mode)
519{
520 int err;
521
522 if (!chip->info->ops->port_set_link)
523 return 0;
524
525 /* Port's MAC control must not be changed unless the link is down */
526 err = chip->info->ops->port_set_link(chip, port, 0);
527 if (err)
528 return err;
529
530 if (chip->info->ops->port_set_speed) {
531 err = chip->info->ops->port_set_speed(chip, port, speed);
532 if (err && err != -EOPNOTSUPP)
533 goto restore_link;
534 }
535
536 if (chip->info->ops->port_set_duplex) {
537 err = chip->info->ops->port_set_duplex(chip, port, duplex);
538 if (err && err != -EOPNOTSUPP)
539 goto restore_link;
540 }
541
542 if (chip->info->ops->port_set_rgmii_delay) {
543 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
544 if (err && err != -EOPNOTSUPP)
545 goto restore_link;
546 }
547
Andrew Lunnf39908d2017-02-04 20:02:50 +0100548 if (chip->info->ops->port_set_cmode) {
549 err = chip->info->ops->port_set_cmode(chip, port, mode);
550 if (err && err != -EOPNOTSUPP)
551 goto restore_link;
552 }
553
Vivien Didelotd78343d2016-11-04 03:23:36 +0100554 err = 0;
555restore_link:
556 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400557 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100558
559 return err;
560}
561
Andrew Lunndea87022015-08-31 15:56:47 +0200562/* We expect the switch to perform auto negotiation if there is a real
563 * phy. However, in the case of a fixed link phy, we force the port
564 * settings from the fixed link settings.
565 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400566static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
567 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200568{
Vivien Didelot04bed142016-08-31 18:06:13 -0400569 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200570 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200571
572 if (!phy_is_pseudo_fixed_link(phydev))
573 return;
574
Vivien Didelotfad09c72016-06-21 12:28:20 -0400575 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100576 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
577 phydev->duplex, phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400578 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100579
580 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400581 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200582}
583
Russell Kingc9a23562018-05-10 13:17:35 -0700584static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
585 unsigned long *supported,
586 struct phylink_link_state *state)
587{
588}
589
590static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
591 struct phylink_link_state *state)
592{
593 struct mv88e6xxx_chip *chip = ds->priv;
594 int err;
595
596 mutex_lock(&chip->reg_lock);
597 err = mv88e6xxx_port_link_state(chip, port, state);
598 mutex_unlock(&chip->reg_lock);
599
600 return err;
601}
602
603static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
604 unsigned int mode,
605 const struct phylink_link_state *state)
606{
607 struct mv88e6xxx_chip *chip = ds->priv;
608 int speed, duplex, link, err;
609
610 if (mode == MLO_AN_PHY)
611 return;
612
613 if (mode == MLO_AN_FIXED) {
614 link = LINK_FORCED_UP;
615 speed = state->speed;
616 duplex = state->duplex;
617 } else {
618 speed = SPEED_UNFORCED;
619 duplex = DUPLEX_UNFORCED;
620 link = LINK_UNFORCED;
621 }
622
623 mutex_lock(&chip->reg_lock);
624 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex,
625 state->interface);
626 mutex_unlock(&chip->reg_lock);
627
628 if (err && err != -EOPNOTSUPP)
629 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
630}
631
632static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
633{
634 struct mv88e6xxx_chip *chip = ds->priv;
635 int err;
636
637 mutex_lock(&chip->reg_lock);
638 err = chip->info->ops->port_set_link(chip, port, link);
639 mutex_unlock(&chip->reg_lock);
640
641 if (err)
642 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
643}
644
645static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
646 unsigned int mode,
647 phy_interface_t interface)
648{
649 if (mode == MLO_AN_FIXED)
650 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
651}
652
653static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
654 unsigned int mode, phy_interface_t interface,
655 struct phy_device *phydev)
656{
657 if (mode == MLO_AN_FIXED)
658 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
659}
660
Andrew Lunna605a0f2016-11-21 23:26:58 +0100661static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000662{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100663 if (!chip->info->ops->stats_snapshot)
664 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000665
Andrew Lunna605a0f2016-11-21 23:26:58 +0100666 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000667}
668
Andrew Lunne413e7e2015-04-02 04:06:38 +0200669static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100670 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
671 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
672 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
673 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
674 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
675 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
676 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
677 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
678 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
679 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
680 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
681 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
682 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
683 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
684 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
685 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
686 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
687 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
688 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
689 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
690 { "single", 4, 0x14, STATS_TYPE_BANK0, },
691 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
692 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
693 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
694 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
695 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
696 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
697 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
698 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
699 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
700 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
701 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
702 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
703 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
704 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
705 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
706 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
707 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
708 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
709 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
710 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
711 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
712 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
713 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
714 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
715 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
716 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
717 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
718 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
719 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
720 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
721 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
722 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
723 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
724 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
725 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
726 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
727 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
728 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200729};
730
Vivien Didelotfad09c72016-06-21 12:28:20 -0400731static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100732 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100733 int port, u16 bank1_select,
734 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200735{
Andrew Lunn80c46272015-06-20 18:42:30 +0200736 u32 low;
737 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100738 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200739 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200740 u64 value;
741
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100742 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100743 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200744 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
745 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800746 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200747
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200748 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100749 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200750 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
751 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800752 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200753 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200754 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100755 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100756 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100757 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100758 /* fall through */
759 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100760 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100761 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100762 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100763 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500764 break;
765 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800766 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200767 }
768 value = (((u64)high) << 16) | low;
769 return value;
770}
771
Andrew Lunn436fe172018-03-01 02:02:29 +0100772static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
773 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100774{
775 struct mv88e6xxx_hw_stat *stat;
776 int i, j;
777
778 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
779 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100780 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100781 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
782 ETH_GSTRING_LEN);
783 j++;
784 }
785 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100786
787 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100788}
789
Andrew Lunn436fe172018-03-01 02:02:29 +0100790static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
791 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100792{
Andrew Lunn436fe172018-03-01 02:02:29 +0100793 return mv88e6xxx_stats_get_strings(chip, data,
794 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100795}
796
Andrew Lunn436fe172018-03-01 02:02:29 +0100797static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
798 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100799{
Andrew Lunn436fe172018-03-01 02:02:29 +0100800 return mv88e6xxx_stats_get_strings(chip, data,
801 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100802}
803
Andrew Lunn65f60e42018-03-28 23:50:28 +0200804static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
805 "atu_member_violation",
806 "atu_miss_violation",
807 "atu_full_violation",
808 "vtu_member_violation",
809 "vtu_miss_violation",
810};
811
812static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
813{
814 unsigned int i;
815
816 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
817 strlcpy(data + i * ETH_GSTRING_LEN,
818 mv88e6xxx_atu_vtu_stats_strings[i],
819 ETH_GSTRING_LEN);
820}
821
Andrew Lunndfafe442016-11-21 23:27:02 +0100822static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700823 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100824{
Vivien Didelot04bed142016-08-31 18:06:13 -0400825 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100826 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100827
Florian Fainelli89f09042018-04-25 12:12:50 -0700828 if (stringset != ETH_SS_STATS)
829 return;
830
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100831 mutex_lock(&chip->reg_lock);
832
Andrew Lunndfafe442016-11-21 23:27:02 +0100833 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100834 count = chip->info->ops->stats_get_strings(chip, data);
835
836 if (chip->info->ops->serdes_get_strings) {
837 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200838 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100839 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100840
Andrew Lunn65f60e42018-03-28 23:50:28 +0200841 data += count * ETH_GSTRING_LEN;
842 mv88e6xxx_atu_vtu_get_strings(data);
843
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100844 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100845}
846
847static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
848 int types)
849{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100850 struct mv88e6xxx_hw_stat *stat;
851 int i, j;
852
853 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
854 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100855 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100856 j++;
857 }
858 return j;
859}
860
Andrew Lunndfafe442016-11-21 23:27:02 +0100861static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
862{
863 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
864 STATS_TYPE_PORT);
865}
866
867static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
868{
869 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
870 STATS_TYPE_BANK1);
871}
872
Florian Fainelli89f09042018-04-25 12:12:50 -0700873static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100874{
875 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100876 int serdes_count = 0;
877 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100878
Florian Fainelli89f09042018-04-25 12:12:50 -0700879 if (sset != ETH_SS_STATS)
880 return 0;
881
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100882 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100883 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100884 count = chip->info->ops->stats_get_sset_count(chip);
885 if (count < 0)
886 goto out;
887
888 if (chip->info->ops->serdes_get_sset_count)
889 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
890 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200891 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100892 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200893 goto out;
894 }
895 count += serdes_count;
896 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
897
Andrew Lunn436fe172018-03-01 02:02:29 +0100898out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100899 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100900
Andrew Lunn436fe172018-03-01 02:02:29 +0100901 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +0100902}
903
Andrew Lunn436fe172018-03-01 02:02:29 +0100904static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
905 uint64_t *data, int types,
906 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +0100907{
908 struct mv88e6xxx_hw_stat *stat;
909 int i, j;
910
911 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
912 stat = &mv88e6xxx_hw_stats[i];
913 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +0100914 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100915 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
916 bank1_select,
917 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +0100918 mutex_unlock(&chip->reg_lock);
919
Andrew Lunn052f9472016-11-21 23:27:03 +0100920 j++;
921 }
922 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100923 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +0100924}
925
Andrew Lunn436fe172018-03-01 02:02:29 +0100926static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
927 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100928{
929 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100930 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400931 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +0100932}
933
Andrew Lunn436fe172018-03-01 02:02:29 +0100934static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
935 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +0100936{
937 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100938 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400939 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
940 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +0100941}
942
Andrew Lunn436fe172018-03-01 02:02:29 +0100943static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
944 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +0100945{
946 return mv88e6xxx_stats_get_stats(chip, port, data,
947 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -0400948 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
949 0);
Andrew Lunn052f9472016-11-21 23:27:03 +0100950}
951
Andrew Lunn65f60e42018-03-28 23:50:28 +0200952static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
953 uint64_t *data)
954{
955 *data++ = chip->ports[port].atu_member_violation;
956 *data++ = chip->ports[port].atu_miss_violation;
957 *data++ = chip->ports[port].atu_full_violation;
958 *data++ = chip->ports[port].vtu_member_violation;
959 *data++ = chip->ports[port].vtu_miss_violation;
960}
961
Andrew Lunn052f9472016-11-21 23:27:03 +0100962static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
963 uint64_t *data)
964{
Andrew Lunn436fe172018-03-01 02:02:29 +0100965 int count = 0;
966
Andrew Lunn052f9472016-11-21 23:27:03 +0100967 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +0100968 count = chip->info->ops->stats_get_stats(chip, port, data);
969
Andrew Lunn65f60e42018-03-28 23:50:28 +0200970 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +0100971 if (chip->info->ops->serdes_get_stats) {
972 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200973 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100974 }
Andrew Lunn65f60e42018-03-28 23:50:28 +0200975 data += count;
976 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
977 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +0100978}
979
Vivien Didelotf81ec902016-05-09 13:22:58 -0400980static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
981 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000982{
Vivien Didelot04bed142016-08-31 18:06:13 -0400983 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000984 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000985
Vivien Didelotfad09c72016-06-21 12:28:20 -0400986 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000987
Andrew Lunna605a0f2016-11-21 23:26:58 +0100988 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +0100989 mutex_unlock(&chip->reg_lock);
990
991 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000992 return;
Andrew Lunn052f9472016-11-21 23:27:03 +0100993
994 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000995
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000996}
Ben Hutchings98e67302011-11-25 14:36:19 +0000997
Vivien Didelotf81ec902016-05-09 13:22:58 -0400998static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -0700999{
1000 return 32 * sizeof(u16);
1001}
1002
Vivien Didelotf81ec902016-05-09 13:22:58 -04001003static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1004 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001005{
Vivien Didelot04bed142016-08-31 18:06:13 -04001006 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001007 int err;
1008 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001009 u16 *p = _p;
1010 int i;
1011
1012 regs->version = 0;
1013
1014 memset(p, 0xff, 32 * sizeof(u16));
1015
Vivien Didelotfad09c72016-06-21 12:28:20 -04001016 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001017
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001018 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001019
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001020 err = mv88e6xxx_port_read(chip, port, i, &reg);
1021 if (!err)
1022 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001023 }
Vivien Didelot23062512016-05-09 13:22:45 -04001024
Vivien Didelotfad09c72016-06-21 12:28:20 -04001025 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001026}
1027
Vivien Didelot08f50062017-08-01 16:32:41 -04001028static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1029 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001030{
Vivien Didelot5480db62017-08-01 16:32:40 -04001031 /* Nothing to do on the port's MAC */
1032 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001033}
1034
Vivien Didelot08f50062017-08-01 16:32:41 -04001035static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1036 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001037{
Vivien Didelot5480db62017-08-01 16:32:40 -04001038 /* Nothing to do on the port's MAC */
1039 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001040}
1041
Vivien Didelote5887a22017-03-30 17:37:11 -04001042static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001043{
Vivien Didelote5887a22017-03-30 17:37:11 -04001044 struct dsa_switch *ds = NULL;
1045 struct net_device *br;
1046 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001047 int i;
1048
Vivien Didelote5887a22017-03-30 17:37:11 -04001049 if (dev < DSA_MAX_SWITCHES)
1050 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001051
Vivien Didelote5887a22017-03-30 17:37:11 -04001052 /* Prevent frames from unknown switch or port */
1053 if (!ds || port >= ds->num_ports)
1054 return 0;
1055
1056 /* Frames from DSA links and CPU ports can egress any local port */
1057 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1058 return mv88e6xxx_port_mask(chip);
1059
1060 br = ds->ports[port].bridge_dev;
1061 pvlan = 0;
1062
1063 /* Frames from user ports can egress any local DSA links and CPU ports,
1064 * as well as any local member of their bridge group.
1065 */
1066 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1067 if (dsa_is_cpu_port(chip->ds, i) ||
1068 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001069 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001070 pvlan |= BIT(i);
1071
1072 return pvlan;
1073}
1074
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001075static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001076{
1077 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001078
1079 /* prevent frames from going back out of the port they came in on */
1080 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001081
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001082 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001083}
1084
Vivien Didelotf81ec902016-05-09 13:22:58 -04001085static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1086 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001087{
Vivien Didelot04bed142016-08-31 18:06:13 -04001088 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001089 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001090
Vivien Didelotfad09c72016-06-21 12:28:20 -04001091 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001092 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001093 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001094
1095 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001096 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001097}
1098
Vivien Didelot93e18d62018-05-11 17:16:35 -04001099static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1100{
1101 int err;
1102
1103 if (chip->info->ops->ieee_pri_map) {
1104 err = chip->info->ops->ieee_pri_map(chip);
1105 if (err)
1106 return err;
1107 }
1108
1109 if (chip->info->ops->ip_pri_map) {
1110 err = chip->info->ops->ip_pri_map(chip);
1111 if (err)
1112 return err;
1113 }
1114
1115 return 0;
1116}
1117
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001118static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1119{
1120 int target, port;
1121 int err;
1122
1123 if (!chip->info->global2_addr)
1124 return 0;
1125
1126 /* Initialize the routing port to the 32 possible target devices */
1127 for (target = 0; target < 32; target++) {
1128 port = 0x1f;
1129 if (target < DSA_MAX_SWITCHES)
1130 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1131 port = chip->ds->rtable[target];
1132
1133 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1134 if (err)
1135 return err;
1136 }
1137
Vivien Didelot02317e62018-05-09 11:38:49 -04001138 if (chip->info->ops->set_cascade_port) {
1139 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1140 err = chip->info->ops->set_cascade_port(chip, port);
1141 if (err)
1142 return err;
1143 }
1144
Vivien Didelot23c98912018-05-09 11:38:50 -04001145 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1146 if (err)
1147 return err;
1148
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001149 return 0;
1150}
1151
Vivien Didelotb28f8722018-04-26 21:56:44 -04001152static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1153{
1154 /* Clear all trunk masks and mapping */
1155 if (chip->info->global2_addr)
1156 return mv88e6xxx_g2_trunk_clear(chip);
1157
1158 return 0;
1159}
1160
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001161static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1162{
1163 if (chip->info->ops->rmu_disable)
1164 return chip->info->ops->rmu_disable(chip);
1165
1166 return 0;
1167}
1168
Vivien Didelot9e907d72017-07-17 13:03:43 -04001169static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1170{
1171 if (chip->info->ops->pot_clear)
1172 return chip->info->ops->pot_clear(chip);
1173
1174 return 0;
1175}
1176
Vivien Didelot51c901a2017-07-17 13:03:41 -04001177static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1178{
1179 if (chip->info->ops->mgmt_rsvd2cpu)
1180 return chip->info->ops->mgmt_rsvd2cpu(chip);
1181
1182 return 0;
1183}
1184
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001185static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1186{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001187 int err;
1188
Vivien Didelotdaefc942017-03-11 16:12:54 -05001189 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1190 if (err)
1191 return err;
1192
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001193 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1194 if (err)
1195 return err;
1196
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001197 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1198}
1199
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001200static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1201{
1202 int port;
1203 int err;
1204
1205 if (!chip->info->ops->irl_init_all)
1206 return 0;
1207
1208 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1209 /* Disable ingress rate limiting by resetting all per port
1210 * ingress rate limit resources to their initial state.
1211 */
1212 err = chip->info->ops->irl_init_all(chip, port);
1213 if (err)
1214 return err;
1215 }
1216
1217 return 0;
1218}
1219
Vivien Didelot04a69a12017-10-13 14:18:05 -04001220static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1221{
1222 if (chip->info->ops->set_switch_mac) {
1223 u8 addr[ETH_ALEN];
1224
1225 eth_random_addr(addr);
1226
1227 return chip->info->ops->set_switch_mac(chip, addr);
1228 }
1229
1230 return 0;
1231}
1232
Vivien Didelot17a15942017-03-30 17:37:09 -04001233static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1234{
1235 u16 pvlan = 0;
1236
1237 if (!mv88e6xxx_has_pvt(chip))
1238 return -EOPNOTSUPP;
1239
1240 /* Skip the local source device, which uses in-chip port VLAN */
1241 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001242 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001243
1244 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1245}
1246
Vivien Didelot81228992017-03-30 17:37:08 -04001247static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1248{
Vivien Didelot17a15942017-03-30 17:37:09 -04001249 int dev, port;
1250 int err;
1251
Vivien Didelot81228992017-03-30 17:37:08 -04001252 if (!mv88e6xxx_has_pvt(chip))
1253 return 0;
1254
1255 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1256 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1257 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001258 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1259 if (err)
1260 return err;
1261
1262 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1263 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1264 err = mv88e6xxx_pvt_map(chip, dev, port);
1265 if (err)
1266 return err;
1267 }
1268 }
1269
1270 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001271}
1272
Vivien Didelot749efcb2016-09-22 16:49:24 -04001273static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1274{
1275 struct mv88e6xxx_chip *chip = ds->priv;
1276 int err;
1277
1278 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001279 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001280 mutex_unlock(&chip->reg_lock);
1281
1282 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001283 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001284}
1285
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001286static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1287{
1288 if (!chip->info->max_vid)
1289 return 0;
1290
1291 return mv88e6xxx_g1_vtu_flush(chip);
1292}
1293
Vivien Didelotf1394b782017-05-01 14:05:22 -04001294static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1295 struct mv88e6xxx_vtu_entry *entry)
1296{
1297 if (!chip->info->ops->vtu_getnext)
1298 return -EOPNOTSUPP;
1299
1300 return chip->info->ops->vtu_getnext(chip, entry);
1301}
1302
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001303static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1304 struct mv88e6xxx_vtu_entry *entry)
1305{
1306 if (!chip->info->ops->vtu_loadpurge)
1307 return -EOPNOTSUPP;
1308
1309 return chip->info->ops->vtu_loadpurge(chip, entry);
1310}
1311
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001312static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001313{
1314 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001315 struct mv88e6xxx_vtu_entry vlan = {
1316 .vid = chip->info->max_vid,
1317 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001318 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001319
1320 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1321
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001322 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001323 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001324 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001325 if (err)
1326 return err;
1327
1328 set_bit(*fid, fid_bitmap);
1329 }
1330
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001331 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001332 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001333 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001334 if (err)
1335 return err;
1336
1337 if (!vlan.valid)
1338 break;
1339
1340 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001341 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001342
1343 /* The reset value 0x000 is used to indicate that multiple address
1344 * databases are not needed. Return the next positive available.
1345 */
1346 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001347 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001348 return -ENOSPC;
1349
1350 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001351 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001352}
1353
Vivien Didelot567aa592017-05-01 14:05:25 -04001354static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1355 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001356{
1357 int err;
1358
1359 if (!vid)
1360 return -EINVAL;
1361
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001362 entry->vid = vid - 1;
1363 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001364
Vivien Didelotf1394b782017-05-01 14:05:22 -04001365 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001366 if (err)
1367 return err;
1368
Vivien Didelot567aa592017-05-01 14:05:25 -04001369 if (entry->vid == vid && entry->valid)
1370 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001371
Vivien Didelot567aa592017-05-01 14:05:25 -04001372 if (new) {
1373 int i;
1374
1375 /* Initialize a fresh VLAN entry */
1376 memset(entry, 0, sizeof(*entry));
1377 entry->valid = true;
1378 entry->vid = vid;
1379
Vivien Didelot553a7682017-06-07 18:12:16 -04001380 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001381 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001382 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001383 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001384
1385 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001386 }
1387
Vivien Didelot567aa592017-05-01 14:05:25 -04001388 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1389 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001390}
1391
Vivien Didelotda9c3592016-02-12 12:09:40 -05001392static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1393 u16 vid_begin, u16 vid_end)
1394{
Vivien Didelot04bed142016-08-31 18:06:13 -04001395 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001396 struct mv88e6xxx_vtu_entry vlan = {
1397 .vid = vid_begin - 1,
1398 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001399 int i, err;
1400
Andrew Lunndb06ae412017-09-25 23:32:20 +02001401 /* DSA and CPU ports have to be members of multiple vlans */
1402 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1403 return 0;
1404
Vivien Didelotda9c3592016-02-12 12:09:40 -05001405 if (!vid_begin)
1406 return -EOPNOTSUPP;
1407
Vivien Didelotfad09c72016-06-21 12:28:20 -04001408 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001409
Vivien Didelotda9c3592016-02-12 12:09:40 -05001410 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001411 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001412 if (err)
1413 goto unlock;
1414
1415 if (!vlan.valid)
1416 break;
1417
1418 if (vlan.vid > vid_end)
1419 break;
1420
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001421 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001422 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1423 continue;
1424
Andrew Lunncd886462017-11-09 22:29:53 +01001425 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001426 continue;
1427
Vivien Didelotbd00e052017-05-01 14:05:11 -04001428 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001429 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001430 continue;
1431
Vivien Didelotc8652c82017-10-16 11:12:19 -04001432 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001433 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001434 break; /* same bridge, check next VLAN */
1435
Vivien Didelotc8652c82017-10-16 11:12:19 -04001436 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001437 continue;
1438
Andrew Lunn743fcc22017-11-09 22:29:54 +01001439 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1440 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001441 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001442 err = -EOPNOTSUPP;
1443 goto unlock;
1444 }
1445 } while (vlan.vid < vid_end);
1446
1447unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001448 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001449
1450 return err;
1451}
1452
Vivien Didelotf81ec902016-05-09 13:22:58 -04001453static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1454 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001455{
Vivien Didelot04bed142016-08-31 18:06:13 -04001456 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001457 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1458 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001459 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001460
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001461 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001462 return -EOPNOTSUPP;
1463
Vivien Didelotfad09c72016-06-21 12:28:20 -04001464 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001465 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001466 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001467
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001468 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001469}
1470
Vivien Didelot57d32312016-06-20 13:13:58 -04001471static int
1472mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001473 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001474{
Vivien Didelot04bed142016-08-31 18:06:13 -04001475 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001476 int err;
1477
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001478 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001479 return -EOPNOTSUPP;
1480
Vivien Didelotda9c3592016-02-12 12:09:40 -05001481 /* If the requested port doesn't belong to the same bridge as the VLAN
1482 * members, do not support it (yet) and fallback to software VLAN.
1483 */
1484 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1485 vlan->vid_end);
1486 if (err)
1487 return err;
1488
Vivien Didelot76e398a2015-11-01 12:33:55 -05001489 /* We don't need any dynamic resource from the kernel (yet),
1490 * so skip the prepare phase.
1491 */
1492 return 0;
1493}
1494
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001495static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1496 const unsigned char *addr, u16 vid,
1497 u8 state)
1498{
1499 struct mv88e6xxx_vtu_entry vlan;
1500 struct mv88e6xxx_atu_entry entry;
1501 int err;
1502
1503 /* Null VLAN ID corresponds to the port private database */
1504 if (vid == 0)
1505 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1506 else
1507 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1508 if (err)
1509 return err;
1510
1511 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1512 ether_addr_copy(entry.mac, addr);
1513 eth_addr_dec(entry.mac);
1514
1515 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1516 if (err)
1517 return err;
1518
1519 /* Initialize a fresh ATU entry if it isn't found */
1520 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1521 !ether_addr_equal(entry.mac, addr)) {
1522 memset(&entry, 0, sizeof(entry));
1523 ether_addr_copy(entry.mac, addr);
1524 }
1525
1526 /* Purge the ATU entry only if no port is using it anymore */
1527 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1528 entry.portvec &= ~BIT(port);
1529 if (!entry.portvec)
1530 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1531 } else {
1532 entry.portvec |= BIT(port);
1533 entry.state = state;
1534 }
1535
1536 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1537}
1538
Andrew Lunn87fa8862017-11-09 22:29:56 +01001539static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1540 u16 vid)
1541{
1542 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1543 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1544
1545 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1546}
1547
1548static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1549{
1550 int port;
1551 int err;
1552
1553 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1554 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1555 if (err)
1556 return err;
1557 }
1558
1559 return 0;
1560}
1561
Vivien Didelotfad09c72016-06-21 12:28:20 -04001562static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001563 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001564{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001565 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001566 int err;
1567
Vivien Didelot567aa592017-05-01 14:05:25 -04001568 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001569 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001570 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001571
Vivien Didelotc91498e2017-06-07 18:12:13 -04001572 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001573
Andrew Lunn87fa8862017-11-09 22:29:56 +01001574 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1575 if (err)
1576 return err;
1577
1578 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001579}
1580
Vivien Didelotf81ec902016-05-09 13:22:58 -04001581static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001582 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001583{
Vivien Didelot04bed142016-08-31 18:06:13 -04001584 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001585 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1586 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001587 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001588 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001589
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001590 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001591 return;
1592
Vivien Didelotc91498e2017-06-07 18:12:13 -04001593 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001594 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001595 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001596 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001597 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001598 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001599
Vivien Didelotfad09c72016-06-21 12:28:20 -04001600 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001601
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001602 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001603 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001604 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1605 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001606
Vivien Didelot77064f32016-11-04 03:23:30 +01001607 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001608 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1609 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001610
Vivien Didelotfad09c72016-06-21 12:28:20 -04001611 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001612}
1613
Vivien Didelotfad09c72016-06-21 12:28:20 -04001614static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001615 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001616{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001617 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001618 int i, err;
1619
Vivien Didelot567aa592017-05-01 14:05:25 -04001620 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001621 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001622 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001623
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001624 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001625 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001626 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001627
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001628 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001629
1630 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001631 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001632 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001633 if (vlan.member[i] !=
1634 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001635 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001636 break;
1637 }
1638 }
1639
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001640 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001641 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001642 return err;
1643
Vivien Didelote606ca32017-03-11 16:12:55 -05001644 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001645}
1646
Vivien Didelotf81ec902016-05-09 13:22:58 -04001647static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1648 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001649{
Vivien Didelot04bed142016-08-31 18:06:13 -04001650 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001651 u16 pvid, vid;
1652 int err = 0;
1653
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001654 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001655 return -EOPNOTSUPP;
1656
Vivien Didelotfad09c72016-06-21 12:28:20 -04001657 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001658
Vivien Didelot77064f32016-11-04 03:23:30 +01001659 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001660 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001661 goto unlock;
1662
Vivien Didelot76e398a2015-11-01 12:33:55 -05001663 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001664 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001665 if (err)
1666 goto unlock;
1667
1668 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001669 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001670 if (err)
1671 goto unlock;
1672 }
1673 }
1674
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001675unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001676 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001677
1678 return err;
1679}
1680
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001681static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1682 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001683{
Vivien Didelot04bed142016-08-31 18:06:13 -04001684 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001685 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001686
Vivien Didelotfad09c72016-06-21 12:28:20 -04001687 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001688 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1689 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001690 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001691
1692 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001693}
1694
Vivien Didelotf81ec902016-05-09 13:22:58 -04001695static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001696 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001697{
Vivien Didelot04bed142016-08-31 18:06:13 -04001698 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001699 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001700
Vivien Didelotfad09c72016-06-21 12:28:20 -04001701 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001702 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001703 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001704 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001705
Vivien Didelot83dabd12016-08-31 11:50:04 -04001706 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001707}
1708
Vivien Didelot83dabd12016-08-31 11:50:04 -04001709static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1710 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001711 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001712{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001713 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001714 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001715 int err;
1716
Vivien Didelot27c0e602017-06-15 12:14:01 -04001717 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001718 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001719
1720 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001721 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001722 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001723 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001724 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001725 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001726
Vivien Didelot27c0e602017-06-15 12:14:01 -04001727 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001728 break;
1729
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001730 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001731 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001732
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001733 if (!is_unicast_ether_addr(addr.mac))
1734 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001735
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001736 is_static = (addr.state ==
1737 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1738 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001739 if (err)
1740 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001741 } while (!is_broadcast_ether_addr(addr.mac));
1742
1743 return err;
1744}
1745
Vivien Didelot83dabd12016-08-31 11:50:04 -04001746static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001747 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001748{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001749 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001750 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001751 };
1752 u16 fid;
1753 int err;
1754
1755 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001756 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001757 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001758 mutex_unlock(&chip->reg_lock);
1759
Vivien Didelot83dabd12016-08-31 11:50:04 -04001760 if (err)
1761 return err;
1762
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001763 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001764 if (err)
1765 return err;
1766
1767 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001768 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001769 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001770 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001771 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001772 if (err)
1773 return err;
1774
1775 if (!vlan.valid)
1776 break;
1777
1778 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001779 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001780 if (err)
1781 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001782 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001783
1784 return err;
1785}
1786
Vivien Didelotf81ec902016-05-09 13:22:58 -04001787static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001788 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001789{
Vivien Didelot04bed142016-08-31 18:06:13 -04001790 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001791
Andrew Lunna61e5402018-02-15 14:38:35 +01001792 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001793}
1794
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001795static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1796 struct net_device *br)
1797{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001798 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001799 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001800 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001801 int err;
1802
1803 /* Remap the Port VLAN of each local bridge group member */
1804 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1805 if (chip->ds->ports[port].bridge_dev == br) {
1806 err = mv88e6xxx_port_vlan_map(chip, port);
1807 if (err)
1808 return err;
1809 }
1810 }
1811
Vivien Didelote96a6e02017-03-30 17:37:13 -04001812 if (!mv88e6xxx_has_pvt(chip))
1813 return 0;
1814
1815 /* Remap the Port VLAN of each cross-chip bridge group member */
1816 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1817 ds = chip->ds->dst->ds[dev];
1818 if (!ds)
1819 break;
1820
1821 for (port = 0; port < ds->num_ports; ++port) {
1822 if (ds->ports[port].bridge_dev == br) {
1823 err = mv88e6xxx_pvt_map(chip, dev, port);
1824 if (err)
1825 return err;
1826 }
1827 }
1828 }
1829
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001830 return 0;
1831}
1832
Vivien Didelotf81ec902016-05-09 13:22:58 -04001833static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001834 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001835{
Vivien Didelot04bed142016-08-31 18:06:13 -04001836 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001837 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001838
Vivien Didelotfad09c72016-06-21 12:28:20 -04001839 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001840 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001841 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001842
Vivien Didelot466dfa02016-02-26 13:16:05 -05001843 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001844}
1845
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001846static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1847 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001848{
Vivien Didelot04bed142016-08-31 18:06:13 -04001849 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001850
Vivien Didelotfad09c72016-06-21 12:28:20 -04001851 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001852 if (mv88e6xxx_bridge_map(chip, br) ||
1853 mv88e6xxx_port_vlan_map(chip, port))
1854 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001855 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001856}
1857
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001858static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1859 int port, struct net_device *br)
1860{
1861 struct mv88e6xxx_chip *chip = ds->priv;
1862 int err;
1863
1864 if (!mv88e6xxx_has_pvt(chip))
1865 return 0;
1866
1867 mutex_lock(&chip->reg_lock);
1868 err = mv88e6xxx_pvt_map(chip, dev, port);
1869 mutex_unlock(&chip->reg_lock);
1870
1871 return err;
1872}
1873
1874static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1875 int port, struct net_device *br)
1876{
1877 struct mv88e6xxx_chip *chip = ds->priv;
1878
1879 if (!mv88e6xxx_has_pvt(chip))
1880 return;
1881
1882 mutex_lock(&chip->reg_lock);
1883 if (mv88e6xxx_pvt_map(chip, dev, port))
1884 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1885 mutex_unlock(&chip->reg_lock);
1886}
1887
Vivien Didelot17e708b2016-12-05 17:30:27 -05001888static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1889{
1890 if (chip->info->ops->reset)
1891 return chip->info->ops->reset(chip);
1892
1893 return 0;
1894}
1895
Vivien Didelot309eca62016-12-05 17:30:26 -05001896static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1897{
1898 struct gpio_desc *gpiod = chip->reset;
1899
1900 /* If there is a GPIO connected to the reset pin, toggle it */
1901 if (gpiod) {
1902 gpiod_set_value_cansleep(gpiod, 1);
1903 usleep_range(10000, 20000);
1904 gpiod_set_value_cansleep(gpiod, 0);
1905 usleep_range(10000, 20000);
1906 }
1907}
1908
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001909static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1910{
1911 int i, err;
1912
1913 /* Set all ports to the Disabled state */
1914 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001915 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001916 if (err)
1917 return err;
1918 }
1919
1920 /* Wait for transmit queues to drain,
1921 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1922 */
1923 usleep_range(2000, 4000);
1924
1925 return 0;
1926}
1927
Vivien Didelotfad09c72016-06-21 12:28:20 -04001928static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001929{
Vivien Didelota935c052016-09-29 12:21:53 -04001930 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001931
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001932 err = mv88e6xxx_disable_ports(chip);
1933 if (err)
1934 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001935
Vivien Didelot309eca62016-12-05 17:30:26 -05001936 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001937
Vivien Didelot17e708b2016-12-05 17:30:27 -05001938 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001939}
1940
Vivien Didelot43145572017-03-11 16:12:59 -05001941static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001942 enum mv88e6xxx_frame_mode frame,
1943 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001944{
1945 int err;
1946
Vivien Didelot43145572017-03-11 16:12:59 -05001947 if (!chip->info->ops->port_set_frame_mode)
1948 return -EOPNOTSUPP;
1949
1950 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001951 if (err)
1952 return err;
1953
Vivien Didelot43145572017-03-11 16:12:59 -05001954 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1955 if (err)
1956 return err;
1957
1958 if (chip->info->ops->port_set_ether_type)
1959 return chip->info->ops->port_set_ether_type(chip, port, etype);
1960
1961 return 0;
1962}
1963
1964static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1965{
1966 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001967 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001968 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001969}
1970
1971static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1972{
1973 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001974 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001975 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001976}
1977
1978static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1979{
1980 return mv88e6xxx_set_port_mode(chip, port,
1981 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001982 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1983 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001984}
1985
1986static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1987{
1988 if (dsa_is_dsa_port(chip->ds, port))
1989 return mv88e6xxx_set_port_mode_dsa(chip, port);
1990
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001991 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001992 return mv88e6xxx_set_port_mode_normal(chip, port);
1993
1994 /* Setup CPU port mode depending on its supported tag format */
1995 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1996 return mv88e6xxx_set_port_mode_dsa(chip, port);
1997
1998 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1999 return mv88e6xxx_set_port_mode_edsa(chip, port);
2000
2001 return -EINVAL;
2002}
2003
Vivien Didelotea698f42017-03-11 16:12:50 -05002004static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2005{
2006 bool message = dsa_is_dsa_port(chip->ds, port);
2007
2008 return mv88e6xxx_port_set_message_port(chip, port, message);
2009}
2010
Vivien Didelot601aeed2017-03-11 16:13:00 -05002011static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2012{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002013 struct dsa_switch *ds = chip->ds;
2014 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002015
2016 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002017 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002018 if (chip->info->ops->port_set_egress_floods)
2019 return chip->info->ops->port_set_egress_floods(chip, port,
2020 flood, flood);
2021
2022 return 0;
2023}
2024
Andrew Lunn6d917822017-05-26 01:03:21 +02002025static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2026 bool on)
2027{
Vivien Didelot523a8902017-05-26 18:02:42 -04002028 if (chip->info->ops->serdes_power)
2029 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002030
Vivien Didelot523a8902017-05-26 18:02:42 -04002031 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002032}
2033
Vivien Didelotfa371c82017-12-05 15:34:10 -05002034static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2035{
2036 struct dsa_switch *ds = chip->ds;
2037 int upstream_port;
2038 int err;
2039
Vivien Didelot07073c72017-12-05 15:34:13 -05002040 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002041 if (chip->info->ops->port_set_upstream_port) {
2042 err = chip->info->ops->port_set_upstream_port(chip, port,
2043 upstream_port);
2044 if (err)
2045 return err;
2046 }
2047
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002048 if (port == upstream_port) {
2049 if (chip->info->ops->set_cpu_port) {
2050 err = chip->info->ops->set_cpu_port(chip,
2051 upstream_port);
2052 if (err)
2053 return err;
2054 }
2055
2056 if (chip->info->ops->set_egress_port) {
2057 err = chip->info->ops->set_egress_port(chip,
2058 upstream_port);
2059 if (err)
2060 return err;
2061 }
2062 }
2063
Vivien Didelotfa371c82017-12-05 15:34:10 -05002064 return 0;
2065}
2066
Vivien Didelotfad09c72016-06-21 12:28:20 -04002067static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002068{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002069 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002070 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002071 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002072
Vivien Didelotd78343d2016-11-04 03:23:36 +01002073 /* MAC Forcing register: don't force link, speed, duplex or flow control
2074 * state to any particular values on physical ports, but force the CPU
2075 * port and all DSA ports to their maximum bandwidth and full duplex.
2076 */
2077 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2078 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2079 SPEED_MAX, DUPLEX_FULL,
2080 PHY_INTERFACE_MODE_NA);
2081 else
2082 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2083 SPEED_UNFORCED, DUPLEX_UNFORCED,
2084 PHY_INTERFACE_MODE_NA);
2085 if (err)
2086 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002087
2088 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2089 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2090 * tunneling, determine priority by looking at 802.1p and IP
2091 * priority fields (IP prio has precedence), and set STP state
2092 * to Forwarding.
2093 *
2094 * If this is the CPU link, use DSA or EDSA tagging depending
2095 * on which tagging mode was configured.
2096 *
2097 * If this is a link to another switch, use DSA tagging mode.
2098 *
2099 * If this is the upstream port for this switch, enable
2100 * forwarding of unknown unicasts and multicasts.
2101 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002102 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2103 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2104 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2105 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002106 if (err)
2107 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002108
Vivien Didelot601aeed2017-03-11 16:13:00 -05002109 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002110 if (err)
2111 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002112
Vivien Didelot601aeed2017-03-11 16:13:00 -05002113 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002114 if (err)
2115 return err;
2116
Andrew Lunn04aca992017-05-26 01:03:24 +02002117 /* Enable the SERDES interface for DSA and CPU ports. Normal
2118 * ports SERDES are enabled when the port is enabled, thus
2119 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002120 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002121 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2122 err = mv88e6xxx_serdes_power(chip, port, true);
2123 if (err)
2124 return err;
2125 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002126
Vivien Didelot8efdda42015-08-13 12:52:23 -04002127 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002128 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002129 * untagged frames on this port, do a destination address lookup on all
2130 * received packets as usual, disable ARP mirroring and don't send a
2131 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002132 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002133 err = mv88e6xxx_port_set_map_da(chip, port);
2134 if (err)
2135 return err;
2136
Vivien Didelotfa371c82017-12-05 15:34:10 -05002137 err = mv88e6xxx_setup_upstream_port(chip, port);
2138 if (err)
2139 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002140
Andrew Lunna23b2962017-02-04 20:15:28 +01002141 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002142 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002143 if (err)
2144 return err;
2145
Vivien Didelotcd782652017-06-08 18:34:13 -04002146 if (chip->info->ops->port_set_jumbo_size) {
2147 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002148 if (err)
2149 return err;
2150 }
2151
Andrew Lunn54d792f2015-05-06 01:09:47 +02002152 /* Port Association Vector: when learning source addresses
2153 * of packets, add the address to the address database using
2154 * a port bitmap that has only the bit for this port set and
2155 * the other bits clear.
2156 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002157 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002158 /* Disable learning for CPU port */
2159 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002160 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002161
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002162 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2163 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002164 if (err)
2165 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002166
2167 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002168 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2169 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002170 if (err)
2171 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002172
Vivien Didelot08984322017-06-08 18:34:12 -04002173 if (chip->info->ops->port_pause_limit) {
2174 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002175 if (err)
2176 return err;
2177 }
2178
Vivien Didelotc8c94892017-03-11 16:13:01 -05002179 if (chip->info->ops->port_disable_learn_limit) {
2180 err = chip->info->ops->port_disable_learn_limit(chip, port);
2181 if (err)
2182 return err;
2183 }
2184
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002185 if (chip->info->ops->port_disable_pri_override) {
2186 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002187 if (err)
2188 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002189 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002190
Andrew Lunnef0a7312016-12-03 04:35:16 +01002191 if (chip->info->ops->port_tag_remap) {
2192 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002193 if (err)
2194 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002195 }
2196
Andrew Lunnef70b112016-12-03 04:45:18 +01002197 if (chip->info->ops->port_egress_rate_limiting) {
2198 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002199 if (err)
2200 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002201 }
2202
Vivien Didelotea698f42017-03-11 16:12:50 -05002203 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002204 if (err)
2205 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002206
Vivien Didelot207afda2016-04-14 14:42:09 -04002207 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002208 * database, and allow bidirectional communication between the
2209 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002210 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002211 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002212 if (err)
2213 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002214
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002215 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002216 if (err)
2217 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002218
2219 /* Default VLAN ID and priority: don't set a default VLAN
2220 * ID, and set the default packet priority to zero.
2221 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002222 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002223}
2224
Andrew Lunn04aca992017-05-26 01:03:24 +02002225static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2226 struct phy_device *phydev)
2227{
2228 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002229 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002230
2231 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002232 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02002233 mutex_unlock(&chip->reg_lock);
2234
2235 return err;
2236}
2237
2238static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2239 struct phy_device *phydev)
2240{
2241 struct mv88e6xxx_chip *chip = ds->priv;
2242
2243 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002244 if (mv88e6xxx_serdes_power(chip, port, false))
2245 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02002246 mutex_unlock(&chip->reg_lock);
2247}
2248
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002249static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2250 unsigned int ageing_time)
2251{
Vivien Didelot04bed142016-08-31 18:06:13 -04002252 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002253 int err;
2254
2255 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002256 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002257 mutex_unlock(&chip->reg_lock);
2258
2259 return err;
2260}
2261
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002262static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002263{
2264 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002265
Andrew Lunnde2273872016-11-21 23:27:01 +01002266 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002267 if (chip->info->ops->stats_set_histogram) {
2268 err = chip->info->ops->stats_set_histogram(chip);
2269 if (err)
2270 return err;
2271 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002272
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002273 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002274}
2275
Vivien Didelotf81ec902016-05-09 13:22:58 -04002276static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002277{
Vivien Didelot04bed142016-08-31 18:06:13 -04002278 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002279 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002280 int i;
2281
Vivien Didelotfad09c72016-06-21 12:28:20 -04002282 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002283 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002284
Vivien Didelotfad09c72016-06-21 12:28:20 -04002285 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002286
Vivien Didelot97299342016-07-18 20:45:30 -04002287 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002288 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002289 if (dsa_is_unused_port(ds, i))
2290 continue;
2291
Vivien Didelot97299342016-07-18 20:45:30 -04002292 err = mv88e6xxx_setup_port(chip, i);
2293 if (err)
2294 goto unlock;
2295 }
2296
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002297 err = mv88e6xxx_irl_setup(chip);
2298 if (err)
2299 goto unlock;
2300
Vivien Didelot04a69a12017-10-13 14:18:05 -04002301 err = mv88e6xxx_mac_setup(chip);
2302 if (err)
2303 goto unlock;
2304
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002305 err = mv88e6xxx_phy_setup(chip);
2306 if (err)
2307 goto unlock;
2308
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002309 err = mv88e6xxx_vtu_setup(chip);
2310 if (err)
2311 goto unlock;
2312
Vivien Didelot81228992017-03-30 17:37:08 -04002313 err = mv88e6xxx_pvt_setup(chip);
2314 if (err)
2315 goto unlock;
2316
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002317 err = mv88e6xxx_atu_setup(chip);
2318 if (err)
2319 goto unlock;
2320
Andrew Lunn87fa8862017-11-09 22:29:56 +01002321 err = mv88e6xxx_broadcast_setup(chip, 0);
2322 if (err)
2323 goto unlock;
2324
Vivien Didelot9e907d72017-07-17 13:03:43 -04002325 err = mv88e6xxx_pot_setup(chip);
2326 if (err)
2327 goto unlock;
2328
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002329 err = mv88e6xxx_rmu_setup(chip);
2330 if (err)
2331 goto unlock;
2332
Vivien Didelot51c901a2017-07-17 13:03:41 -04002333 err = mv88e6xxx_rsvd2cpu_setup(chip);
2334 if (err)
2335 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002336
Vivien Didelotb28f8722018-04-26 21:56:44 -04002337 err = mv88e6xxx_trunk_setup(chip);
2338 if (err)
2339 goto unlock;
2340
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002341 err = mv88e6xxx_devmap_setup(chip);
2342 if (err)
2343 goto unlock;
2344
Vivien Didelot93e18d62018-05-11 17:16:35 -04002345 err = mv88e6xxx_pri_setup(chip);
2346 if (err)
2347 goto unlock;
2348
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002349 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002350 if (chip->info->ptp_support) {
2351 err = mv88e6xxx_ptp_setup(chip);
2352 if (err)
2353 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002354
2355 err = mv88e6xxx_hwtstamp_setup(chip);
2356 if (err)
2357 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002358 }
2359
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002360 err = mv88e6xxx_stats_setup(chip);
2361 if (err)
2362 goto unlock;
2363
Vivien Didelot6b17e862015-08-13 12:52:18 -04002364unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002365 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002366
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002367 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002368}
2369
Vivien Didelote57e5e72016-08-15 17:19:00 -04002370static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002371{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002372 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2373 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002374 u16 val;
2375 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002376
Andrew Lunnee26a222017-01-24 14:53:48 +01002377 if (!chip->info->ops->phy_read)
2378 return -EOPNOTSUPP;
2379
Vivien Didelotfad09c72016-06-21 12:28:20 -04002380 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002381 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002382 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002383
Andrew Lunnda9f3302017-02-01 03:40:05 +01002384 if (reg == MII_PHYSID2) {
2385 /* Some internal PHYS don't have a model number. Use
2386 * the mv88e6390 family model number instead.
2387 */
2388 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002389 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002390 }
2391
Vivien Didelote57e5e72016-08-15 17:19:00 -04002392 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002393}
2394
Vivien Didelote57e5e72016-08-15 17:19:00 -04002395static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002396{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002397 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2398 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002399 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002400
Andrew Lunnee26a222017-01-24 14:53:48 +01002401 if (!chip->info->ops->phy_write)
2402 return -EOPNOTSUPP;
2403
Vivien Didelotfad09c72016-06-21 12:28:20 -04002404 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002405 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002406 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002407
2408 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002409}
2410
Vivien Didelotfad09c72016-06-21 12:28:20 -04002411static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002412 struct device_node *np,
2413 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002414{
2415 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002416 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002417 struct mii_bus *bus;
2418 int err;
2419
Andrew Lunn2510bab2018-02-22 01:51:49 +01002420 if (external) {
2421 mutex_lock(&chip->reg_lock);
2422 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2423 mutex_unlock(&chip->reg_lock);
2424
2425 if (err)
2426 return err;
2427 }
2428
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002429 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002430 if (!bus)
2431 return -ENOMEM;
2432
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002433 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002434 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002435 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002436 INIT_LIST_HEAD(&mdio_bus->list);
2437 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002438
Andrew Lunnb516d452016-06-04 21:17:06 +02002439 if (np) {
2440 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002441 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002442 } else {
2443 bus->name = "mv88e6xxx SMI";
2444 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2445 }
2446
2447 bus->read = mv88e6xxx_mdio_read;
2448 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002449 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002450
Andrew Lunn6f882842018-03-17 20:32:05 +01002451 if (!external) {
2452 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2453 if (err)
2454 return err;
2455 }
2456
Andrew Lunna3c53be52017-01-24 14:53:50 +01002457 if (np)
2458 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002459 else
2460 err = mdiobus_register(bus);
2461 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002462 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002463 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002464 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002465 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002466
2467 if (external)
2468 list_add_tail(&mdio_bus->list, &chip->mdios);
2469 else
2470 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002471
2472 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002473}
2474
Andrew Lunna3c53be52017-01-24 14:53:50 +01002475static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2476 { .compatible = "marvell,mv88e6xxx-mdio-external",
2477 .data = (void *)true },
2478 { },
2479};
2480
Andrew Lunn3126aee2017-12-07 01:05:57 +01002481static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2482
2483{
2484 struct mv88e6xxx_mdio_bus *mdio_bus;
2485 struct mii_bus *bus;
2486
2487 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2488 bus = mdio_bus->bus;
2489
Andrew Lunn6f882842018-03-17 20:32:05 +01002490 if (!mdio_bus->external)
2491 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2492
Andrew Lunn3126aee2017-12-07 01:05:57 +01002493 mdiobus_unregister(bus);
2494 }
2495}
2496
Andrew Lunna3c53be52017-01-24 14:53:50 +01002497static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2498 struct device_node *np)
2499{
2500 const struct of_device_id *match;
2501 struct device_node *child;
2502 int err;
2503
2504 /* Always register one mdio bus for the internal/default mdio
2505 * bus. This maybe represented in the device tree, but is
2506 * optional.
2507 */
2508 child = of_get_child_by_name(np, "mdio");
2509 err = mv88e6xxx_mdio_register(chip, child, false);
2510 if (err)
2511 return err;
2512
2513 /* Walk the device tree, and see if there are any other nodes
2514 * which say they are compatible with the external mdio
2515 * bus.
2516 */
2517 for_each_available_child_of_node(np, child) {
2518 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2519 if (match) {
2520 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002521 if (err) {
2522 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002523 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002524 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002525 }
2526 }
2527
2528 return 0;
2529}
2530
Vivien Didelot855b1932016-07-20 18:18:35 -04002531static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2532{
Vivien Didelot04bed142016-08-31 18:06:13 -04002533 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002534
2535 return chip->eeprom_len;
2536}
2537
Vivien Didelot855b1932016-07-20 18:18:35 -04002538static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2539 struct ethtool_eeprom *eeprom, u8 *data)
2540{
Vivien Didelot04bed142016-08-31 18:06:13 -04002541 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002542 int err;
2543
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002544 if (!chip->info->ops->get_eeprom)
2545 return -EOPNOTSUPP;
2546
Vivien Didelot855b1932016-07-20 18:18:35 -04002547 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002548 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002549 mutex_unlock(&chip->reg_lock);
2550
2551 if (err)
2552 return err;
2553
2554 eeprom->magic = 0xc3ec4951;
2555
2556 return 0;
2557}
2558
Vivien Didelot855b1932016-07-20 18:18:35 -04002559static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2560 struct ethtool_eeprom *eeprom, u8 *data)
2561{
Vivien Didelot04bed142016-08-31 18:06:13 -04002562 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002563 int err;
2564
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002565 if (!chip->info->ops->set_eeprom)
2566 return -EOPNOTSUPP;
2567
Vivien Didelot855b1932016-07-20 18:18:35 -04002568 if (eeprom->magic != 0xc3ec4951)
2569 return -EINVAL;
2570
2571 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002572 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002573 mutex_unlock(&chip->reg_lock);
2574
2575 return err;
2576}
2577
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002578static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002579 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002580 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2581 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002582 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002583 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002584 .phy_read = mv88e6185_phy_ppu_read,
2585 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002586 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002587 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002588 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002589 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002590 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002591 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002592 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002593 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002594 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002595 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002596 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002597 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002598 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002599 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2600 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002601 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002602 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2603 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002604 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002605 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002606 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002607 .ppu_enable = mv88e6185_g1_ppu_enable,
2608 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002609 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002610 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002611 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002612 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behún5bafeb6e2018-05-04 19:26:10 +02002613 .serdes_power = mv88e6341_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002614};
2615
2616static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002617 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002618 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2619 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002620 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002621 .phy_read = mv88e6185_phy_ppu_read,
2622 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002623 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002624 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002625 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002626 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002627 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002628 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002629 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002630 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002631 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2632 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002633 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002634 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002635 .ppu_enable = mv88e6185_g1_ppu_enable,
2636 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002637 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002638 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002639 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002640};
2641
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002642static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002643 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002644 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2645 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002646 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002647 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2648 .phy_read = mv88e6xxx_g2_smi_phy_read,
2649 .phy_write = mv88e6xxx_g2_smi_phy_write,
2650 .port_set_link = mv88e6xxx_port_set_link,
2651 .port_set_duplex = mv88e6xxx_port_set_duplex,
2652 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002653 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002654 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002655 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002656 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002657 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002658 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002659 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002660 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002661 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002662 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002663 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002664 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2665 .stats_get_strings = mv88e6095_stats_get_strings,
2666 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002667 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2668 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002669 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002670 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002671 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002672 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002673 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002674 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002675 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002676};
2677
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002678static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002679 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002680 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2681 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002682 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002683 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002684 .phy_read = mv88e6xxx_g2_smi_phy_read,
2685 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002686 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002687 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002688 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002689 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002690 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002691 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002692 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002693 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002694 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002695 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2696 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002697 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002698 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2699 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002700 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002701 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002702 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002703 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002704 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002705 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002706};
2707
2708static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002709 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002710 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2711 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002712 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002713 .phy_read = mv88e6185_phy_ppu_read,
2714 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002715 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002716 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002717 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002718 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002719 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002720 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002721 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002722 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002723 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002724 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002725 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002726 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002727 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002728 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2729 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002730 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002731 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2732 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002733 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002734 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002735 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002736 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002737 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002738 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002739 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002740 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002741};
2742
Vivien Didelot990e27b2017-03-28 13:50:32 -04002743static const struct mv88e6xxx_ops mv88e6141_ops = {
2744 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002745 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2746 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002747 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002748 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2749 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2750 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2751 .phy_read = mv88e6xxx_g2_smi_phy_read,
2752 .phy_write = mv88e6xxx_g2_smi_phy_write,
2753 .port_set_link = mv88e6xxx_port_set_link,
2754 .port_set_duplex = mv88e6xxx_port_set_duplex,
2755 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2756 .port_set_speed = mv88e6390_port_set_speed,
2757 .port_tag_remap = mv88e6095_port_tag_remap,
2758 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2759 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2760 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002761 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002762 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002763 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002764 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2765 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2766 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002767 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002768 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2769 .stats_get_strings = mv88e6320_stats_get_strings,
2770 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002771 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2772 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002773 .watchdog_ops = &mv88e6390_watchdog_ops,
2774 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002775 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002776 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002777 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002778 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002779 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002780};
2781
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002782static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002783 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002784 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2785 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002786 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002787 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002788 .phy_read = mv88e6xxx_g2_smi_phy_read,
2789 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002790 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002791 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002792 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002793 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002794 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002795 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002796 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002797 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002798 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002799 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002800 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002801 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002802 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002803 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002804 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2805 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002806 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002807 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2808 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002809 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002810 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002811 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002812 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002813 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002814 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002815};
2816
2817static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002818 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002819 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2820 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002821 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002822 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002823 .phy_read = mv88e6165_phy_read,
2824 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002825 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002826 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002827 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002828 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002829 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002830 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002831 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002832 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2833 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002834 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002835 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2836 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002837 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002838 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002839 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002840 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002841 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002842 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002843};
2844
2845static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002846 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002847 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2848 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002849 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002850 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002851 .phy_read = mv88e6xxx_g2_smi_phy_read,
2852 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002853 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002854 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002855 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002856 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002857 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002858 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002859 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002860 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002861 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002862 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002863 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002864 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002865 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002866 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002867 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002868 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2869 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002870 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002871 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2872 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002873 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002874 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002875 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002876 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002877 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002878 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002879};
2880
2881static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002882 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002883 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2884 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002885 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002886 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2887 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002888 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002889 .phy_read = mv88e6xxx_g2_smi_phy_read,
2890 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002891 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002892 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002893 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002894 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002895 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002896 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002897 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002898 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002899 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002900 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002901 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002902 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002903 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002904 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002905 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002906 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2907 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002908 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002909 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2910 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002911 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002912 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002913 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002914 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002915 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002916 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002917 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002918 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002919 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002920};
2921
2922static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002923 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002924 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2925 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002926 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002927 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002928 .phy_read = mv88e6xxx_g2_smi_phy_read,
2929 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002930 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002931 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002932 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002933 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002934 .port_tag_remap = mv88e6095_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 Didelotcd782652017-06-08 18:34:13 -04002938 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002939 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002940 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002941 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002942 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002943 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002944 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002945 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2946 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002947 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002948 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2949 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002950 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002951 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002952 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002953 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002954 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002955 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behún5bafeb6e2018-05-04 19:26:10 +02002956 .serdes_power = mv88e6341_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002957};
2958
2959static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002960 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002961 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2962 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002963 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002964 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2965 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002966 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002967 .phy_read = mv88e6xxx_g2_smi_phy_read,
2968 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002969 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002970 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002971 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002972 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002973 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002974 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002975 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002976 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002977 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002978 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002979 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002980 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002981 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002982 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002983 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002984 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2985 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002986 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002987 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2988 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002989 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002990 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002991 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002992 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002993 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002994 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002995 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002996 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002997 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002998};
2999
3000static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003001 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003002 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3003 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003004 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003005 .phy_read = mv88e6185_phy_ppu_read,
3006 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003007 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003008 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003009 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003010 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003011 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003012 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003013 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003014 .stats_snapshot = mv88e6xxx_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 = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003023 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003024 .ppu_enable = mv88e6185_g1_ppu_enable,
3025 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003026 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003027 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003028 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003029};
3030
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003031static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003032 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003033 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003034 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3035 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003036 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3037 .phy_read = mv88e6xxx_g2_smi_phy_read,
3038 .phy_write = mv88e6xxx_g2_smi_phy_write,
3039 .port_set_link = mv88e6xxx_port_set_link,
3040 .port_set_duplex = mv88e6xxx_port_set_duplex,
3041 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3042 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003043 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003044 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003045 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003046 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003047 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003048 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003049 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003050 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003051 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003052 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3053 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003054 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003055 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3056 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003057 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003058 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003059 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003060 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003061 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003062 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3063 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003064 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003065 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003066};
3067
3068static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003069 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003070 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003071 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3072 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003073 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3074 .phy_read = mv88e6xxx_g2_smi_phy_read,
3075 .phy_write = mv88e6xxx_g2_smi_phy_write,
3076 .port_set_link = mv88e6xxx_port_set_link,
3077 .port_set_duplex = mv88e6xxx_port_set_duplex,
3078 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3079 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003080 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003081 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003082 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003083 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003084 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003085 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003086 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003087 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003088 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003089 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3090 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003091 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003092 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3093 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003094 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003095 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003096 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003097 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003098 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003099 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3100 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003101 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003102 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003103};
3104
3105static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003106 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003107 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003108 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3109 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003110 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3111 .phy_read = mv88e6xxx_g2_smi_phy_read,
3112 .phy_write = mv88e6xxx_g2_smi_phy_write,
3113 .port_set_link = mv88e6xxx_port_set_link,
3114 .port_set_duplex = mv88e6xxx_port_set_duplex,
3115 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3116 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003117 .port_tag_remap = mv88e6390_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 Didelot08984322017-06-08 18:34:12 -04003121 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003122 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003123 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003124 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003125 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003126 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3127 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003128 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003129 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3130 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003131 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003132 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003133 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003134 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003135 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003136 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3137 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003138 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003139};
3140
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003141static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003142 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003143 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3144 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003145 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003146 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3147 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003148 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003149 .phy_read = mv88e6xxx_g2_smi_phy_read,
3150 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003151 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003152 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003153 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003154 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003155 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003156 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003157 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003158 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003159 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003160 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003161 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003162 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003163 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003164 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003165 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003166 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3167 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003168 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003169 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3170 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003171 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003172 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003173 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003174 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003175 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003176 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003177 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003178 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003179 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003180 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003181};
3182
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003183static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003184 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003185 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003186 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3187 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003188 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3189 .phy_read = mv88e6xxx_g2_smi_phy_read,
3190 .phy_write = mv88e6xxx_g2_smi_phy_write,
3191 .port_set_link = mv88e6xxx_port_set_link,
3192 .port_set_duplex = mv88e6xxx_port_set_duplex,
3193 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3194 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003195 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003196 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003197 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003198 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003199 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003200 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003201 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003202 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003203 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003204 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003205 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3206 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003207 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003208 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3209 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003210 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003211 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003212 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003213 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003214 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003215 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3216 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003217 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003218 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003219 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003220};
3221
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003222static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003223 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003224 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3225 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003226 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003227 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3228 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003229 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003230 .phy_read = mv88e6xxx_g2_smi_phy_read,
3231 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003232 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003233 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003234 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003235 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003236 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003237 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003238 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003239 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003240 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003241 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003242 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003243 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003244 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003245 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003246 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3247 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003248 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003249 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3250 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003251 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003252 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003253 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003254 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003255 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003256 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003257 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003258};
3259
3260static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003261 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003262 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3263 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003264 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003265 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3266 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003267 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003268 .phy_read = mv88e6xxx_g2_smi_phy_read,
3269 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003270 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003271 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003272 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003273 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003274 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003275 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003276 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003277 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003278 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003279 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003280 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003281 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003282 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003283 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003284 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3285 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003286 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003287 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3288 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003289 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003290 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003291 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003292 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003293 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003294};
3295
Vivien Didelot16e329a2017-03-28 13:50:33 -04003296static const struct mv88e6xxx_ops mv88e6341_ops = {
3297 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003298 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3299 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003300 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003301 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3302 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3303 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3304 .phy_read = mv88e6xxx_g2_smi_phy_read,
3305 .phy_write = mv88e6xxx_g2_smi_phy_write,
3306 .port_set_link = mv88e6xxx_port_set_link,
3307 .port_set_duplex = mv88e6xxx_port_set_duplex,
3308 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3309 .port_set_speed = mv88e6390_port_set_speed,
3310 .port_tag_remap = mv88e6095_port_tag_remap,
3311 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3312 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3313 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003314 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003315 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003316 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003317 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3318 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3319 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003320 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003321 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3322 .stats_get_strings = mv88e6320_stats_get_strings,
3323 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003324 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3325 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003326 .watchdog_ops = &mv88e6390_watchdog_ops,
3327 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003328 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003329 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003330 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003331 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003332 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003333 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003334};
3335
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003336static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003337 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003338 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3339 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003340 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003341 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003342 .phy_read = mv88e6xxx_g2_smi_phy_read,
3343 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003344 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003345 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003346 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003347 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003348 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003349 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003350 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003351 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003352 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003353 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003354 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003355 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003356 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003357 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003358 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003359 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3360 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003361 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003362 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3363 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003364 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003365 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003366 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003367 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003368 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003369 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003370};
3371
3372static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003373 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003374 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3375 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003376 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003377 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003378 .phy_read = mv88e6xxx_g2_smi_phy_read,
3379 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003380 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003381 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003382 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003383 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003384 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003385 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003386 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003387 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003388 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003389 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003390 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003391 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003392 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003393 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003394 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003395 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3396 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003397 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003398 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3399 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003400 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003401 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003402 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003403 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003404 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003405 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003406 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003407};
3408
3409static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003410 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003411 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3412 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003413 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003414 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3415 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003416 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003417 .phy_read = mv88e6xxx_g2_smi_phy_read,
3418 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003419 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003420 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003421 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003422 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003423 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003424 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003425 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003426 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003427 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003428 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003429 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003430 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003431 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003432 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003433 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003434 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3435 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003436 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003437 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3438 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003439 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003440 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003441 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003442 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003443 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003444 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003445 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003446 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003447 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003448 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003449 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3450 .serdes_get_strings = mv88e6352_serdes_get_strings,
3451 .serdes_get_stats = mv88e6352_serdes_get_stats,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003452};
3453
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003454static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003455 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003456 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003457 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3458 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003459 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3460 .phy_read = mv88e6xxx_g2_smi_phy_read,
3461 .phy_write = mv88e6xxx_g2_smi_phy_write,
3462 .port_set_link = mv88e6xxx_port_set_link,
3463 .port_set_duplex = mv88e6xxx_port_set_duplex,
3464 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3465 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003466 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003467 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003468 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003469 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003470 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003471 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003472 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003473 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003474 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003475 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003476 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003477 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003478 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3479 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003480 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003481 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3482 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003483 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003484 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003485 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003486 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003487 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003488 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3489 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003490 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003491 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003492 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003493};
3494
3495static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003496 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003497 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003498 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3499 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003500 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3501 .phy_read = mv88e6xxx_g2_smi_phy_read,
3502 .phy_write = mv88e6xxx_g2_smi_phy_write,
3503 .port_set_link = mv88e6xxx_port_set_link,
3504 .port_set_duplex = mv88e6xxx_port_set_duplex,
3505 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3506 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003507 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003508 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003509 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003510 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003511 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003512 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003513 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003514 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003515 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003516 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003517 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003518 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003519 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3520 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003521 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003522 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3523 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003524 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003525 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003526 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003527 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003528 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003529 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3530 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003531 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003532 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003533 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003534};
3535
Vivien Didelotf81ec902016-05-09 13:22:58 -04003536static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3537 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003538 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003539 .family = MV88E6XXX_FAMILY_6097,
3540 .name = "Marvell 88E6085",
3541 .num_databases = 4096,
3542 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003543 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003544 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003545 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003546 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003547 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003548 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003549 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003550 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003551 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003552 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003553 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003554 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003555 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003556 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003557 },
3558
3559 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003560 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003561 .family = MV88E6XXX_FAMILY_6095,
3562 .name = "Marvell 88E6095/88E6095F",
3563 .num_databases = 256,
3564 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003565 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003566 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003567 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003568 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003569 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003570 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003571 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003572 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003573 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003574 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003575 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003576 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003577 },
3578
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003579 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003580 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003581 .family = MV88E6XXX_FAMILY_6097,
3582 .name = "Marvell 88E6097/88E6097F",
3583 .num_databases = 4096,
3584 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003585 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003586 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003587 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003588 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003589 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003590 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003591 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003592 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003593 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003594 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003595 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003596 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003597 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003598 .ops = &mv88e6097_ops,
3599 },
3600
Vivien Didelotf81ec902016-05-09 13:22:58 -04003601 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003602 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003603 .family = MV88E6XXX_FAMILY_6165,
3604 .name = "Marvell 88E6123",
3605 .num_databases = 4096,
3606 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003607 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003608 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003609 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003610 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003611 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003612 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003613 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003614 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003615 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003616 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003617 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003618 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003619 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003620 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003621 },
3622
3623 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003624 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003625 .family = MV88E6XXX_FAMILY_6185,
3626 .name = "Marvell 88E6131",
3627 .num_databases = 256,
3628 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003629 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003630 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003631 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003632 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003633 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003634 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003635 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003636 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003637 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003638 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003639 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003640 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003641 },
3642
Vivien Didelot990e27b2017-03-28 13:50:32 -04003643 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003644 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003645 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003646 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003647 .num_databases = 4096,
3648 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003649 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003650 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003651 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003652 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003653 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003654 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003655 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003656 .age_time_coeff = 3750,
3657 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003658 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003659 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003660 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003661 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003662 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003663 .ops = &mv88e6141_ops,
3664 },
3665
Vivien Didelotf81ec902016-05-09 13:22:58 -04003666 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003667 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003668 .family = MV88E6XXX_FAMILY_6165,
3669 .name = "Marvell 88E6161",
3670 .num_databases = 4096,
3671 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003672 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003673 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003674 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003675 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003676 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003677 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003678 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003679 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003680 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003681 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003682 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003683 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003684 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003685 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003686 },
3687
3688 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003689 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003690 .family = MV88E6XXX_FAMILY_6165,
3691 .name = "Marvell 88E6165",
3692 .num_databases = 4096,
3693 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003694 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003695 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003696 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003697 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003698 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003699 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003700 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003701 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003702 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003703 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003704 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003705 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003706 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003707 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003708 },
3709
3710 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003711 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003712 .family = MV88E6XXX_FAMILY_6351,
3713 .name = "Marvell 88E6171",
3714 .num_databases = 4096,
3715 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003716 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003717 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003718 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003719 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003720 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003721 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003722 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003723 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003724 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003725 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003726 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003727 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003728 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003729 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003730 },
3731
3732 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003733 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003734 .family = MV88E6XXX_FAMILY_6352,
3735 .name = "Marvell 88E6172",
3736 .num_databases = 4096,
3737 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003738 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003739 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003740 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003741 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003742 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003743 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003744 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003745 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003746 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003747 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003748 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003749 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003750 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003751 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003752 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003753 },
3754
3755 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003756 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003757 .family = MV88E6XXX_FAMILY_6351,
3758 .name = "Marvell 88E6175",
3759 .num_databases = 4096,
3760 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003761 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003762 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003763 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003764 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003765 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003766 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003767 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003768 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003769 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003770 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003771 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003772 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003773 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003774 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003775 },
3776
3777 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003778 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003779 .family = MV88E6XXX_FAMILY_6352,
3780 .name = "Marvell 88E6176",
3781 .num_databases = 4096,
3782 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003783 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003784 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003785 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003786 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003787 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003788 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003789 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003790 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003791 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003792 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003793 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003794 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003795 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003796 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003797 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003798 },
3799
3800 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003801 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003802 .family = MV88E6XXX_FAMILY_6185,
3803 .name = "Marvell 88E6185",
3804 .num_databases = 256,
3805 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003806 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003807 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003808 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003809 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003810 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003811 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003812 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003813 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003814 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003815 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003816 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003817 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003818 },
3819
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003820 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003821 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003822 .family = MV88E6XXX_FAMILY_6390,
3823 .name = "Marvell 88E6190",
3824 .num_databases = 4096,
3825 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003826 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003827 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003828 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003829 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003830 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003831 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003832 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003833 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003834 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003835 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003836 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003837 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003838 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003839 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003840 .ops = &mv88e6190_ops,
3841 },
3842
3843 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003844 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003845 .family = MV88E6XXX_FAMILY_6390,
3846 .name = "Marvell 88E6190X",
3847 .num_databases = 4096,
3848 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003849 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003850 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003851 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003852 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003853 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003854 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003855 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003856 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003857 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003858 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003859 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003860 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003861 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003862 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003863 .ops = &mv88e6190x_ops,
3864 },
3865
3866 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003867 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003868 .family = MV88E6XXX_FAMILY_6390,
3869 .name = "Marvell 88E6191",
3870 .num_databases = 4096,
3871 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003872 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04003873 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003874 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003875 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003876 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003877 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003878 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003879 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003880 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003881 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003882 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003883 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003884 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003885 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003886 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003887 },
3888
Vivien Didelotf81ec902016-05-09 13:22:58 -04003889 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003890 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003891 .family = MV88E6XXX_FAMILY_6352,
3892 .name = "Marvell 88E6240",
3893 .num_databases = 4096,
3894 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003895 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003896 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003897 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003898 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003899 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003900 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003901 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003902 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003903 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003904 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003905 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003906 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003907 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003908 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003909 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003910 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003911 },
3912
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003913 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003914 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003915 .family = MV88E6XXX_FAMILY_6390,
3916 .name = "Marvell 88E6290",
3917 .num_databases = 4096,
3918 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003919 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003920 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003921 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003922 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003923 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003924 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003925 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003926 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003927 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003928 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003929 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003930 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003931 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003932 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003933 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003934 .ops = &mv88e6290_ops,
3935 },
3936
Vivien Didelotf81ec902016-05-09 13:22:58 -04003937 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003938 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003939 .family = MV88E6XXX_FAMILY_6320,
3940 .name = "Marvell 88E6320",
3941 .num_databases = 4096,
3942 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003943 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003944 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003945 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003946 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003947 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003948 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003949 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003950 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003951 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003952 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003953 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003954 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003955 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003956 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003957 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003958 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003959 },
3960
3961 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003962 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003963 .family = MV88E6XXX_FAMILY_6320,
3964 .name = "Marvell 88E6321",
3965 .num_databases = 4096,
3966 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003967 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003968 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003969 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003970 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003971 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003972 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003973 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003974 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003975 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003976 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003977 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003978 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003979 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003980 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003981 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003982 },
3983
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003984 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003985 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003986 .family = MV88E6XXX_FAMILY_6341,
3987 .name = "Marvell 88E6341",
3988 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01003989 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003990 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003991 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003992 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003993 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003994 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003995 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003996 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003997 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003998 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003999 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004000 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004001 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004002 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004003 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004004 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004005 .ops = &mv88e6341_ops,
4006 },
4007
Vivien Didelotf81ec902016-05-09 13:22:58 -04004008 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004009 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004010 .family = MV88E6XXX_FAMILY_6351,
4011 .name = "Marvell 88E6350",
4012 .num_databases = 4096,
4013 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004014 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004015 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004016 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004017 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004018 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004019 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004020 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004021 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004022 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004023 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004024 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004025 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004026 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004027 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004028 },
4029
4030 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004031 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004032 .family = MV88E6XXX_FAMILY_6351,
4033 .name = "Marvell 88E6351",
4034 .num_databases = 4096,
4035 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004036 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004037 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004038 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004039 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004040 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004041 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004042 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004043 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004044 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004045 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004046 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004047 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004048 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004049 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004050 },
4051
4052 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004053 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004054 .family = MV88E6XXX_FAMILY_6352,
4055 .name = "Marvell 88E6352",
4056 .num_databases = 4096,
4057 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004058 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004059 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004060 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004061 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004062 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004063 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004064 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004065 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004066 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004067 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004068 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004069 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004070 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004071 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004072 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004073 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004074 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004075 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004076 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004077 .family = MV88E6XXX_FAMILY_6390,
4078 .name = "Marvell 88E6390",
4079 .num_databases = 4096,
4080 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004081 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004082 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004083 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004084 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004085 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004086 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004087 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004088 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004089 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004090 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004091 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004092 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004093 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004094 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004095 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004096 .ops = &mv88e6390_ops,
4097 },
4098 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004099 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004100 .family = MV88E6XXX_FAMILY_6390,
4101 .name = "Marvell 88E6390X",
4102 .num_databases = 4096,
4103 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004104 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004105 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004106 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004107 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004108 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004109 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004110 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004111 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004112 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004113 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004114 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004115 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004116 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004117 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004118 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004119 .ops = &mv88e6390x_ops,
4120 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004121};
4122
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004123static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004124{
Vivien Didelota439c062016-04-17 13:23:58 -04004125 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004126
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004127 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4128 if (mv88e6xxx_table[i].prod_num == prod_num)
4129 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004130
Vivien Didelotb9b37712015-10-30 19:39:48 -04004131 return NULL;
4132}
4133
Vivien Didelotfad09c72016-06-21 12:28:20 -04004134static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004135{
4136 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004137 unsigned int prod_num, rev;
4138 u16 id;
4139 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004140
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004141 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004142 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004143 mutex_unlock(&chip->reg_lock);
4144 if (err)
4145 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004146
Vivien Didelot107fcc12017-06-12 12:37:36 -04004147 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4148 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004149
4150 info = mv88e6xxx_lookup_info(prod_num);
4151 if (!info)
4152 return -ENODEV;
4153
Vivien Didelotcaac8542016-06-20 13:14:09 -04004154 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004155 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004156
Vivien Didelotca070c12016-09-02 14:45:34 -04004157 err = mv88e6xxx_g2_require(chip);
4158 if (err)
4159 return err;
4160
Vivien Didelotfad09c72016-06-21 12:28:20 -04004161 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4162 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004163
4164 return 0;
4165}
4166
Vivien Didelotfad09c72016-06-21 12:28:20 -04004167static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004168{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004169 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004170
Vivien Didelotfad09c72016-06-21 12:28:20 -04004171 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4172 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004173 return NULL;
4174
Vivien Didelotfad09c72016-06-21 12:28:20 -04004175 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004176
Vivien Didelotfad09c72016-06-21 12:28:20 -04004177 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004178 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004179
Vivien Didelotfad09c72016-06-21 12:28:20 -04004180 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004181}
4182
Vivien Didelotfad09c72016-06-21 12:28:20 -04004183static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004184 struct mii_bus *bus, int sw_addr)
4185{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004186 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004187 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004188 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004189 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004190 else
4191 return -EINVAL;
4192
Vivien Didelotfad09c72016-06-21 12:28:20 -04004193 chip->bus = bus;
4194 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004195
4196 return 0;
4197}
4198
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004199static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4200 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004201{
Vivien Didelot04bed142016-08-31 18:06:13 -04004202 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004203
Andrew Lunn443d5a12016-12-03 04:35:18 +01004204 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004205}
4206
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004207#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004208static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4209 struct device *host_dev, int sw_addr,
4210 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004211{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004212 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004213 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004214 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004215
Vivien Didelota439c062016-04-17 13:23:58 -04004216 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004217 if (!bus)
4218 return NULL;
4219
Vivien Didelotfad09c72016-06-21 12:28:20 -04004220 chip = mv88e6xxx_alloc_chip(dsa_dev);
4221 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004222 return NULL;
4223
Vivien Didelotcaac8542016-06-20 13:14:09 -04004224 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004225 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004226
Vivien Didelotfad09c72016-06-21 12:28:20 -04004227 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004228 if (err)
4229 goto free;
4230
Vivien Didelotfad09c72016-06-21 12:28:20 -04004231 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004232 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004233 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004234
Andrew Lunndc30c352016-10-16 19:56:49 +02004235 mutex_lock(&chip->reg_lock);
4236 err = mv88e6xxx_switch_reset(chip);
4237 mutex_unlock(&chip->reg_lock);
4238 if (err)
4239 goto free;
4240
Vivien Didelote57e5e72016-08-15 17:19:00 -04004241 mv88e6xxx_phy_init(chip);
4242
Andrew Lunna3c53be52017-01-24 14:53:50 +01004243 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004244 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004245 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004246
Vivien Didelotfad09c72016-06-21 12:28:20 -04004247 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004248
Vivien Didelotfad09c72016-06-21 12:28:20 -04004249 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004250free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004251 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004252
4253 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004254}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004255#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004256
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004257static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004258 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004259{
4260 /* We don't need any dynamic resource from the kernel (yet),
4261 * so skip the prepare phase.
4262 */
4263
4264 return 0;
4265}
4266
4267static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004268 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004269{
Vivien Didelot04bed142016-08-31 18:06:13 -04004270 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004271
4272 mutex_lock(&chip->reg_lock);
4273 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004274 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004275 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4276 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004277 mutex_unlock(&chip->reg_lock);
4278}
4279
4280static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4281 const struct switchdev_obj_port_mdb *mdb)
4282{
Vivien Didelot04bed142016-08-31 18:06:13 -04004283 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004284 int err;
4285
4286 mutex_lock(&chip->reg_lock);
4287 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004288 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004289 mutex_unlock(&chip->reg_lock);
4290
4291 return err;
4292}
4293
Florian Fainellia82f67a2017-01-08 14:52:08 -08004294static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004295#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004296 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004297#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004298 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004299 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004300 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004301 .phylink_validate = mv88e6xxx_validate,
4302 .phylink_mac_link_state = mv88e6xxx_link_state,
4303 .phylink_mac_config = mv88e6xxx_mac_config,
4304 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4305 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004306 .get_strings = mv88e6xxx_get_strings,
4307 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4308 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004309 .port_enable = mv88e6xxx_port_enable,
4310 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004311 .get_mac_eee = mv88e6xxx_get_mac_eee,
4312 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004313 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004314 .get_eeprom = mv88e6xxx_get_eeprom,
4315 .set_eeprom = mv88e6xxx_set_eeprom,
4316 .get_regs_len = mv88e6xxx_get_regs_len,
4317 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004318 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004319 .port_bridge_join = mv88e6xxx_port_bridge_join,
4320 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4321 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004322 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004323 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4324 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4325 .port_vlan_add = mv88e6xxx_port_vlan_add,
4326 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004327 .port_fdb_add = mv88e6xxx_port_fdb_add,
4328 .port_fdb_del = mv88e6xxx_port_fdb_del,
4329 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004330 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4331 .port_mdb_add = mv88e6xxx_port_mdb_add,
4332 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004333 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4334 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004335 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4336 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4337 .port_txtstamp = mv88e6xxx_port_txtstamp,
4338 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4339 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004340};
4341
Florian Fainelliab3d4082017-01-08 14:52:07 -08004342static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4343 .ops = &mv88e6xxx_switch_ops,
4344};
4345
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004346static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004347{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004348 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004349 struct dsa_switch *ds;
4350
Vivien Didelot73b12042017-03-30 17:37:10 -04004351 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004352 if (!ds)
4353 return -ENOMEM;
4354
Vivien Didelotfad09c72016-06-21 12:28:20 -04004355 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004356 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004357 ds->ageing_time_min = chip->info->age_time_coeff;
4358 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004359
4360 dev_set_drvdata(dev, ds);
4361
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004362 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004363}
4364
Vivien Didelotfad09c72016-06-21 12:28:20 -04004365static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004366{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004367 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004368}
4369
Vivien Didelot57d32312016-06-20 13:13:58 -04004370static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004371{
4372 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004373 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004374 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004375 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004376 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02004377 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004378
Vivien Didelotcaac8542016-06-20 13:14:09 -04004379 compat_info = of_device_get_match_data(dev);
4380 if (!compat_info)
4381 return -EINVAL;
4382
Vivien Didelotfad09c72016-06-21 12:28:20 -04004383 chip = mv88e6xxx_alloc_chip(dev);
4384 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004385 return -ENOMEM;
4386
Vivien Didelotfad09c72016-06-21 12:28:20 -04004387 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004388
Vivien Didelotfad09c72016-06-21 12:28:20 -04004389 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004390 if (err)
4391 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004392
Andrew Lunnb4308f02016-11-21 23:26:55 +01004393 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
4394 if (IS_ERR(chip->reset))
4395 return PTR_ERR(chip->reset);
4396
Vivien Didelotfad09c72016-06-21 12:28:20 -04004397 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004398 if (err)
4399 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004400
Vivien Didelote57e5e72016-08-15 17:19:00 -04004401 mv88e6xxx_phy_init(chip);
4402
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004403 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004404 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004405 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004406
Andrew Lunndc30c352016-10-16 19:56:49 +02004407 mutex_lock(&chip->reg_lock);
4408 err = mv88e6xxx_switch_reset(chip);
4409 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004410 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004411 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004412
Andrew Lunndc30c352016-10-16 19:56:49 +02004413 chip->irq = of_irq_get(np, 0);
4414 if (chip->irq == -EPROBE_DEFER) {
4415 err = chip->irq;
4416 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004417 }
4418
Andrew Lunn294d7112018-02-22 22:58:32 +01004419 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004420 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004421 * controllers
4422 */
4423 mutex_lock(&chip->reg_lock);
4424 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004425 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004426 else
4427 err = mv88e6xxx_irq_poll_setup(chip);
4428 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004429
Andrew Lunn294d7112018-02-22 22:58:32 +01004430 if (err)
4431 goto out;
4432
4433 if (chip->info->g2_irqs > 0) {
4434 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004435 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004436 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004437 }
4438
Andrew Lunn294d7112018-02-22 22:58:32 +01004439 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4440 if (err)
4441 goto out_g2_irq;
4442
4443 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4444 if (err)
4445 goto out_g1_atu_prob_irq;
4446
Andrew Lunna3c53be52017-01-24 14:53:50 +01004447 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004448 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004449 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004450
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004451 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004452 if (err)
4453 goto out_mdio;
4454
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004455 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004456
4457out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004458 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004459out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004460 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004461out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004462 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004463out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004464 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004465 mv88e6xxx_g2_irq_free(chip);
4466out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004467 mutex_lock(&chip->reg_lock);
4468 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004469 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004470 else
4471 mv88e6xxx_irq_poll_free(chip);
4472 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004473out:
4474 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004475}
4476
4477static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4478{
4479 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004480 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004481
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004482 if (chip->info->ptp_support) {
4483 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004484 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004485 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004486
Andrew Lunn930188c2016-08-22 16:01:03 +02004487 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004488 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004489 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004490
Andrew Lunn76f38f12018-03-17 20:21:09 +01004491 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4492 mv88e6xxx_g1_atu_prob_irq_free(chip);
4493
4494 if (chip->info->g2_irqs > 0)
4495 mv88e6xxx_g2_irq_free(chip);
4496
4497 mutex_lock(&chip->reg_lock);
4498 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004499 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004500 else
4501 mv88e6xxx_irq_poll_free(chip);
4502 mutex_unlock(&chip->reg_lock);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004503}
4504
4505static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004506 {
4507 .compatible = "marvell,mv88e6085",
4508 .data = &mv88e6xxx_table[MV88E6085],
4509 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004510 {
4511 .compatible = "marvell,mv88e6190",
4512 .data = &mv88e6xxx_table[MV88E6190],
4513 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004514 { /* sentinel */ },
4515};
4516
4517MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4518
4519static struct mdio_driver mv88e6xxx_driver = {
4520 .probe = mv88e6xxx_probe,
4521 .remove = mv88e6xxx_remove,
4522 .mdiodrv.driver = {
4523 .name = "mv88e6085",
4524 .of_match_table = mv88e6xxx_of_match,
4525 },
4526};
4527
Ben Hutchings98e67302011-11-25 14:36:19 +00004528static int __init mv88e6xxx_init(void)
4529{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004530 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004531 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004532}
4533module_init(mv88e6xxx_init);
4534
4535static void __exit mv88e6xxx_cleanup(void)
4536{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004537 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004538 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004539}
4540module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004541
4542MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4543MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4544MODULE_LICENSE("GPL");