blob: 1cebde80b1017c491c85f7639c979c7bfaf68aa9 [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
Andrew Lunnde2273872016-11-21 23:27:01 +0100998static int mv88e6xxx_stats_set_histogram(struct mv88e6xxx_chip *chip)
999{
1000 if (chip->info->ops->stats_set_histogram)
1001 return chip->info->ops->stats_set_histogram(chip);
1002
1003 return 0;
1004}
1005
Vivien Didelotf81ec902016-05-09 13:22:58 -04001006static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001007{
1008 return 32 * sizeof(u16);
1009}
1010
Vivien Didelotf81ec902016-05-09 13:22:58 -04001011static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1012 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001013{
Vivien Didelot04bed142016-08-31 18:06:13 -04001014 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001015 int err;
1016 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001017 u16 *p = _p;
1018 int i;
1019
1020 regs->version = 0;
1021
1022 memset(p, 0xff, 32 * sizeof(u16));
1023
Vivien Didelotfad09c72016-06-21 12:28:20 -04001024 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001025
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001026 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001027
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001028 err = mv88e6xxx_port_read(chip, port, i, &reg);
1029 if (!err)
1030 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001031 }
Vivien Didelot23062512016-05-09 13:22:45 -04001032
Vivien Didelotfad09c72016-06-21 12:28:20 -04001033 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001034}
1035
Vivien Didelot08f50062017-08-01 16:32:41 -04001036static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1037 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001038{
Vivien Didelot5480db62017-08-01 16:32:40 -04001039 /* Nothing to do on the port's MAC */
1040 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001041}
1042
Vivien Didelot08f50062017-08-01 16:32:41 -04001043static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1044 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001045{
Vivien Didelot5480db62017-08-01 16:32:40 -04001046 /* Nothing to do on the port's MAC */
1047 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001048}
1049
Vivien Didelote5887a22017-03-30 17:37:11 -04001050static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001051{
Vivien Didelote5887a22017-03-30 17:37:11 -04001052 struct dsa_switch *ds = NULL;
1053 struct net_device *br;
1054 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001055 int i;
1056
Vivien Didelote5887a22017-03-30 17:37:11 -04001057 if (dev < DSA_MAX_SWITCHES)
1058 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001059
Vivien Didelote5887a22017-03-30 17:37:11 -04001060 /* Prevent frames from unknown switch or port */
1061 if (!ds || port >= ds->num_ports)
1062 return 0;
1063
1064 /* Frames from DSA links and CPU ports can egress any local port */
1065 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1066 return mv88e6xxx_port_mask(chip);
1067
1068 br = ds->ports[port].bridge_dev;
1069 pvlan = 0;
1070
1071 /* Frames from user ports can egress any local DSA links and CPU ports,
1072 * as well as any local member of their bridge group.
1073 */
1074 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1075 if (dsa_is_cpu_port(chip->ds, i) ||
1076 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001077 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001078 pvlan |= BIT(i);
1079
1080 return pvlan;
1081}
1082
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001083static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001084{
1085 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001086
1087 /* prevent frames from going back out of the port they came in on */
1088 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001089
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001090 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001091}
1092
Vivien Didelotf81ec902016-05-09 13:22:58 -04001093static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1094 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001095{
Vivien Didelot04bed142016-08-31 18:06:13 -04001096 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001097 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001098
Vivien Didelotfad09c72016-06-21 12:28:20 -04001099 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001100 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001101 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001102
1103 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001104 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001105}
1106
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001107static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1108{
1109 int target, port;
1110 int err;
1111
1112 if (!chip->info->global2_addr)
1113 return 0;
1114
1115 /* Initialize the routing port to the 32 possible target devices */
1116 for (target = 0; target < 32; target++) {
1117 port = 0x1f;
1118 if (target < DSA_MAX_SWITCHES)
1119 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1120 port = chip->ds->rtable[target];
1121
1122 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1123 if (err)
1124 return err;
1125 }
1126
Vivien Didelot02317e62018-05-09 11:38:49 -04001127 if (chip->info->ops->set_cascade_port) {
1128 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1129 err = chip->info->ops->set_cascade_port(chip, port);
1130 if (err)
1131 return err;
1132 }
1133
Vivien Didelot23c98912018-05-09 11:38:50 -04001134 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1135 if (err)
1136 return err;
1137
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001138 return 0;
1139}
1140
Vivien Didelotb28f8722018-04-26 21:56:44 -04001141static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1142{
1143 /* Clear all trunk masks and mapping */
1144 if (chip->info->global2_addr)
1145 return mv88e6xxx_g2_trunk_clear(chip);
1146
1147 return 0;
1148}
1149
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001150static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1151{
1152 if (chip->info->ops->rmu_disable)
1153 return chip->info->ops->rmu_disable(chip);
1154
1155 return 0;
1156}
1157
Vivien Didelot9e907d72017-07-17 13:03:43 -04001158static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1159{
1160 if (chip->info->ops->pot_clear)
1161 return chip->info->ops->pot_clear(chip);
1162
1163 return 0;
1164}
1165
Vivien Didelot51c901a2017-07-17 13:03:41 -04001166static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1167{
1168 if (chip->info->ops->mgmt_rsvd2cpu)
1169 return chip->info->ops->mgmt_rsvd2cpu(chip);
1170
1171 return 0;
1172}
1173
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001174static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1175{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001176 int err;
1177
Vivien Didelotdaefc942017-03-11 16:12:54 -05001178 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1179 if (err)
1180 return err;
1181
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001182 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1183 if (err)
1184 return err;
1185
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001186 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1187}
1188
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001189static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1190{
1191 int port;
1192 int err;
1193
1194 if (!chip->info->ops->irl_init_all)
1195 return 0;
1196
1197 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1198 /* Disable ingress rate limiting by resetting all per port
1199 * ingress rate limit resources to their initial state.
1200 */
1201 err = chip->info->ops->irl_init_all(chip, port);
1202 if (err)
1203 return err;
1204 }
1205
1206 return 0;
1207}
1208
Vivien Didelot04a69a12017-10-13 14:18:05 -04001209static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1210{
1211 if (chip->info->ops->set_switch_mac) {
1212 u8 addr[ETH_ALEN];
1213
1214 eth_random_addr(addr);
1215
1216 return chip->info->ops->set_switch_mac(chip, addr);
1217 }
1218
1219 return 0;
1220}
1221
Vivien Didelot17a15942017-03-30 17:37:09 -04001222static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1223{
1224 u16 pvlan = 0;
1225
1226 if (!mv88e6xxx_has_pvt(chip))
1227 return -EOPNOTSUPP;
1228
1229 /* Skip the local source device, which uses in-chip port VLAN */
1230 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001231 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001232
1233 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1234}
1235
Vivien Didelot81228992017-03-30 17:37:08 -04001236static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1237{
Vivien Didelot17a15942017-03-30 17:37:09 -04001238 int dev, port;
1239 int err;
1240
Vivien Didelot81228992017-03-30 17:37:08 -04001241 if (!mv88e6xxx_has_pvt(chip))
1242 return 0;
1243
1244 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1245 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1246 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001247 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1248 if (err)
1249 return err;
1250
1251 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1252 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1253 err = mv88e6xxx_pvt_map(chip, dev, port);
1254 if (err)
1255 return err;
1256 }
1257 }
1258
1259 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001260}
1261
Vivien Didelot749efcb2016-09-22 16:49:24 -04001262static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1263{
1264 struct mv88e6xxx_chip *chip = ds->priv;
1265 int err;
1266
1267 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001268 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001269 mutex_unlock(&chip->reg_lock);
1270
1271 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001272 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001273}
1274
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001275static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1276{
1277 if (!chip->info->max_vid)
1278 return 0;
1279
1280 return mv88e6xxx_g1_vtu_flush(chip);
1281}
1282
Vivien Didelotf1394b782017-05-01 14:05:22 -04001283static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1284 struct mv88e6xxx_vtu_entry *entry)
1285{
1286 if (!chip->info->ops->vtu_getnext)
1287 return -EOPNOTSUPP;
1288
1289 return chip->info->ops->vtu_getnext(chip, entry);
1290}
1291
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001292static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1293 struct mv88e6xxx_vtu_entry *entry)
1294{
1295 if (!chip->info->ops->vtu_loadpurge)
1296 return -EOPNOTSUPP;
1297
1298 return chip->info->ops->vtu_loadpurge(chip, entry);
1299}
1300
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001301static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001302{
1303 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001304 struct mv88e6xxx_vtu_entry vlan = {
1305 .vid = chip->info->max_vid,
1306 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001307 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001308
1309 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1310
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001311 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001312 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001313 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001314 if (err)
1315 return err;
1316
1317 set_bit(*fid, fid_bitmap);
1318 }
1319
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001320 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001321 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001322 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001323 if (err)
1324 return err;
1325
1326 if (!vlan.valid)
1327 break;
1328
1329 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001330 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001331
1332 /* The reset value 0x000 is used to indicate that multiple address
1333 * databases are not needed. Return the next positive available.
1334 */
1335 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001336 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001337 return -ENOSPC;
1338
1339 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001340 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001341}
1342
Vivien Didelot567aa592017-05-01 14:05:25 -04001343static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1344 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001345{
1346 int err;
1347
1348 if (!vid)
1349 return -EINVAL;
1350
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001351 entry->vid = vid - 1;
1352 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001353
Vivien Didelotf1394b782017-05-01 14:05:22 -04001354 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001355 if (err)
1356 return err;
1357
Vivien Didelot567aa592017-05-01 14:05:25 -04001358 if (entry->vid == vid && entry->valid)
1359 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001360
Vivien Didelot567aa592017-05-01 14:05:25 -04001361 if (new) {
1362 int i;
1363
1364 /* Initialize a fresh VLAN entry */
1365 memset(entry, 0, sizeof(*entry));
1366 entry->valid = true;
1367 entry->vid = vid;
1368
Vivien Didelot553a7682017-06-07 18:12:16 -04001369 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001370 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001371 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001372 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001373
1374 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001375 }
1376
Vivien Didelot567aa592017-05-01 14:05:25 -04001377 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1378 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001379}
1380
Vivien Didelotda9c3592016-02-12 12:09:40 -05001381static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1382 u16 vid_begin, u16 vid_end)
1383{
Vivien Didelot04bed142016-08-31 18:06:13 -04001384 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001385 struct mv88e6xxx_vtu_entry vlan = {
1386 .vid = vid_begin - 1,
1387 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001388 int i, err;
1389
Andrew Lunndb06ae412017-09-25 23:32:20 +02001390 /* DSA and CPU ports have to be members of multiple vlans */
1391 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1392 return 0;
1393
Vivien Didelotda9c3592016-02-12 12:09:40 -05001394 if (!vid_begin)
1395 return -EOPNOTSUPP;
1396
Vivien Didelotfad09c72016-06-21 12:28:20 -04001397 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001398
Vivien Didelotda9c3592016-02-12 12:09:40 -05001399 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001400 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001401 if (err)
1402 goto unlock;
1403
1404 if (!vlan.valid)
1405 break;
1406
1407 if (vlan.vid > vid_end)
1408 break;
1409
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001410 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001411 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1412 continue;
1413
Andrew Lunncd886462017-11-09 22:29:53 +01001414 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001415 continue;
1416
Vivien Didelotbd00e052017-05-01 14:05:11 -04001417 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001418 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001419 continue;
1420
Vivien Didelotc8652c82017-10-16 11:12:19 -04001421 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001422 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001423 break; /* same bridge, check next VLAN */
1424
Vivien Didelotc8652c82017-10-16 11:12:19 -04001425 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001426 continue;
1427
Andrew Lunn743fcc22017-11-09 22:29:54 +01001428 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1429 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001430 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001431 err = -EOPNOTSUPP;
1432 goto unlock;
1433 }
1434 } while (vlan.vid < vid_end);
1435
1436unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001437 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001438
1439 return err;
1440}
1441
Vivien Didelotf81ec902016-05-09 13:22:58 -04001442static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1443 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001444{
Vivien Didelot04bed142016-08-31 18:06:13 -04001445 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001446 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1447 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001448 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001449
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001450 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001451 return -EOPNOTSUPP;
1452
Vivien Didelotfad09c72016-06-21 12:28:20 -04001453 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001454 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001455 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001456
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001457 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001458}
1459
Vivien Didelot57d32312016-06-20 13:13:58 -04001460static int
1461mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001462 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001463{
Vivien Didelot04bed142016-08-31 18:06:13 -04001464 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001465 int err;
1466
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001467 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001468 return -EOPNOTSUPP;
1469
Vivien Didelotda9c3592016-02-12 12:09:40 -05001470 /* If the requested port doesn't belong to the same bridge as the VLAN
1471 * members, do not support it (yet) and fallback to software VLAN.
1472 */
1473 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1474 vlan->vid_end);
1475 if (err)
1476 return err;
1477
Vivien Didelot76e398a2015-11-01 12:33:55 -05001478 /* We don't need any dynamic resource from the kernel (yet),
1479 * so skip the prepare phase.
1480 */
1481 return 0;
1482}
1483
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001484static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1485 const unsigned char *addr, u16 vid,
1486 u8 state)
1487{
1488 struct mv88e6xxx_vtu_entry vlan;
1489 struct mv88e6xxx_atu_entry entry;
1490 int err;
1491
1492 /* Null VLAN ID corresponds to the port private database */
1493 if (vid == 0)
1494 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1495 else
1496 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1497 if (err)
1498 return err;
1499
1500 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1501 ether_addr_copy(entry.mac, addr);
1502 eth_addr_dec(entry.mac);
1503
1504 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1505 if (err)
1506 return err;
1507
1508 /* Initialize a fresh ATU entry if it isn't found */
1509 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1510 !ether_addr_equal(entry.mac, addr)) {
1511 memset(&entry, 0, sizeof(entry));
1512 ether_addr_copy(entry.mac, addr);
1513 }
1514
1515 /* Purge the ATU entry only if no port is using it anymore */
1516 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1517 entry.portvec &= ~BIT(port);
1518 if (!entry.portvec)
1519 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1520 } else {
1521 entry.portvec |= BIT(port);
1522 entry.state = state;
1523 }
1524
1525 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1526}
1527
Andrew Lunn87fa8862017-11-09 22:29:56 +01001528static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1529 u16 vid)
1530{
1531 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1532 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1533
1534 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1535}
1536
1537static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1538{
1539 int port;
1540 int err;
1541
1542 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1543 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1544 if (err)
1545 return err;
1546 }
1547
1548 return 0;
1549}
1550
Vivien Didelotfad09c72016-06-21 12:28:20 -04001551static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001552 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001553{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001554 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001555 int err;
1556
Vivien Didelot567aa592017-05-01 14:05:25 -04001557 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001558 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001559 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001560
Vivien Didelotc91498e2017-06-07 18:12:13 -04001561 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001562
Andrew Lunn87fa8862017-11-09 22:29:56 +01001563 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1564 if (err)
1565 return err;
1566
1567 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001568}
1569
Vivien Didelotf81ec902016-05-09 13:22:58 -04001570static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001571 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001572{
Vivien Didelot04bed142016-08-31 18:06:13 -04001573 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001574 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1575 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001576 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001577 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001578
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001579 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001580 return;
1581
Vivien Didelotc91498e2017-06-07 18:12:13 -04001582 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001583 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001584 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001585 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001586 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001587 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001588
Vivien Didelotfad09c72016-06-21 12:28:20 -04001589 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001590
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001591 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001592 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001593 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1594 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001595
Vivien Didelot77064f32016-11-04 03:23:30 +01001596 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001597 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1598 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001599
Vivien Didelotfad09c72016-06-21 12:28:20 -04001600 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001601}
1602
Vivien Didelotfad09c72016-06-21 12:28:20 -04001603static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001604 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001605{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001606 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001607 int i, err;
1608
Vivien Didelot567aa592017-05-01 14:05:25 -04001609 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001610 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001611 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001612
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001613 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001614 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001615 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001616
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001617 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001618
1619 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001620 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001621 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001622 if (vlan.member[i] !=
1623 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001624 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001625 break;
1626 }
1627 }
1628
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001629 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001630 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001631 return err;
1632
Vivien Didelote606ca32017-03-11 16:12:55 -05001633 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001634}
1635
Vivien Didelotf81ec902016-05-09 13:22:58 -04001636static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1637 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001638{
Vivien Didelot04bed142016-08-31 18:06:13 -04001639 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001640 u16 pvid, vid;
1641 int err = 0;
1642
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001643 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001644 return -EOPNOTSUPP;
1645
Vivien Didelotfad09c72016-06-21 12:28:20 -04001646 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001647
Vivien Didelot77064f32016-11-04 03:23:30 +01001648 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001649 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001650 goto unlock;
1651
Vivien Didelot76e398a2015-11-01 12:33:55 -05001652 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001653 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001654 if (err)
1655 goto unlock;
1656
1657 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001658 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001659 if (err)
1660 goto unlock;
1661 }
1662 }
1663
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001664unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001665 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001666
1667 return err;
1668}
1669
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001670static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1671 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001672{
Vivien Didelot04bed142016-08-31 18:06:13 -04001673 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001674 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001675
Vivien Didelotfad09c72016-06-21 12:28:20 -04001676 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001677 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1678 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001679 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001680
1681 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001682}
1683
Vivien Didelotf81ec902016-05-09 13:22:58 -04001684static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001685 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001686{
Vivien Didelot04bed142016-08-31 18:06:13 -04001687 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001688 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001689
Vivien Didelotfad09c72016-06-21 12:28:20 -04001690 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001691 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001692 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001693 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001694
Vivien Didelot83dabd12016-08-31 11:50:04 -04001695 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001696}
1697
Vivien Didelot83dabd12016-08-31 11:50:04 -04001698static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1699 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001700 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001701{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001702 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001703 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001704 int err;
1705
Vivien Didelot27c0e602017-06-15 12:14:01 -04001706 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001707 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001708
1709 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001710 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001711 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001712 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001713 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001714 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001715
Vivien Didelot27c0e602017-06-15 12:14:01 -04001716 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001717 break;
1718
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001719 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001720 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001721
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001722 if (!is_unicast_ether_addr(addr.mac))
1723 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001724
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001725 is_static = (addr.state ==
1726 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1727 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001728 if (err)
1729 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001730 } while (!is_broadcast_ether_addr(addr.mac));
1731
1732 return err;
1733}
1734
Vivien Didelot83dabd12016-08-31 11:50:04 -04001735static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001736 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001737{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001738 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001739 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001740 };
1741 u16 fid;
1742 int err;
1743
1744 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001745 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001746 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001747 mutex_unlock(&chip->reg_lock);
1748
Vivien Didelot83dabd12016-08-31 11:50:04 -04001749 if (err)
1750 return err;
1751
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001752 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001753 if (err)
1754 return err;
1755
1756 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001757 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001758 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001759 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001760 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001761 if (err)
1762 return err;
1763
1764 if (!vlan.valid)
1765 break;
1766
1767 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001768 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001769 if (err)
1770 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001771 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001772
1773 return err;
1774}
1775
Vivien Didelotf81ec902016-05-09 13:22:58 -04001776static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001777 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001778{
Vivien Didelot04bed142016-08-31 18:06:13 -04001779 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001780
Andrew Lunna61e5402018-02-15 14:38:35 +01001781 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001782}
1783
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001784static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1785 struct net_device *br)
1786{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001787 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001788 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001789 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001790 int err;
1791
1792 /* Remap the Port VLAN of each local bridge group member */
1793 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1794 if (chip->ds->ports[port].bridge_dev == br) {
1795 err = mv88e6xxx_port_vlan_map(chip, port);
1796 if (err)
1797 return err;
1798 }
1799 }
1800
Vivien Didelote96a6e02017-03-30 17:37:13 -04001801 if (!mv88e6xxx_has_pvt(chip))
1802 return 0;
1803
1804 /* Remap the Port VLAN of each cross-chip bridge group member */
1805 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1806 ds = chip->ds->dst->ds[dev];
1807 if (!ds)
1808 break;
1809
1810 for (port = 0; port < ds->num_ports; ++port) {
1811 if (ds->ports[port].bridge_dev == br) {
1812 err = mv88e6xxx_pvt_map(chip, dev, port);
1813 if (err)
1814 return err;
1815 }
1816 }
1817 }
1818
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001819 return 0;
1820}
1821
Vivien Didelotf81ec902016-05-09 13:22:58 -04001822static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001823 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001824{
Vivien Didelot04bed142016-08-31 18:06:13 -04001825 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001826 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001827
Vivien Didelotfad09c72016-06-21 12:28:20 -04001828 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001829 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001830 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001831
Vivien Didelot466dfa02016-02-26 13:16:05 -05001832 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001833}
1834
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001835static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1836 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001837{
Vivien Didelot04bed142016-08-31 18:06:13 -04001838 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001839
Vivien Didelotfad09c72016-06-21 12:28:20 -04001840 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001841 if (mv88e6xxx_bridge_map(chip, br) ||
1842 mv88e6xxx_port_vlan_map(chip, port))
1843 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001844 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001845}
1846
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001847static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1848 int port, struct net_device *br)
1849{
1850 struct mv88e6xxx_chip *chip = ds->priv;
1851 int err;
1852
1853 if (!mv88e6xxx_has_pvt(chip))
1854 return 0;
1855
1856 mutex_lock(&chip->reg_lock);
1857 err = mv88e6xxx_pvt_map(chip, dev, port);
1858 mutex_unlock(&chip->reg_lock);
1859
1860 return err;
1861}
1862
1863static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1864 int port, struct net_device *br)
1865{
1866 struct mv88e6xxx_chip *chip = ds->priv;
1867
1868 if (!mv88e6xxx_has_pvt(chip))
1869 return;
1870
1871 mutex_lock(&chip->reg_lock);
1872 if (mv88e6xxx_pvt_map(chip, dev, port))
1873 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1874 mutex_unlock(&chip->reg_lock);
1875}
1876
Vivien Didelot17e708b2016-12-05 17:30:27 -05001877static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1878{
1879 if (chip->info->ops->reset)
1880 return chip->info->ops->reset(chip);
1881
1882 return 0;
1883}
1884
Vivien Didelot309eca62016-12-05 17:30:26 -05001885static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
1886{
1887 struct gpio_desc *gpiod = chip->reset;
1888
1889 /* If there is a GPIO connected to the reset pin, toggle it */
1890 if (gpiod) {
1891 gpiod_set_value_cansleep(gpiod, 1);
1892 usleep_range(10000, 20000);
1893 gpiod_set_value_cansleep(gpiod, 0);
1894 usleep_range(10000, 20000);
1895 }
1896}
1897
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001898static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
1899{
1900 int i, err;
1901
1902 /* Set all ports to the Disabled state */
1903 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04001904 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001905 if (err)
1906 return err;
1907 }
1908
1909 /* Wait for transmit queues to drain,
1910 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
1911 */
1912 usleep_range(2000, 4000);
1913
1914 return 0;
1915}
1916
Vivien Didelotfad09c72016-06-21 12:28:20 -04001917static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04001918{
Vivien Didelota935c052016-09-29 12:21:53 -04001919 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001920
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05001921 err = mv88e6xxx_disable_ports(chip);
1922 if (err)
1923 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04001924
Vivien Didelot309eca62016-12-05 17:30:26 -05001925 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001926
Vivien Didelot17e708b2016-12-05 17:30:27 -05001927 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04001928}
1929
Vivien Didelot43145572017-03-11 16:12:59 -05001930static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001931 enum mv88e6xxx_frame_mode frame,
1932 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01001933{
1934 int err;
1935
Vivien Didelot43145572017-03-11 16:12:59 -05001936 if (!chip->info->ops->port_set_frame_mode)
1937 return -EOPNOTSUPP;
1938
1939 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01001940 if (err)
1941 return err;
1942
Vivien Didelot43145572017-03-11 16:12:59 -05001943 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
1944 if (err)
1945 return err;
1946
1947 if (chip->info->ops->port_set_ether_type)
1948 return chip->info->ops->port_set_ether_type(chip, port, etype);
1949
1950 return 0;
1951}
1952
1953static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
1954{
1955 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001956 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001957 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001958}
1959
1960static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
1961{
1962 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001963 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04001964 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05001965}
1966
1967static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
1968{
1969 return mv88e6xxx_set_port_mode(chip, port,
1970 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04001971 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
1972 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05001973}
1974
1975static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
1976{
1977 if (dsa_is_dsa_port(chip->ds, port))
1978 return mv88e6xxx_set_port_mode_dsa(chip, port);
1979
Vivien Didelot2b3e9892017-10-26 11:22:54 -04001980 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05001981 return mv88e6xxx_set_port_mode_normal(chip, port);
1982
1983 /* Setup CPU port mode depending on its supported tag format */
1984 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
1985 return mv88e6xxx_set_port_mode_dsa(chip, port);
1986
1987 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
1988 return mv88e6xxx_set_port_mode_edsa(chip, port);
1989
1990 return -EINVAL;
1991}
1992
Vivien Didelotea698f42017-03-11 16:12:50 -05001993static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
1994{
1995 bool message = dsa_is_dsa_port(chip->ds, port);
1996
1997 return mv88e6xxx_port_set_message_port(chip, port, message);
1998}
1999
Vivien Didelot601aeed2017-03-11 16:13:00 -05002000static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2001{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002002 struct dsa_switch *ds = chip->ds;
2003 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002004
2005 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002006 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002007 if (chip->info->ops->port_set_egress_floods)
2008 return chip->info->ops->port_set_egress_floods(chip, port,
2009 flood, flood);
2010
2011 return 0;
2012}
2013
Andrew Lunn6d917822017-05-26 01:03:21 +02002014static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2015 bool on)
2016{
Vivien Didelot523a8902017-05-26 18:02:42 -04002017 if (chip->info->ops->serdes_power)
2018 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002019
Vivien Didelot523a8902017-05-26 18:02:42 -04002020 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002021}
2022
Vivien Didelotfa371c82017-12-05 15:34:10 -05002023static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2024{
2025 struct dsa_switch *ds = chip->ds;
2026 int upstream_port;
2027 int err;
2028
Vivien Didelot07073c72017-12-05 15:34:13 -05002029 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002030 if (chip->info->ops->port_set_upstream_port) {
2031 err = chip->info->ops->port_set_upstream_port(chip, port,
2032 upstream_port);
2033 if (err)
2034 return err;
2035 }
2036
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002037 if (port == upstream_port) {
2038 if (chip->info->ops->set_cpu_port) {
2039 err = chip->info->ops->set_cpu_port(chip,
2040 upstream_port);
2041 if (err)
2042 return err;
2043 }
2044
2045 if (chip->info->ops->set_egress_port) {
2046 err = chip->info->ops->set_egress_port(chip,
2047 upstream_port);
2048 if (err)
2049 return err;
2050 }
2051 }
2052
Vivien Didelotfa371c82017-12-05 15:34:10 -05002053 return 0;
2054}
2055
Vivien Didelotfad09c72016-06-21 12:28:20 -04002056static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002057{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002058 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002059 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002060 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002061
Vivien Didelotd78343d2016-11-04 03:23:36 +01002062 /* MAC Forcing register: don't force link, speed, duplex or flow control
2063 * state to any particular values on physical ports, but force the CPU
2064 * port and all DSA ports to their maximum bandwidth and full duplex.
2065 */
2066 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2067 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2068 SPEED_MAX, DUPLEX_FULL,
2069 PHY_INTERFACE_MODE_NA);
2070 else
2071 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2072 SPEED_UNFORCED, DUPLEX_UNFORCED,
2073 PHY_INTERFACE_MODE_NA);
2074 if (err)
2075 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002076
2077 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2078 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2079 * tunneling, determine priority by looking at 802.1p and IP
2080 * priority fields (IP prio has precedence), and set STP state
2081 * to Forwarding.
2082 *
2083 * If this is the CPU link, use DSA or EDSA tagging depending
2084 * on which tagging mode was configured.
2085 *
2086 * If this is a link to another switch, use DSA tagging mode.
2087 *
2088 * If this is the upstream port for this switch, enable
2089 * forwarding of unknown unicasts and multicasts.
2090 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002091 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2092 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2093 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2094 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002095 if (err)
2096 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002097
Vivien Didelot601aeed2017-03-11 16:13:00 -05002098 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002099 if (err)
2100 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002101
Vivien Didelot601aeed2017-03-11 16:13:00 -05002102 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002103 if (err)
2104 return err;
2105
Andrew Lunn04aca992017-05-26 01:03:24 +02002106 /* Enable the SERDES interface for DSA and CPU ports. Normal
2107 * ports SERDES are enabled when the port is enabled, thus
2108 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002109 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002110 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2111 err = mv88e6xxx_serdes_power(chip, port, true);
2112 if (err)
2113 return err;
2114 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002115
Vivien Didelot8efdda42015-08-13 12:52:23 -04002116 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002117 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002118 * untagged frames on this port, do a destination address lookup on all
2119 * received packets as usual, disable ARP mirroring and don't send a
2120 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002121 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002122 err = mv88e6xxx_port_set_map_da(chip, port);
2123 if (err)
2124 return err;
2125
Vivien Didelotfa371c82017-12-05 15:34:10 -05002126 err = mv88e6xxx_setup_upstream_port(chip, port);
2127 if (err)
2128 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002129
Andrew Lunna23b2962017-02-04 20:15:28 +01002130 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002131 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002132 if (err)
2133 return err;
2134
Vivien Didelotcd782652017-06-08 18:34:13 -04002135 if (chip->info->ops->port_set_jumbo_size) {
2136 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002137 if (err)
2138 return err;
2139 }
2140
Andrew Lunn54d792f2015-05-06 01:09:47 +02002141 /* Port Association Vector: when learning source addresses
2142 * of packets, add the address to the address database using
2143 * a port bitmap that has only the bit for this port set and
2144 * the other bits clear.
2145 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002146 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002147 /* Disable learning for CPU port */
2148 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002149 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002150
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002151 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2152 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002153 if (err)
2154 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002155
2156 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002157 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2158 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002159 if (err)
2160 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002161
Vivien Didelot08984322017-06-08 18:34:12 -04002162 if (chip->info->ops->port_pause_limit) {
2163 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002164 if (err)
2165 return err;
2166 }
2167
Vivien Didelotc8c94892017-03-11 16:13:01 -05002168 if (chip->info->ops->port_disable_learn_limit) {
2169 err = chip->info->ops->port_disable_learn_limit(chip, port);
2170 if (err)
2171 return err;
2172 }
2173
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002174 if (chip->info->ops->port_disable_pri_override) {
2175 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002176 if (err)
2177 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002178 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002179
Andrew Lunnef0a7312016-12-03 04:35:16 +01002180 if (chip->info->ops->port_tag_remap) {
2181 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002182 if (err)
2183 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002184 }
2185
Andrew Lunnef70b112016-12-03 04:45:18 +01002186 if (chip->info->ops->port_egress_rate_limiting) {
2187 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002188 if (err)
2189 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002190 }
2191
Vivien Didelotea698f42017-03-11 16:12:50 -05002192 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002193 if (err)
2194 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002195
Vivien Didelot207afda2016-04-14 14:42:09 -04002196 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002197 * database, and allow bidirectional communication between the
2198 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002199 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002200 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002201 if (err)
2202 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002203
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002204 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002205 if (err)
2206 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002207
2208 /* Default VLAN ID and priority: don't set a default VLAN
2209 * ID, and set the default packet priority to zero.
2210 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002211 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002212}
2213
Andrew Lunn04aca992017-05-26 01:03:24 +02002214static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2215 struct phy_device *phydev)
2216{
2217 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002218 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002219
2220 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002221 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02002222 mutex_unlock(&chip->reg_lock);
2223
2224 return err;
2225}
2226
2227static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2228 struct phy_device *phydev)
2229{
2230 struct mv88e6xxx_chip *chip = ds->priv;
2231
2232 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002233 if (mv88e6xxx_serdes_power(chip, port, false))
2234 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02002235 mutex_unlock(&chip->reg_lock);
2236}
2237
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002238static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2239 unsigned int ageing_time)
2240{
Vivien Didelot04bed142016-08-31 18:06:13 -04002241 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002242 int err;
2243
2244 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002245 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002246 mutex_unlock(&chip->reg_lock);
2247
2248 return err;
2249}
2250
Vivien Didelot97299342016-07-18 20:45:30 -04002251static int mv88e6xxx_g1_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002252{
2253 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002254
Vivien Didelot08a01262016-05-09 13:22:50 -04002255 /* Configure the IP ToS mapping registers. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002256 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_0, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002257 if (err)
2258 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002259 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_1, 0x0000);
Vivien Didelot08a01262016-05-09 13:22:50 -04002260 if (err)
2261 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002262 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_2, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002263 if (err)
2264 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002265 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_3, 0x5555);
Vivien Didelot08a01262016-05-09 13:22:50 -04002266 if (err)
2267 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002268 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_4, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002269 if (err)
2270 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002271 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_5, 0xaaaa);
Vivien Didelot08a01262016-05-09 13:22:50 -04002272 if (err)
2273 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002274 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_6, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002275 if (err)
2276 return err;
Vivien Didelotccba8f32017-06-15 12:14:06 -04002277 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IP_PRI_7, 0xffff);
Vivien Didelot08a01262016-05-09 13:22:50 -04002278 if (err)
2279 return err;
2280
2281 /* Configure the IEEE 802.1p priority mapping register. */
Vivien Didelotccba8f32017-06-15 12:14:06 -04002282 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_IEEE_PRI, 0xfa41);
Vivien Didelot08a01262016-05-09 13:22:50 -04002283 if (err)
2284 return err;
2285
Andrew Lunnde2273872016-11-21 23:27:01 +01002286 /* Initialize the statistics unit */
2287 err = mv88e6xxx_stats_set_histogram(chip);
2288 if (err)
2289 return err;
2290
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002291 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002292}
2293
Vivien Didelotf81ec902016-05-09 13:22:58 -04002294static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002295{
Vivien Didelot04bed142016-08-31 18:06:13 -04002296 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot552238b2016-05-09 13:22:49 -04002297 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002298 int i;
2299
Vivien Didelotfad09c72016-06-21 12:28:20 -04002300 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002301 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002302
Vivien Didelotfad09c72016-06-21 12:28:20 -04002303 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002304
Vivien Didelot97299342016-07-18 20:45:30 -04002305 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002306 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002307 if (dsa_is_unused_port(ds, i))
2308 continue;
2309
Vivien Didelot97299342016-07-18 20:45:30 -04002310 err = mv88e6xxx_setup_port(chip, i);
2311 if (err)
2312 goto unlock;
2313 }
2314
2315 /* Setup Switch Global 1 Registers */
2316 err = mv88e6xxx_g1_setup(chip);
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002317 if (err)
2318 goto unlock;
2319
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002320 err = mv88e6xxx_irl_setup(chip);
2321 if (err)
2322 goto unlock;
2323
Vivien Didelot04a69a12017-10-13 14:18:05 -04002324 err = mv88e6xxx_mac_setup(chip);
2325 if (err)
2326 goto unlock;
2327
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002328 err = mv88e6xxx_phy_setup(chip);
2329 if (err)
2330 goto unlock;
2331
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002332 err = mv88e6xxx_vtu_setup(chip);
2333 if (err)
2334 goto unlock;
2335
Vivien Didelot81228992017-03-30 17:37:08 -04002336 err = mv88e6xxx_pvt_setup(chip);
2337 if (err)
2338 goto unlock;
2339
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002340 err = mv88e6xxx_atu_setup(chip);
2341 if (err)
2342 goto unlock;
2343
Andrew Lunn87fa8862017-11-09 22:29:56 +01002344 err = mv88e6xxx_broadcast_setup(chip, 0);
2345 if (err)
2346 goto unlock;
2347
Vivien Didelot9e907d72017-07-17 13:03:43 -04002348 err = mv88e6xxx_pot_setup(chip);
2349 if (err)
2350 goto unlock;
2351
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002352 err = mv88e6xxx_rmu_setup(chip);
2353 if (err)
2354 goto unlock;
2355
Vivien Didelot51c901a2017-07-17 13:03:41 -04002356 err = mv88e6xxx_rsvd2cpu_setup(chip);
2357 if (err)
2358 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002359
Vivien Didelotb28f8722018-04-26 21:56:44 -04002360 err = mv88e6xxx_trunk_setup(chip);
2361 if (err)
2362 goto unlock;
2363
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002364 err = mv88e6xxx_devmap_setup(chip);
2365 if (err)
2366 goto unlock;
2367
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002368 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002369 if (chip->info->ptp_support) {
2370 err = mv88e6xxx_ptp_setup(chip);
2371 if (err)
2372 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002373
2374 err = mv88e6xxx_hwtstamp_setup(chip);
2375 if (err)
2376 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002377 }
2378
Vivien Didelot6b17e862015-08-13 12:52:18 -04002379unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002380 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002381
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002382 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002383}
2384
Vivien Didelote57e5e72016-08-15 17:19:00 -04002385static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002386{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002387 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2388 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002389 u16 val;
2390 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002391
Andrew Lunnee26a222017-01-24 14:53:48 +01002392 if (!chip->info->ops->phy_read)
2393 return -EOPNOTSUPP;
2394
Vivien Didelotfad09c72016-06-21 12:28:20 -04002395 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002396 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002397 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002398
Andrew Lunnda9f3302017-02-01 03:40:05 +01002399 if (reg == MII_PHYSID2) {
2400 /* Some internal PHYS don't have a model number. Use
2401 * the mv88e6390 family model number instead.
2402 */
2403 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002404 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002405 }
2406
Vivien Didelote57e5e72016-08-15 17:19:00 -04002407 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002408}
2409
Vivien Didelote57e5e72016-08-15 17:19:00 -04002410static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002411{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002412 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2413 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002414 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002415
Andrew Lunnee26a222017-01-24 14:53:48 +01002416 if (!chip->info->ops->phy_write)
2417 return -EOPNOTSUPP;
2418
Vivien Didelotfad09c72016-06-21 12:28:20 -04002419 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002420 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002421 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002422
2423 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002424}
2425
Vivien Didelotfad09c72016-06-21 12:28:20 -04002426static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002427 struct device_node *np,
2428 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002429{
2430 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002431 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002432 struct mii_bus *bus;
2433 int err;
2434
Andrew Lunn2510bab2018-02-22 01:51:49 +01002435 if (external) {
2436 mutex_lock(&chip->reg_lock);
2437 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2438 mutex_unlock(&chip->reg_lock);
2439
2440 if (err)
2441 return err;
2442 }
2443
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002444 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002445 if (!bus)
2446 return -ENOMEM;
2447
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002448 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002449 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002450 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002451 INIT_LIST_HEAD(&mdio_bus->list);
2452 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002453
Andrew Lunnb516d452016-06-04 21:17:06 +02002454 if (np) {
2455 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002456 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002457 } else {
2458 bus->name = "mv88e6xxx SMI";
2459 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2460 }
2461
2462 bus->read = mv88e6xxx_mdio_read;
2463 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002464 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002465
Andrew Lunn6f882842018-03-17 20:32:05 +01002466 if (!external) {
2467 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2468 if (err)
2469 return err;
2470 }
2471
Andrew Lunna3c53be52017-01-24 14:53:50 +01002472 if (np)
2473 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002474 else
2475 err = mdiobus_register(bus);
2476 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002477 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002478 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002479 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002480 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002481
2482 if (external)
2483 list_add_tail(&mdio_bus->list, &chip->mdios);
2484 else
2485 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002486
2487 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002488}
2489
Andrew Lunna3c53be52017-01-24 14:53:50 +01002490static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2491 { .compatible = "marvell,mv88e6xxx-mdio-external",
2492 .data = (void *)true },
2493 { },
2494};
2495
Andrew Lunn3126aee2017-12-07 01:05:57 +01002496static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2497
2498{
2499 struct mv88e6xxx_mdio_bus *mdio_bus;
2500 struct mii_bus *bus;
2501
2502 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2503 bus = mdio_bus->bus;
2504
Andrew Lunn6f882842018-03-17 20:32:05 +01002505 if (!mdio_bus->external)
2506 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2507
Andrew Lunn3126aee2017-12-07 01:05:57 +01002508 mdiobus_unregister(bus);
2509 }
2510}
2511
Andrew Lunna3c53be52017-01-24 14:53:50 +01002512static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2513 struct device_node *np)
2514{
2515 const struct of_device_id *match;
2516 struct device_node *child;
2517 int err;
2518
2519 /* Always register one mdio bus for the internal/default mdio
2520 * bus. This maybe represented in the device tree, but is
2521 * optional.
2522 */
2523 child = of_get_child_by_name(np, "mdio");
2524 err = mv88e6xxx_mdio_register(chip, child, false);
2525 if (err)
2526 return err;
2527
2528 /* Walk the device tree, and see if there are any other nodes
2529 * which say they are compatible with the external mdio
2530 * bus.
2531 */
2532 for_each_available_child_of_node(np, child) {
2533 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2534 if (match) {
2535 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002536 if (err) {
2537 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002538 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002539 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002540 }
2541 }
2542
2543 return 0;
2544}
2545
Vivien Didelot855b1932016-07-20 18:18:35 -04002546static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2547{
Vivien Didelot04bed142016-08-31 18:06:13 -04002548 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002549
2550 return chip->eeprom_len;
2551}
2552
Vivien Didelot855b1932016-07-20 18:18:35 -04002553static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2554 struct ethtool_eeprom *eeprom, u8 *data)
2555{
Vivien Didelot04bed142016-08-31 18:06:13 -04002556 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002557 int err;
2558
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002559 if (!chip->info->ops->get_eeprom)
2560 return -EOPNOTSUPP;
2561
Vivien Didelot855b1932016-07-20 18:18:35 -04002562 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002563 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002564 mutex_unlock(&chip->reg_lock);
2565
2566 if (err)
2567 return err;
2568
2569 eeprom->magic = 0xc3ec4951;
2570
2571 return 0;
2572}
2573
Vivien Didelot855b1932016-07-20 18:18:35 -04002574static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2575 struct ethtool_eeprom *eeprom, u8 *data)
2576{
Vivien Didelot04bed142016-08-31 18:06:13 -04002577 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002578 int err;
2579
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002580 if (!chip->info->ops->set_eeprom)
2581 return -EOPNOTSUPP;
2582
Vivien Didelot855b1932016-07-20 18:18:35 -04002583 if (eeprom->magic != 0xc3ec4951)
2584 return -EINVAL;
2585
2586 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002587 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002588 mutex_unlock(&chip->reg_lock);
2589
2590 return err;
2591}
2592
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002593static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002594 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002595 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002596 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002597 .phy_read = mv88e6185_phy_ppu_read,
2598 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002599 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002600 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002601 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002602 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002603 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002604 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002605 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002606 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002607 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002608 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002609 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002610 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002611 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002612 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2613 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002614 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002615 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2616 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002617 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002618 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002619 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002620 .ppu_enable = mv88e6185_g1_ppu_enable,
2621 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002622 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002623 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002624 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002625 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behún5bafeb6e2018-05-04 19:26:10 +02002626 .serdes_power = mv88e6341_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002627};
2628
2629static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002630 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002631 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002632 .phy_read = mv88e6185_phy_ppu_read,
2633 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002634 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002635 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002636 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002637 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002638 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002639 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002640 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002641 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002642 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2643 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002644 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002645 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002646 .ppu_enable = mv88e6185_g1_ppu_enable,
2647 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002648 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002649 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002650 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002651};
2652
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002653static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002654 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002655 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002656 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2657 .phy_read = mv88e6xxx_g2_smi_phy_read,
2658 .phy_write = mv88e6xxx_g2_smi_phy_write,
2659 .port_set_link = mv88e6xxx_port_set_link,
2660 .port_set_duplex = mv88e6xxx_port_set_duplex,
2661 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002662 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002663 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002664 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002665 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002666 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002667 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002668 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002669 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002670 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002671 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002672 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002673 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2674 .stats_get_strings = mv88e6095_stats_get_strings,
2675 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002676 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2677 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002678 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002679 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002680 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002681 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002682 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002683 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002684 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002685};
2686
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002687static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002688 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002689 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002690 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002691 .phy_read = mv88e6xxx_g2_smi_phy_read,
2692 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002693 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002694 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002695 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002696 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002697 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002698 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002699 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002700 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002701 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002702 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2703 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002704 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002705 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2706 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002707 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002708 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002709 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002710 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002711 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002712 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002713};
2714
2715static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002716 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002717 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002718 .phy_read = mv88e6185_phy_ppu_read,
2719 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002720 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002721 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002722 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002723 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002724 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002725 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002726 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002727 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002728 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002729 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002730 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002731 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002732 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002733 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2734 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002735 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002736 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2737 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002738 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002739 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002740 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002741 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002742 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002743 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002744 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002745 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002746};
2747
Vivien Didelot990e27b2017-03-28 13:50:32 -04002748static const struct mv88e6xxx_ops mv88e6141_ops = {
2749 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002750 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002751 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2752 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2753 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2754 .phy_read = mv88e6xxx_g2_smi_phy_read,
2755 .phy_write = mv88e6xxx_g2_smi_phy_write,
2756 .port_set_link = mv88e6xxx_port_set_link,
2757 .port_set_duplex = mv88e6xxx_port_set_duplex,
2758 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2759 .port_set_speed = mv88e6390_port_set_speed,
2760 .port_tag_remap = mv88e6095_port_tag_remap,
2761 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2762 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2763 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002764 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002765 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002766 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002767 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2768 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
2769 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002770 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002771 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2772 .stats_get_strings = mv88e6320_stats_get_strings,
2773 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002774 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2775 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002776 .watchdog_ops = &mv88e6390_watchdog_ops,
2777 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002778 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002779 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002780 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002781 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002782 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002783};
2784
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002785static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002786 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002787 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002788 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002789 .phy_read = mv88e6xxx_g2_smi_phy_read,
2790 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002791 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002792 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002793 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002794 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002795 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002796 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002797 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002798 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002799 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002800 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002801 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002802 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002803 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002804 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002805 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2806 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002807 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002808 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2809 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002810 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002811 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002812 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002813 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002814 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002815 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002816};
2817
2818static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002819 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002820 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002821 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002822 .phy_read = mv88e6165_phy_read,
2823 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002824 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002825 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002826 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002827 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002828 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002829 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002830 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002831 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2832 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002833 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002834 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2835 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002836 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002837 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002838 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002839 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002840 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002841 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002842};
2843
2844static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002845 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002846 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002847 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002848 .phy_read = mv88e6xxx_g2_smi_phy_read,
2849 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002850 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002851 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002852 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002853 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002854 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002855 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002856 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002857 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002858 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002859 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002860 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002861 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002862 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002863 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002864 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002865 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2866 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002867 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002868 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2869 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002870 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002871 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002872 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002873 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002874 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002875 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002876};
2877
2878static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002879 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002880 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002881 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2882 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002883 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002884 .phy_read = mv88e6xxx_g2_smi_phy_read,
2885 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002886 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002887 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002888 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002889 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002890 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002891 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002892 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002893 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002894 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002895 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002896 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002897 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002898 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002899 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002900 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002901 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2902 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002903 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002904 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2905 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002906 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002907 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002908 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002909 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002910 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002911 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002912 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002913 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002914 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002915};
2916
2917static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002918 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002919 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002920 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002921 .phy_read = mv88e6xxx_g2_smi_phy_read,
2922 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002923 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002924 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002925 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002926 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002927 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002928 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002929 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002930 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002931 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002932 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002933 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002934 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002935 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002936 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002937 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002938 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2939 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002940 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002941 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2942 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002943 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002944 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002945 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002946 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002947 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002948 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behún5bafeb6e2018-05-04 19:26:10 +02002949 .serdes_power = mv88e6341_serdes_power,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002950};
2951
2952static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002953 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002954 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002955 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
2956 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002957 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002958 .phy_read = mv88e6xxx_g2_smi_phy_read,
2959 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002960 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002961 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01002962 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002963 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002964 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002965 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002966 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002967 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002968 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002969 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002970 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002971 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002972 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002973 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002974 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002975 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2976 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002977 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002978 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2979 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002980 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002981 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002982 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002983 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002984 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002985 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002986 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02002987 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002988 .gpio_ops = &mv88e6352_gpio_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002989};
2990
2991static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002992 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002993 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002994 .phy_read = mv88e6185_phy_ppu_read,
2995 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002996 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002997 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002998 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002999 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003000 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003001 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003002 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003003 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003004 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003005 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3006 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003007 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003008 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3009 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003010 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003011 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003012 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003013 .ppu_enable = mv88e6185_g1_ppu_enable,
3014 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003015 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003016 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003017 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003018};
3019
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003020static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003021 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003022 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003023 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3024 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003025 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3026 .phy_read = mv88e6xxx_g2_smi_phy_read,
3027 .phy_write = mv88e6xxx_g2_smi_phy_write,
3028 .port_set_link = mv88e6xxx_port_set_link,
3029 .port_set_duplex = mv88e6xxx_port_set_duplex,
3030 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3031 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003032 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003033 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003034 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003035 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003036 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003037 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003038 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003039 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003040 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003041 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3042 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003043 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003044 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3045 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003046 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003047 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003048 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003049 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003050 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003051 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3052 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003053 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003054 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003055};
3056
3057static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003058 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003059 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003060 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3061 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003062 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3063 .phy_read = mv88e6xxx_g2_smi_phy_read,
3064 .phy_write = mv88e6xxx_g2_smi_phy_write,
3065 .port_set_link = mv88e6xxx_port_set_link,
3066 .port_set_duplex = mv88e6xxx_port_set_duplex,
3067 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3068 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003069 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003070 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003071 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003072 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003073 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003074 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003075 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003076 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003077 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003078 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3079 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003080 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003081 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3082 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003083 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003084 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003085 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003086 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003087 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003088 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3089 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003090 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003091 .gpio_ops = &mv88e6352_gpio_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003092};
3093
3094static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003095 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003096 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003097 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3098 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003099 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3100 .phy_read = mv88e6xxx_g2_smi_phy_read,
3101 .phy_write = mv88e6xxx_g2_smi_phy_write,
3102 .port_set_link = mv88e6xxx_port_set_link,
3103 .port_set_duplex = mv88e6xxx_port_set_duplex,
3104 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3105 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003106 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003107 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003108 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003109 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003110 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003111 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003112 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003113 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003114 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003115 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3116 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003117 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003118 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3119 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003120 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003121 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003122 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003123 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003124 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003125 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3126 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003127 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003128};
3129
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003130static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003131 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003132 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003133 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3134 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003135 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003136 .phy_read = mv88e6xxx_g2_smi_phy_read,
3137 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003138 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003139 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003140 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003141 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003142 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003143 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003144 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003145 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003146 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003147 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003148 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003149 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003150 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003151 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003152 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003153 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3154 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003155 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003156 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3157 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003158 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003159 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003160 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003161 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003162 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003163 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003164 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003165 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003166 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003167 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003168};
3169
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003170static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003171 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003172 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003173 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3174 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003175 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3176 .phy_read = mv88e6xxx_g2_smi_phy_read,
3177 .phy_write = mv88e6xxx_g2_smi_phy_write,
3178 .port_set_link = mv88e6xxx_port_set_link,
3179 .port_set_duplex = mv88e6xxx_port_set_duplex,
3180 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3181 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003182 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003183 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003184 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003185 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003186 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003187 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003188 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003189 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003190 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003191 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003192 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3193 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003194 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003195 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3196 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003197 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003198 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003199 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003200 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003201 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003202 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3203 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003204 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003205 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003206 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003207};
3208
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003209static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003210 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003211 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003212 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3213 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003214 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003215 .phy_read = mv88e6xxx_g2_smi_phy_read,
3216 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003217 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003218 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003219 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003220 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003221 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003222 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003223 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003224 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003225 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003226 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003227 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003228 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003229 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003230 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003231 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3232 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003233 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003234 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3235 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003236 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003237 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003238 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003239 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003240 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003241 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003242 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003243};
3244
3245static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003246 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003247 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003248 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3249 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003250 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003251 .phy_read = mv88e6xxx_g2_smi_phy_read,
3252 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003253 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003254 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003255 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003256 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003257 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003258 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003259 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003260 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003261 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003262 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003263 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003264 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003265 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003266 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003267 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3268 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003269 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003270 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3271 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003272 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003273 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003274 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003275 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003276 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003277};
3278
Vivien Didelot16e329a2017-03-28 13:50:33 -04003279static const struct mv88e6xxx_ops mv88e6341_ops = {
3280 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003281 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003282 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3283 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3284 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3285 .phy_read = mv88e6xxx_g2_smi_phy_read,
3286 .phy_write = mv88e6xxx_g2_smi_phy_write,
3287 .port_set_link = mv88e6xxx_port_set_link,
3288 .port_set_duplex = mv88e6xxx_port_set_duplex,
3289 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3290 .port_set_speed = mv88e6390_port_set_speed,
3291 .port_tag_remap = mv88e6095_port_tag_remap,
3292 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3293 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3294 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003295 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003296 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003297 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003298 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3299 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
3300 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003301 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003302 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3303 .stats_get_strings = mv88e6320_stats_get_strings,
3304 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003305 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3306 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003307 .watchdog_ops = &mv88e6390_watchdog_ops,
3308 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003309 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003310 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003311 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003312 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003313 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003314 .avb_ops = &mv88e6390_avb_ops,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003315};
3316
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003317static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003318 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003319 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003320 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003321 .phy_read = mv88e6xxx_g2_smi_phy_read,
3322 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003323 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003324 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003325 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003326 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003327 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003328 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003329 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003330 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003331 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003332 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003333 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003334 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003335 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003336 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003337 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003338 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3339 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003340 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003341 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3342 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003343 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003344 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003345 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003346 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003347 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003348 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003349};
3350
3351static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003352 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003353 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003354 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003355 .phy_read = mv88e6xxx_g2_smi_phy_read,
3356 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003357 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003358 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003359 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003360 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003361 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003362 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003363 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003364 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003365 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003366 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003367 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003368 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003369 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003370 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003371 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003372 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3373 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003374 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003375 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3376 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003377 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003378 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003379 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003380 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003381 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003382 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003383 .avb_ops = &mv88e6352_avb_ops,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003384};
3385
3386static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003387 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003388 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003389 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3390 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003391 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003392 .phy_read = mv88e6xxx_g2_smi_phy_read,
3393 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003394 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003395 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003396 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003397 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003398 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003399 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003400 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003401 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003402 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003403 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003404 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003405 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003406 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003407 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003408 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003409 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3410 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003411 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003412 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3413 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003414 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003415 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003416 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003417 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003418 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003419 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003420 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003421 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003422 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003423 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003424 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3425 .serdes_get_strings = mv88e6352_serdes_get_strings,
3426 .serdes_get_stats = mv88e6352_serdes_get_stats,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003427};
3428
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003429static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003430 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003431 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003432 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3433 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003434 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3435 .phy_read = mv88e6xxx_g2_smi_phy_read,
3436 .phy_write = mv88e6xxx_g2_smi_phy_write,
3437 .port_set_link = mv88e6xxx_port_set_link,
3438 .port_set_duplex = mv88e6xxx_port_set_duplex,
3439 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3440 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003441 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003442 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003443 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003444 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003445 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003446 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003447 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003448 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003449 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003450 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003451 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003452 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003453 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3454 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003455 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003456 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3457 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003458 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003459 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003460 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003461 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003462 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003463 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3464 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003465 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003466 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003467 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003468};
3469
3470static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003471 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003472 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003473 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3474 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003475 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3476 .phy_read = mv88e6xxx_g2_smi_phy_read,
3477 .phy_write = mv88e6xxx_g2_smi_phy_write,
3478 .port_set_link = mv88e6xxx_port_set_link,
3479 .port_set_duplex = mv88e6xxx_port_set_duplex,
3480 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3481 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003482 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003483 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003484 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003485 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003486 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003487 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003488 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003489 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003490 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003491 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn79523472016-11-21 23:27:00 +01003492 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003493 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003494 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3495 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003496 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003497 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3498 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003499 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003500 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003501 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003502 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003503 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003504 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3505 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003506 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003507 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003508 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003509};
3510
Vivien Didelotf81ec902016-05-09 13:22:58 -04003511static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3512 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003513 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003514 .family = MV88E6XXX_FAMILY_6097,
3515 .name = "Marvell 88E6085",
3516 .num_databases = 4096,
3517 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003518 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003519 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003520 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003521 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003522 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003523 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003524 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003525 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003526 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003527 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003528 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003529 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003530 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003531 },
3532
3533 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003534 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003535 .family = MV88E6XXX_FAMILY_6095,
3536 .name = "Marvell 88E6095/88E6095F",
3537 .num_databases = 256,
3538 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003539 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003540 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003541 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003542 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003543 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003544 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003545 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003546 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003547 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003548 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003549 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003550 },
3551
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003552 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003553 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003554 .family = MV88E6XXX_FAMILY_6097,
3555 .name = "Marvell 88E6097/88E6097F",
3556 .num_databases = 4096,
3557 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003558 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003559 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003560 .port_base_addr = 0x10,
3561 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003562 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003563 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003564 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003565 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003566 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003567 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003568 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003569 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003570 .ops = &mv88e6097_ops,
3571 },
3572
Vivien Didelotf81ec902016-05-09 13:22:58 -04003573 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003574 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003575 .family = MV88E6XXX_FAMILY_6165,
3576 .name = "Marvell 88E6123",
3577 .num_databases = 4096,
3578 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003579 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003580 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003581 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003582 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003583 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003584 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003585 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003586 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003587 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003588 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003589 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003590 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003591 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003592 },
3593
3594 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003595 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003596 .family = MV88E6XXX_FAMILY_6185,
3597 .name = "Marvell 88E6131",
3598 .num_databases = 256,
3599 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003600 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003601 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003602 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003603 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003604 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003605 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003606 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003607 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003608 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003609 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003610 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003611 },
3612
Vivien Didelot990e27b2017-03-28 13:50:32 -04003613 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003614 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003615 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003616 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003617 .num_databases = 4096,
3618 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003619 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003620 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003621 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003622 .port_base_addr = 0x10,
3623 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003624 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003625 .age_time_coeff = 3750,
3626 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003627 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003628 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003629 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003630 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003631 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003632 .ops = &mv88e6141_ops,
3633 },
3634
Vivien Didelotf81ec902016-05-09 13:22:58 -04003635 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003636 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003637 .family = MV88E6XXX_FAMILY_6165,
3638 .name = "Marvell 88E6161",
3639 .num_databases = 4096,
3640 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003641 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003642 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003643 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003644 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003645 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003646 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003647 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003648 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003649 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003650 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003651 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003652 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003653 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003654 },
3655
3656 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003657 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003658 .family = MV88E6XXX_FAMILY_6165,
3659 .name = "Marvell 88E6165",
3660 .num_databases = 4096,
3661 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003662 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003663 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003664 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003665 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003666 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003667 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003668 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003669 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003670 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003671 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003672 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003673 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003674 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003675 },
3676
3677 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003678 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003679 .family = MV88E6XXX_FAMILY_6351,
3680 .name = "Marvell 88E6171",
3681 .num_databases = 4096,
3682 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003683 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003684 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003685 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003686 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003687 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003688 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003689 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003690 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003691 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003692 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003693 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003694 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003695 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003696 },
3697
3698 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003699 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003700 .family = MV88E6XXX_FAMILY_6352,
3701 .name = "Marvell 88E6172",
3702 .num_databases = 4096,
3703 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003704 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003705 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003706 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003707 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003708 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003709 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003710 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003711 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003712 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003713 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003714 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003715 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003716 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003717 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003718 },
3719
3720 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003721 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003722 .family = MV88E6XXX_FAMILY_6351,
3723 .name = "Marvell 88E6175",
3724 .num_databases = 4096,
3725 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003726 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003727 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003728 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003729 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003730 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003731 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003732 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003733 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003734 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003735 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003736 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003737 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003738 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003739 },
3740
3741 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003742 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003743 .family = MV88E6XXX_FAMILY_6352,
3744 .name = "Marvell 88E6176",
3745 .num_databases = 4096,
3746 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003747 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003748 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003749 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003750 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003751 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003752 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003753 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003754 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003755 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003756 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003757 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003758 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003759 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003760 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003761 },
3762
3763 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003764 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003765 .family = MV88E6XXX_FAMILY_6185,
3766 .name = "Marvell 88E6185",
3767 .num_databases = 256,
3768 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003769 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003770 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003771 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003772 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003773 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003774 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003775 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003776 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003777 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003778 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003779 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003780 },
3781
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003782 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003783 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003784 .family = MV88E6XXX_FAMILY_6390,
3785 .name = "Marvell 88E6190",
3786 .num_databases = 4096,
3787 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003788 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003789 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003790 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003791 .port_base_addr = 0x0,
3792 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003793 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003794 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003795 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003796 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003797 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04003798 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003799 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05003800 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003801 .ops = &mv88e6190_ops,
3802 },
3803
3804 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003805 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003806 .family = MV88E6XXX_FAMILY_6390,
3807 .name = "Marvell 88E6190X",
3808 .num_databases = 4096,
3809 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003810 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003811 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003812 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003813 .port_base_addr = 0x0,
3814 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003815 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003816 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003817 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003818 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003819 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003820 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003821 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003822 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003823 .ops = &mv88e6190x_ops,
3824 },
3825
3826 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003827 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003828 .family = MV88E6XXX_FAMILY_6390,
3829 .name = "Marvell 88E6191",
3830 .num_databases = 4096,
3831 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003832 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04003833 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003834 .port_base_addr = 0x0,
3835 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003836 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003837 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003838 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003839 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003840 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003841 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003842 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003843 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003844 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04003845 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003846 },
3847
Vivien Didelotf81ec902016-05-09 13:22:58 -04003848 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003849 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003850 .family = MV88E6XXX_FAMILY_6352,
3851 .name = "Marvell 88E6240",
3852 .num_databases = 4096,
3853 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003854 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003855 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003856 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003857 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003858 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003859 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003860 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003861 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003862 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003863 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003864 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003865 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003866 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003867 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003868 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003869 },
3870
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003871 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003872 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003873 .family = MV88E6XXX_FAMILY_6390,
3874 .name = "Marvell 88E6290",
3875 .num_databases = 4096,
3876 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003877 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003878 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04003879 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003880 .port_base_addr = 0x0,
3881 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003882 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01003883 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003884 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003885 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05003886 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04003887 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003888 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003889 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003890 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003891 .ops = &mv88e6290_ops,
3892 },
3893
Vivien Didelotf81ec902016-05-09 13:22:58 -04003894 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003895 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003896 .family = MV88E6XXX_FAMILY_6320,
3897 .name = "Marvell 88E6320",
3898 .num_databases = 4096,
3899 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003900 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003901 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003902 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003903 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003904 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003905 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003906 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003907 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003908 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003909 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003910 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003911 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003912 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003913 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003914 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003915 },
3916
3917 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003918 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003919 .family = MV88E6XXX_FAMILY_6320,
3920 .name = "Marvell 88E6321",
3921 .num_databases = 4096,
3922 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003923 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003924 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003925 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003926 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003927 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003928 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003929 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003930 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003931 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003932 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003933 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003934 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003935 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003936 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003937 },
3938
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003939 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003940 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003941 .family = MV88E6XXX_FAMILY_6341,
3942 .name = "Marvell 88E6341",
3943 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01003944 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003945 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003946 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003947 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003948 .port_base_addr = 0x10,
3949 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003950 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003951 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05003952 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003953 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003954 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003955 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003956 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003957 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003958 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01003959 .ops = &mv88e6341_ops,
3960 },
3961
Vivien Didelotf81ec902016-05-09 13:22:58 -04003962 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003963 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003964 .family = MV88E6XXX_FAMILY_6351,
3965 .name = "Marvell 88E6350",
3966 .num_databases = 4096,
3967 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003968 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003969 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003970 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003971 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003972 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003973 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003974 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003975 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003976 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003977 .pvt = true,
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,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003980 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003981 },
3982
3983 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003984 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003985 .family = MV88E6XXX_FAMILY_6351,
3986 .name = "Marvell 88E6351",
3987 .num_databases = 4096,
3988 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003989 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003990 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003991 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04003992 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003993 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003994 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003995 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003996 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003997 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003998 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003999 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004000 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004001 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004002 },
4003
4004 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004005 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004006 .family = MV88E6XXX_FAMILY_6352,
4007 .name = "Marvell 88E6352",
4008 .num_databases = 4096,
4009 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004010 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004011 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004012 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004013 .port_base_addr = 0x10,
Vivien Didelota935c052016-09-29 12:21:53 -04004014 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004015 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004016 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004017 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004018 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004019 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004020 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004021 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004022 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004023 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004024 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004025 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004026 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004027 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004028 .family = MV88E6XXX_FAMILY_6390,
4029 .name = "Marvell 88E6390",
4030 .num_databases = 4096,
4031 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004032 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004033 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004034 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004035 .port_base_addr = 0x0,
4036 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004037 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004038 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004039 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004040 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004041 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004042 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004043 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004044 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004045 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004046 .ops = &mv88e6390_ops,
4047 },
4048 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004049 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004050 .family = MV88E6XXX_FAMILY_6390,
4051 .name = "Marvell 88E6390X",
4052 .num_databases = 4096,
4053 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004054 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004055 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004056 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004057 .port_base_addr = 0x0,
4058 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004059 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004060 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004061 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004062 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004063 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004064 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004065 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004066 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004067 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004068 .ops = &mv88e6390x_ops,
4069 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004070};
4071
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004072static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004073{
Vivien Didelota439c062016-04-17 13:23:58 -04004074 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004075
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004076 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4077 if (mv88e6xxx_table[i].prod_num == prod_num)
4078 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004079
Vivien Didelotb9b37712015-10-30 19:39:48 -04004080 return NULL;
4081}
4082
Vivien Didelotfad09c72016-06-21 12:28:20 -04004083static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004084{
4085 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004086 unsigned int prod_num, rev;
4087 u16 id;
4088 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004089
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004090 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004091 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004092 mutex_unlock(&chip->reg_lock);
4093 if (err)
4094 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004095
Vivien Didelot107fcc12017-06-12 12:37:36 -04004096 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4097 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004098
4099 info = mv88e6xxx_lookup_info(prod_num);
4100 if (!info)
4101 return -ENODEV;
4102
Vivien Didelotcaac8542016-06-20 13:14:09 -04004103 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004104 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004105
Vivien Didelotca070c12016-09-02 14:45:34 -04004106 err = mv88e6xxx_g2_require(chip);
4107 if (err)
4108 return err;
4109
Vivien Didelotfad09c72016-06-21 12:28:20 -04004110 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4111 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004112
4113 return 0;
4114}
4115
Vivien Didelotfad09c72016-06-21 12:28:20 -04004116static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004117{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004118 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004119
Vivien Didelotfad09c72016-06-21 12:28:20 -04004120 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4121 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004122 return NULL;
4123
Vivien Didelotfad09c72016-06-21 12:28:20 -04004124 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004125
Vivien Didelotfad09c72016-06-21 12:28:20 -04004126 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004127 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004128
Vivien Didelotfad09c72016-06-21 12:28:20 -04004129 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004130}
4131
Vivien Didelotfad09c72016-06-21 12:28:20 -04004132static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004133 struct mii_bus *bus, int sw_addr)
4134{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004135 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004136 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004137 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004138 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004139 else
4140 return -EINVAL;
4141
Vivien Didelotfad09c72016-06-21 12:28:20 -04004142 chip->bus = bus;
4143 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004144
4145 return 0;
4146}
4147
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004148static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4149 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004150{
Vivien Didelot04bed142016-08-31 18:06:13 -04004151 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004152
Andrew Lunn443d5a12016-12-03 04:35:18 +01004153 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004154}
4155
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004156#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004157static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4158 struct device *host_dev, int sw_addr,
4159 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004160{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004161 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004162 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004163 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004164
Vivien Didelota439c062016-04-17 13:23:58 -04004165 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004166 if (!bus)
4167 return NULL;
4168
Vivien Didelotfad09c72016-06-21 12:28:20 -04004169 chip = mv88e6xxx_alloc_chip(dsa_dev);
4170 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004171 return NULL;
4172
Vivien Didelotcaac8542016-06-20 13:14:09 -04004173 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004174 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004175
Vivien Didelotfad09c72016-06-21 12:28:20 -04004176 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004177 if (err)
4178 goto free;
4179
Vivien Didelotfad09c72016-06-21 12:28:20 -04004180 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004181 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004182 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004183
Andrew Lunndc30c352016-10-16 19:56:49 +02004184 mutex_lock(&chip->reg_lock);
4185 err = mv88e6xxx_switch_reset(chip);
4186 mutex_unlock(&chip->reg_lock);
4187 if (err)
4188 goto free;
4189
Vivien Didelote57e5e72016-08-15 17:19:00 -04004190 mv88e6xxx_phy_init(chip);
4191
Andrew Lunna3c53be52017-01-24 14:53:50 +01004192 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004193 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004194 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004195
Vivien Didelotfad09c72016-06-21 12:28:20 -04004196 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004197
Vivien Didelotfad09c72016-06-21 12:28:20 -04004198 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004199free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004200 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004201
4202 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004203}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004204#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004205
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004206static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004207 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004208{
4209 /* We don't need any dynamic resource from the kernel (yet),
4210 * so skip the prepare phase.
4211 */
4212
4213 return 0;
4214}
4215
4216static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004217 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004218{
Vivien Didelot04bed142016-08-31 18:06:13 -04004219 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004220
4221 mutex_lock(&chip->reg_lock);
4222 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004223 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004224 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4225 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004226 mutex_unlock(&chip->reg_lock);
4227}
4228
4229static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4230 const struct switchdev_obj_port_mdb *mdb)
4231{
Vivien Didelot04bed142016-08-31 18:06:13 -04004232 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004233 int err;
4234
4235 mutex_lock(&chip->reg_lock);
4236 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004237 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004238 mutex_unlock(&chip->reg_lock);
4239
4240 return err;
4241}
4242
Florian Fainellia82f67a2017-01-08 14:52:08 -08004243static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004244#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004245 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004246#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004247 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004248 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004249 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004250 .phylink_validate = mv88e6xxx_validate,
4251 .phylink_mac_link_state = mv88e6xxx_link_state,
4252 .phylink_mac_config = mv88e6xxx_mac_config,
4253 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4254 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004255 .get_strings = mv88e6xxx_get_strings,
4256 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4257 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004258 .port_enable = mv88e6xxx_port_enable,
4259 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004260 .get_mac_eee = mv88e6xxx_get_mac_eee,
4261 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004262 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004263 .get_eeprom = mv88e6xxx_get_eeprom,
4264 .set_eeprom = mv88e6xxx_set_eeprom,
4265 .get_regs_len = mv88e6xxx_get_regs_len,
4266 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004267 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004268 .port_bridge_join = mv88e6xxx_port_bridge_join,
4269 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4270 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004271 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004272 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4273 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4274 .port_vlan_add = mv88e6xxx_port_vlan_add,
4275 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004276 .port_fdb_add = mv88e6xxx_port_fdb_add,
4277 .port_fdb_del = mv88e6xxx_port_fdb_del,
4278 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004279 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4280 .port_mdb_add = mv88e6xxx_port_mdb_add,
4281 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004282 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4283 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004284 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4285 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4286 .port_txtstamp = mv88e6xxx_port_txtstamp,
4287 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4288 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004289};
4290
Florian Fainelliab3d4082017-01-08 14:52:07 -08004291static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4292 .ops = &mv88e6xxx_switch_ops,
4293};
4294
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004295static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004296{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004297 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004298 struct dsa_switch *ds;
4299
Vivien Didelot73b12042017-03-30 17:37:10 -04004300 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004301 if (!ds)
4302 return -ENOMEM;
4303
Vivien Didelotfad09c72016-06-21 12:28:20 -04004304 ds->priv = chip;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004305 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004306 ds->ageing_time_min = chip->info->age_time_coeff;
4307 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004308
4309 dev_set_drvdata(dev, ds);
4310
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004311 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004312}
4313
Vivien Didelotfad09c72016-06-21 12:28:20 -04004314static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004315{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004316 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004317}
4318
Vivien Didelot57d32312016-06-20 13:13:58 -04004319static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004320{
4321 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004322 struct device_node *np = dev->of_node;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004323 const struct mv88e6xxx_info *compat_info;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004324 struct mv88e6xxx_chip *chip;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004325 u32 eeprom_len;
Andrew Lunn52638f72016-05-10 23:27:22 +02004326 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004327
Vivien Didelotcaac8542016-06-20 13:14:09 -04004328 compat_info = of_device_get_match_data(dev);
4329 if (!compat_info)
4330 return -EINVAL;
4331
Vivien Didelotfad09c72016-06-21 12:28:20 -04004332 chip = mv88e6xxx_alloc_chip(dev);
4333 if (!chip)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004334 return -ENOMEM;
4335
Vivien Didelotfad09c72016-06-21 12:28:20 -04004336 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004337
Vivien Didelotfad09c72016-06-21 12:28:20 -04004338 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004339 if (err)
4340 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004341
Andrew Lunnb4308f02016-11-21 23:26:55 +01004342 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
4343 if (IS_ERR(chip->reset))
4344 return PTR_ERR(chip->reset);
4345
Vivien Didelotfad09c72016-06-21 12:28:20 -04004346 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004347 if (err)
4348 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004349
Vivien Didelote57e5e72016-08-15 17:19:00 -04004350 mv88e6xxx_phy_init(chip);
4351
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004352 if (chip->info->ops->get_eeprom &&
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004353 !of_property_read_u32(np, "eeprom-length", &eeprom_len))
Vivien Didelotfad09c72016-06-21 12:28:20 -04004354 chip->eeprom_len = eeprom_len;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004355
Andrew Lunndc30c352016-10-16 19:56:49 +02004356 mutex_lock(&chip->reg_lock);
4357 err = mv88e6xxx_switch_reset(chip);
4358 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004359 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004360 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004361
Andrew Lunndc30c352016-10-16 19:56:49 +02004362 chip->irq = of_irq_get(np, 0);
4363 if (chip->irq == -EPROBE_DEFER) {
4364 err = chip->irq;
4365 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004366 }
4367
Andrew Lunn294d7112018-02-22 22:58:32 +01004368 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004369 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004370 * controllers
4371 */
4372 mutex_lock(&chip->reg_lock);
4373 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004374 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004375 else
4376 err = mv88e6xxx_irq_poll_setup(chip);
4377 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004378
Andrew Lunn294d7112018-02-22 22:58:32 +01004379 if (err)
4380 goto out;
4381
4382 if (chip->info->g2_irqs > 0) {
4383 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004384 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004385 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004386 }
4387
Andrew Lunn294d7112018-02-22 22:58:32 +01004388 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4389 if (err)
4390 goto out_g2_irq;
4391
4392 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4393 if (err)
4394 goto out_g1_atu_prob_irq;
4395
Andrew Lunna3c53be52017-01-24 14:53:50 +01004396 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004397 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004398 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004399
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004400 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004401 if (err)
4402 goto out_mdio;
4403
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004404 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004405
4406out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004407 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004408out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004409 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004410out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004411 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004412out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004413 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004414 mv88e6xxx_g2_irq_free(chip);
4415out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004416 mutex_lock(&chip->reg_lock);
4417 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004418 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004419 else
4420 mv88e6xxx_irq_poll_free(chip);
4421 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004422out:
4423 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004424}
4425
4426static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4427{
4428 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004429 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004430
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004431 if (chip->info->ptp_support) {
4432 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004433 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004434 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004435
Andrew Lunn930188c2016-08-22 16:01:03 +02004436 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004437 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004438 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004439
Andrew Lunn76f38f12018-03-17 20:21:09 +01004440 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4441 mv88e6xxx_g1_atu_prob_irq_free(chip);
4442
4443 if (chip->info->g2_irqs > 0)
4444 mv88e6xxx_g2_irq_free(chip);
4445
4446 mutex_lock(&chip->reg_lock);
4447 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004448 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004449 else
4450 mv88e6xxx_irq_poll_free(chip);
4451 mutex_unlock(&chip->reg_lock);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004452}
4453
4454static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004455 {
4456 .compatible = "marvell,mv88e6085",
4457 .data = &mv88e6xxx_table[MV88E6085],
4458 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004459 {
4460 .compatible = "marvell,mv88e6190",
4461 .data = &mv88e6xxx_table[MV88E6190],
4462 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004463 { /* sentinel */ },
4464};
4465
4466MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4467
4468static struct mdio_driver mv88e6xxx_driver = {
4469 .probe = mv88e6xxx_probe,
4470 .remove = mv88e6xxx_remove,
4471 .mdiodrv.driver = {
4472 .name = "mv88e6085",
4473 .of_match_table = mv88e6xxx_of_match,
4474 },
4475};
4476
Ben Hutchings98e67302011-11-25 14:36:19 +00004477static int __init mv88e6xxx_init(void)
4478{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004479 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004480 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004481}
4482module_init(mv88e6xxx_init);
4483
4484static void __exit mv88e6xxx_cleanup(void)
4485{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004486 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004487 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004488}
4489module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004490
4491MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4492MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4493MODULE_LICENSE("GPL");