blob: bfd5a7faef3b878338b414c8e1b0dc01f85e8b29 [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>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020031#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000032#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010033#include <linux/gpio/consumer.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000034#include <linux/phy.h>
Russell Kingc9a23562018-05-10 13:17:35 -070035#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000036#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040037
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040038#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040039#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040040#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010041#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020042#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010043#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010044#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020045#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000046
Vivien Didelotfad09c72016-06-21 12:28:20 -040047static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048{
Vivien Didelotfad09c72016-06-21 12:28:20 -040049 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
50 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040051 dump_stack();
52 }
53}
54
Vivien Didelot914b32f2016-06-20 13:14:11 -040055/* The switch ADDR[4:1] configuration pins define the chip SMI device address
56 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
57 *
58 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
59 * is the only device connected to the SMI master. In this mode it responds to
60 * all 32 possible SMI addresses, and thus maps directly the internal devices.
61 *
62 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
63 * multiple devices to share the SMI interface. In this mode it responds to only
64 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000065 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040066
Vivien Didelotfad09c72016-06-21 12:28:20 -040067static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040068 int addr, int reg, u16 *val)
69{
Vivien Didelotfad09c72016-06-21 12:28:20 -040070 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040071 return -EOPNOTSUPP;
72
Vivien Didelotfad09c72016-06-21 12:28:20 -040073 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040074}
75
Vivien Didelotfad09c72016-06-21 12:28:20 -040076static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040077 int addr, int reg, u16 val)
78{
Vivien Didelotfad09c72016-06-21 12:28:20 -040079 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040080 return -EOPNOTSUPP;
81
Vivien Didelotfad09c72016-06-21 12:28:20 -040082 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040083}
84
Vivien Didelotfad09c72016-06-21 12:28:20 -040085static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040086 int addr, int reg, u16 *val)
87{
88 int ret;
89
Vivien Didelotfad09c72016-06-21 12:28:20 -040090 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040091 if (ret < 0)
92 return ret;
93
94 *val = ret & 0xffff;
95
96 return 0;
97}
98
Vivien Didelotfad09c72016-06-21 12:28:20 -040099static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400100 int addr, int reg, u16 val)
101{
102 int ret;
103
Vivien Didelotfad09c72016-06-21 12:28:20 -0400104 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400105 if (ret < 0)
106 return ret;
107
108 return 0;
109}
110
Vivien Didelotc08026a2016-09-29 12:21:59 -0400111static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400112 .read = mv88e6xxx_smi_single_chip_read,
113 .write = mv88e6xxx_smi_single_chip_write,
114};
115
Vivien Didelotfad09c72016-06-21 12:28:20 -0400116static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000117{
118 int ret;
119 int i;
120
121 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400122 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000123 if (ret < 0)
124 return ret;
125
Andrew Lunncca8b132015-04-02 04:06:39 +0200126 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000127 return 0;
128 }
129
130 return -ETIMEDOUT;
131}
132
Vivien Didelotfad09c72016-06-21 12:28:20 -0400133static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400134 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000135{
136 int ret;
137
Barry Grussling3675c8d2013-01-08 16:05:53 +0000138 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400139 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000140 if (ret < 0)
141 return ret;
142
Barry Grussling3675c8d2013-01-08 16:05:53 +0000143 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400144 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200145 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000146 if (ret < 0)
147 return ret;
148
Barry Grussling3675c8d2013-01-08 16:05:53 +0000149 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400150 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000151 if (ret < 0)
152 return ret;
153
Barry Grussling3675c8d2013-01-08 16:05:53 +0000154 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400155 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000156 if (ret < 0)
157 return ret;
158
Vivien Didelot914b32f2016-06-20 13:14:11 -0400159 *val = ret & 0xffff;
160
161 return 0;
162}
163
Vivien Didelotfad09c72016-06-21 12:28:20 -0400164static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400165 int addr, int reg, u16 val)
166{
167 int ret;
168
169 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400170 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400171 if (ret < 0)
172 return ret;
173
174 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400175 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400176 if (ret < 0)
177 return ret;
178
179 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400180 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400181 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
182 if (ret < 0)
183 return ret;
184
185 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400186 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400187 if (ret < 0)
188 return ret;
189
190 return 0;
191}
192
Vivien Didelotc08026a2016-09-29 12:21:59 -0400193static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400194 .read = mv88e6xxx_smi_multi_chip_read,
195 .write = mv88e6xxx_smi_multi_chip_write,
196};
197
Vivien Didelotec561272016-09-02 14:45:33 -0400198int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400199{
200 int err;
201
Vivien Didelotfad09c72016-06-21 12:28:20 -0400202 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400203
Vivien Didelotfad09c72016-06-21 12:28:20 -0400204 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400205 if (err)
206 return err;
207
Vivien Didelotfad09c72016-06-21 12:28:20 -0400208 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400209 addr, reg, *val);
210
211 return 0;
212}
213
Vivien Didelotec561272016-09-02 14:45:33 -0400214int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400215{
216 int err;
217
Vivien Didelotfad09c72016-06-21 12:28:20 -0400218 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400219
Vivien Didelotfad09c72016-06-21 12:28:20 -0400220 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400221 if (err)
222 return err;
223
Vivien Didelotfad09c72016-06-21 12:28:20 -0400224 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400225 addr, reg, val);
226
227 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000228}
229
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200230struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100231{
232 struct mv88e6xxx_mdio_bus *mdio_bus;
233
234 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
235 list);
236 if (!mdio_bus)
237 return NULL;
238
239 return mdio_bus->bus;
240}
241
Andrew Lunndc30c352016-10-16 19:56:49 +0200242static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
243{
244 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
245 unsigned int n = d->hwirq;
246
247 chip->g1_irq.masked |= (1 << n);
248}
249
250static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
251{
252 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
253 unsigned int n = d->hwirq;
254
255 chip->g1_irq.masked &= ~(1 << n);
256}
257
Andrew Lunn294d7112018-02-22 22:58:32 +0100258static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200259{
Andrew Lunndc30c352016-10-16 19:56:49 +0200260 unsigned int nhandled = 0;
261 unsigned int sub_irq;
262 unsigned int n;
263 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500264 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200265 int err;
266
267 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400268 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200269 mutex_unlock(&chip->reg_lock);
270
271 if (err)
272 goto out;
273
John David Anglin7c0db242019-02-11 13:40:21 -0500274 do {
275 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
276 if (reg & (1 << n)) {
277 sub_irq = irq_find_mapping(chip->g1_irq.domain,
278 n);
279 handle_nested_irq(sub_irq);
280 ++nhandled;
281 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200282 }
John David Anglin7c0db242019-02-11 13:40:21 -0500283
284 mutex_lock(&chip->reg_lock);
285 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
286 if (err)
287 goto unlock;
288 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
289unlock:
290 mutex_unlock(&chip->reg_lock);
291 if (err)
292 goto out;
293 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
294 } while (reg & ctl1);
295
Andrew Lunndc30c352016-10-16 19:56:49 +0200296out:
297 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
298}
299
Andrew Lunn294d7112018-02-22 22:58:32 +0100300static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
301{
302 struct mv88e6xxx_chip *chip = dev_id;
303
304 return mv88e6xxx_g1_irq_thread_work(chip);
305}
306
Andrew Lunndc30c352016-10-16 19:56:49 +0200307static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
308{
309 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
310
311 mutex_lock(&chip->reg_lock);
312}
313
314static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
315{
316 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
317 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
318 u16 reg;
319 int err;
320
Vivien Didelotd77f4322017-06-15 12:14:03 -0400321 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200322 if (err)
323 goto out;
324
325 reg &= ~mask;
326 reg |= (~chip->g1_irq.masked & mask);
327
Vivien Didelotd77f4322017-06-15 12:14:03 -0400328 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200329 if (err)
330 goto out;
331
332out:
333 mutex_unlock(&chip->reg_lock);
334}
335
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530336static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200337 .name = "mv88e6xxx-g1",
338 .irq_mask = mv88e6xxx_g1_irq_mask,
339 .irq_unmask = mv88e6xxx_g1_irq_unmask,
340 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
341 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
342};
343
344static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
345 unsigned int irq,
346 irq_hw_number_t hwirq)
347{
348 struct mv88e6xxx_chip *chip = d->host_data;
349
350 irq_set_chip_data(irq, d->host_data);
351 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
352 irq_set_noprobe(irq);
353
354 return 0;
355}
356
357static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
358 .map = mv88e6xxx_g1_irq_domain_map,
359 .xlate = irq_domain_xlate_twocell,
360};
361
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200362/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100363static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200364{
365 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100366 u16 mask;
367
Vivien Didelotd77f4322017-06-15 12:14:03 -0400368 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100369 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400370 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100371
Andreas Färber5edef2f2016-11-27 23:26:28 +0100372 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100373 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200374 irq_dispose_mapping(virq);
375 }
376
Andrew Lunna3db3d32016-11-20 20:14:14 +0100377 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200378}
379
Andrew Lunn294d7112018-02-22 22:58:32 +0100380static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
381{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200382 /*
383 * free_irq must be called without reg_lock taken because the irq
384 * handler takes this lock, too.
385 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100386 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200387
388 mutex_lock(&chip->reg_lock);
389 mv88e6xxx_g1_irq_free_common(chip);
390 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100391}
392
393static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200394{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100395 int err, irq, virq;
396 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200397
398 chip->g1_irq.nirqs = chip->info->g1_irqs;
399 chip->g1_irq.domain = irq_domain_add_simple(
400 NULL, chip->g1_irq.nirqs, 0,
401 &mv88e6xxx_g1_irq_domain_ops, chip);
402 if (!chip->g1_irq.domain)
403 return -ENOMEM;
404
405 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
406 irq_create_mapping(chip->g1_irq.domain, irq);
407
408 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
409 chip->g1_irq.masked = ~0;
410
Vivien Didelotd77f4322017-06-15 12:14:03 -0400411 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200412 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100413 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200414
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100415 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200416
Vivien Didelotd77f4322017-06-15 12:14:03 -0400417 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200418 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100419 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200420
421 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400422 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200423 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100424 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200425
Andrew Lunndc30c352016-10-16 19:56:49 +0200426 return 0;
427
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100428out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100429 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400430 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100431
432out_mapping:
433 for (irq = 0; irq < 16; irq++) {
434 virq = irq_find_mapping(chip->g1_irq.domain, irq);
435 irq_dispose_mapping(virq);
436 }
437
438 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200439
440 return err;
441}
442
Andrew Lunn294d7112018-02-22 22:58:32 +0100443static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
444{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100445 static struct lock_class_key lock_key;
446 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100447 int err;
448
449 err = mv88e6xxx_g1_irq_setup_common(chip);
450 if (err)
451 return err;
452
Andrew Lunnf6d97582019-02-23 17:43:56 +0100453 /* These lock classes tells lockdep that global 1 irqs are in
454 * a different category than their parent GPIO, so it won't
455 * report false recursion.
456 */
457 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
458
Andrew Lunn342a0ee2019-02-23 17:43:57 +0100459 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100460 err = request_threaded_irq(chip->irq, NULL,
461 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200462 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100463 dev_name(chip->dev), chip);
Andrew Lunn342a0ee2019-02-23 17:43:57 +0100464 mutex_lock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100465 if (err)
466 mv88e6xxx_g1_irq_free_common(chip);
467
468 return err;
469}
470
471static void mv88e6xxx_irq_poll(struct kthread_work *work)
472{
473 struct mv88e6xxx_chip *chip = container_of(work,
474 struct mv88e6xxx_chip,
475 irq_poll_work.work);
476 mv88e6xxx_g1_irq_thread_work(chip);
477
478 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
479 msecs_to_jiffies(100));
480}
481
482static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
483{
484 int err;
485
486 err = mv88e6xxx_g1_irq_setup_common(chip);
487 if (err)
488 return err;
489
490 kthread_init_delayed_work(&chip->irq_poll_work,
491 mv88e6xxx_irq_poll);
492
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800493 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100494 if (IS_ERR(chip->kworker))
495 return PTR_ERR(chip->kworker);
496
497 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
498 msecs_to_jiffies(100));
499
500 return 0;
501}
502
503static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
504{
505 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
506 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200507
508 mutex_lock(&chip->reg_lock);
509 mv88e6xxx_g1_irq_free_common(chip);
510 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100511}
512
Vivien Didelotec561272016-09-02 14:45:33 -0400513int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400514{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200515 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400516
Andrew Lunn6441e6692016-08-19 00:01:55 +0200517 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400518 u16 val;
519 int err;
520
521 err = mv88e6xxx_read(chip, addr, reg, &val);
522 if (err)
523 return err;
524
525 if (!(val & mask))
526 return 0;
527
528 usleep_range(1000, 2000);
529 }
530
Andrew Lunn30853552016-08-19 00:01:57 +0200531 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400532 return -ETIMEDOUT;
533}
534
Vivien Didelotf22ab642016-07-18 20:45:31 -0400535/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400536int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400537{
538 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200539 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400540
541 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200542 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
543 if (err)
544 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400545
546 /* Set the Update bit to trigger a write operation */
547 val = BIT(15) | update;
548
549 return mv88e6xxx_write(chip, addr, reg, val);
550}
551
Heiner Kallweit72d8b4f2019-03-01 20:41:00 +0100552int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
553 int speed, int duplex, int pause,
554 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100555{
Andrew Lunna26deec2019-04-18 03:11:39 +0200556 struct phylink_link_state state;
Vivien Didelotd78343d2016-11-04 03:23:36 +0100557 int err;
558
559 if (!chip->info->ops->port_set_link)
560 return 0;
561
Andrew Lunna26deec2019-04-18 03:11:39 +0200562 if (!chip->info->ops->port_link_state)
563 return 0;
564
565 err = chip->info->ops->port_link_state(chip, port, &state);
566 if (err)
567 return err;
568
569 /* Has anything actually changed? We don't expect the
570 * interface mode to change without one of the other
571 * parameters also changing
572 */
573 if (state.link == link &&
574 state.speed == speed &&
575 state.duplex == duplex)
576 return 0;
577
Vivien Didelotd78343d2016-11-04 03:23:36 +0100578 /* Port's MAC control must not be changed unless the link is down */
579 err = chip->info->ops->port_set_link(chip, port, 0);
580 if (err)
581 return err;
582
583 if (chip->info->ops->port_set_speed) {
584 err = chip->info->ops->port_set_speed(chip, port, speed);
585 if (err && err != -EOPNOTSUPP)
586 goto restore_link;
587 }
588
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100589 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
590 mode = chip->info->ops->port_max_speed_mode(port);
591
Andrew Lunn54186b92018-08-09 15:38:37 +0200592 if (chip->info->ops->port_set_pause) {
593 err = chip->info->ops->port_set_pause(chip, port, pause);
594 if (err)
595 goto restore_link;
596 }
597
Vivien Didelotd78343d2016-11-04 03:23:36 +0100598 if (chip->info->ops->port_set_duplex) {
599 err = chip->info->ops->port_set_duplex(chip, port, duplex);
600 if (err && err != -EOPNOTSUPP)
601 goto restore_link;
602 }
603
604 if (chip->info->ops->port_set_rgmii_delay) {
605 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
606 if (err && err != -EOPNOTSUPP)
607 goto restore_link;
608 }
609
Andrew Lunnf39908d2017-02-04 20:02:50 +0100610 if (chip->info->ops->port_set_cmode) {
611 err = chip->info->ops->port_set_cmode(chip, port, mode);
612 if (err && err != -EOPNOTSUPP)
613 goto restore_link;
614 }
615
Vivien Didelotd78343d2016-11-04 03:23:36 +0100616 err = 0;
617restore_link:
618 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400619 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100620
621 return err;
622}
623
Marek Vasutd700ec42018-09-12 00:15:24 +0200624static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
625{
626 struct mv88e6xxx_chip *chip = ds->priv;
627
628 return port < chip->info->num_internal_phys;
629}
630
Andrew Lunndea87022015-08-31 15:56:47 +0200631/* We expect the switch to perform auto negotiation if there is a real
632 * phy. However, in the case of a fixed link phy, we force the port
633 * settings from the fixed link settings.
634 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400635static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
636 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200637{
Vivien Didelot04bed142016-08-31 18:06:13 -0400638 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200639 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200640
Marek Vasutd700ec42018-09-12 00:15:24 +0200641 if (!phy_is_pseudo_fixed_link(phydev) &&
642 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200643 return;
644
Vivien Didelotfad09c72016-06-21 12:28:20 -0400645 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100646 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200647 phydev->duplex, phydev->pause,
648 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400649 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100650
651 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400652 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200653}
654
Russell King6c422e32018-08-09 15:38:39 +0200655static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
656 unsigned long *mask,
657 struct phylink_link_state *state)
658{
659 if (!phy_interface_mode_is_8023z(state->interface)) {
660 /* 10M and 100M are only supported in non-802.3z mode */
661 phylink_set(mask, 10baseT_Half);
662 phylink_set(mask, 10baseT_Full);
663 phylink_set(mask, 100baseT_Half);
664 phylink_set(mask, 100baseT_Full);
665 }
666}
667
668static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
669 unsigned long *mask,
670 struct phylink_link_state *state)
671{
672 /* FIXME: if the port is in 1000Base-X mode, then it only supports
673 * 1000M FD speeds. In this case, CMODE will indicate 5.
674 */
675 phylink_set(mask, 1000baseT_Full);
676 phylink_set(mask, 1000baseX_Full);
677
678 mv88e6065_phylink_validate(chip, port, mask, state);
679}
680
Marek Behúne3af71a2019-02-25 12:39:55 +0100681static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
682 unsigned long *mask,
683 struct phylink_link_state *state)
684{
685 if (port >= 5)
686 phylink_set(mask, 2500baseX_Full);
687
688 /* No ethtool bits for 200Mbps */
689 phylink_set(mask, 1000baseT_Full);
690 phylink_set(mask, 1000baseX_Full);
691
692 mv88e6065_phylink_validate(chip, port, mask, state);
693}
694
Russell King6c422e32018-08-09 15:38:39 +0200695static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
696 unsigned long *mask,
697 struct phylink_link_state *state)
698{
699 /* No ethtool bits for 200Mbps */
700 phylink_set(mask, 1000baseT_Full);
701 phylink_set(mask, 1000baseX_Full);
702
703 mv88e6065_phylink_validate(chip, port, mask, state);
704}
705
706static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
707 unsigned long *mask,
708 struct phylink_link_state *state)
709{
Andrew Lunnec260162019-02-08 22:25:44 +0100710 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200711 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100712 phylink_set(mask, 2500baseT_Full);
713 }
Russell King6c422e32018-08-09 15:38:39 +0200714
715 /* No ethtool bits for 200Mbps */
716 phylink_set(mask, 1000baseT_Full);
717 phylink_set(mask, 1000baseX_Full);
718
719 mv88e6065_phylink_validate(chip, port, mask, state);
720}
721
722static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
723 unsigned long *mask,
724 struct phylink_link_state *state)
725{
726 if (port >= 9) {
727 phylink_set(mask, 10000baseT_Full);
728 phylink_set(mask, 10000baseKR_Full);
729 }
730
731 mv88e6390_phylink_validate(chip, port, mask, state);
732}
733
Russell Kingc9a23562018-05-10 13:17:35 -0700734static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
735 unsigned long *supported,
736 struct phylink_link_state *state)
737{
Russell King6c422e32018-08-09 15:38:39 +0200738 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
739 struct mv88e6xxx_chip *chip = ds->priv;
740
741 /* Allow all the expected bits */
742 phylink_set(mask, Autoneg);
743 phylink_set(mask, Pause);
744 phylink_set_port_modes(mask);
745
746 if (chip->info->ops->phylink_validate)
747 chip->info->ops->phylink_validate(chip, port, mask, state);
748
749 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
750 bitmap_and(state->advertising, state->advertising, mask,
751 __ETHTOOL_LINK_MODE_MASK_NBITS);
752
753 /* We can only operate at 2500BaseX or 1000BaseX. If requested
754 * to advertise both, only report advertising at 2500BaseX.
755 */
756 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700757}
758
759static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
760 struct phylink_link_state *state)
761{
762 struct mv88e6xxx_chip *chip = ds->priv;
763 int err;
764
765 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200766 if (chip->info->ops->port_link_state)
767 err = chip->info->ops->port_link_state(chip, port, state);
768 else
769 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700770 mutex_unlock(&chip->reg_lock);
771
772 return err;
773}
774
775static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
776 unsigned int mode,
777 const struct phylink_link_state *state)
778{
779 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200780 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700781
Marek Vasutd700ec42018-09-12 00:15:24 +0200782 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700783 return;
784
785 if (mode == MLO_AN_FIXED) {
786 link = LINK_FORCED_UP;
787 speed = state->speed;
788 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200789 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
790 link = state->link;
791 speed = state->speed;
792 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700793 } else {
794 speed = SPEED_UNFORCED;
795 duplex = DUPLEX_UNFORCED;
796 link = LINK_UNFORCED;
797 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200798 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700799
800 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200801 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700802 state->interface);
803 mutex_unlock(&chip->reg_lock);
804
805 if (err && err != -EOPNOTSUPP)
806 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
807}
808
809static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
810{
811 struct mv88e6xxx_chip *chip = ds->priv;
812 int err;
813
814 mutex_lock(&chip->reg_lock);
815 err = chip->info->ops->port_set_link(chip, port, link);
816 mutex_unlock(&chip->reg_lock);
817
818 if (err)
819 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
820}
821
822static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
823 unsigned int mode,
824 phy_interface_t interface)
825{
826 if (mode == MLO_AN_FIXED)
827 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
828}
829
830static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
831 unsigned int mode, phy_interface_t interface,
832 struct phy_device *phydev)
833{
834 if (mode == MLO_AN_FIXED)
835 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
836}
837
Andrew Lunna605a0f2016-11-21 23:26:58 +0100838static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000839{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100840 if (!chip->info->ops->stats_snapshot)
841 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000842
Andrew Lunna605a0f2016-11-21 23:26:58 +0100843 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000844}
845
Andrew Lunne413e7e2015-04-02 04:06:38 +0200846static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100847 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
848 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
849 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
850 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
851 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
852 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
853 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
854 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
855 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
856 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
857 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
858 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
859 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
860 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
861 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
862 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
863 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
864 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
865 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
866 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
867 { "single", 4, 0x14, STATS_TYPE_BANK0, },
868 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
869 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
870 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
871 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
872 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
873 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
874 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
875 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
876 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
877 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
878 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
879 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
880 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
881 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
882 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
883 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
884 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
885 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
886 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
887 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
888 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
889 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
890 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
891 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
892 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
893 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
894 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
895 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
896 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
897 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
898 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
899 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
900 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
901 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
902 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
903 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
904 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
905 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200906};
907
Vivien Didelotfad09c72016-06-21 12:28:20 -0400908static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100909 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100910 int port, u16 bank1_select,
911 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200912{
Andrew Lunn80c46272015-06-20 18:42:30 +0200913 u32 low;
914 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100915 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200916 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200917 u64 value;
918
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100919 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100920 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200921 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
922 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800923 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200924
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200925 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100926 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200927 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
928 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800929 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200930 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200931 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100932 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100933 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100934 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100935 /* fall through */
936 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100937 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100938 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100939 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100940 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500941 break;
942 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800943 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200944 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100945 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200946 return value;
947}
948
Andrew Lunn436fe172018-03-01 02:02:29 +0100949static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
950 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100951{
952 struct mv88e6xxx_hw_stat *stat;
953 int i, j;
954
955 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
956 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100957 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100958 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
959 ETH_GSTRING_LEN);
960 j++;
961 }
962 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100963
964 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100965}
966
Andrew Lunn436fe172018-03-01 02:02:29 +0100967static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
968 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100969{
Andrew Lunn436fe172018-03-01 02:02:29 +0100970 return mv88e6xxx_stats_get_strings(chip, data,
971 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100972}
973
Andrew Lunn436fe172018-03-01 02:02:29 +0100974static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
975 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100976{
Andrew Lunn436fe172018-03-01 02:02:29 +0100977 return mv88e6xxx_stats_get_strings(chip, data,
978 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100979}
980
Andrew Lunn65f60e42018-03-28 23:50:28 +0200981static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
982 "atu_member_violation",
983 "atu_miss_violation",
984 "atu_full_violation",
985 "vtu_member_violation",
986 "vtu_miss_violation",
987};
988
989static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
990{
991 unsigned int i;
992
993 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
994 strlcpy(data + i * ETH_GSTRING_LEN,
995 mv88e6xxx_atu_vtu_stats_strings[i],
996 ETH_GSTRING_LEN);
997}
998
Andrew Lunndfafe442016-11-21 23:27:02 +0100999static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -07001000 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001001{
Vivien Didelot04bed142016-08-31 18:06:13 -04001002 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001003 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001004
Florian Fainelli89f09042018-04-25 12:12:50 -07001005 if (stringset != ETH_SS_STATS)
1006 return;
1007
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001008 mutex_lock(&chip->reg_lock);
1009
Andrew Lunndfafe442016-11-21 23:27:02 +01001010 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +01001011 count = chip->info->ops->stats_get_strings(chip, data);
1012
1013 if (chip->info->ops->serdes_get_strings) {
1014 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001015 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001017
Andrew Lunn65f60e42018-03-28 23:50:28 +02001018 data += count * ETH_GSTRING_LEN;
1019 mv88e6xxx_atu_vtu_get_strings(data);
1020
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001021 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001022}
1023
1024static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
1025 int types)
1026{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001027 struct mv88e6xxx_hw_stat *stat;
1028 int i, j;
1029
1030 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1031 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +01001032 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001033 j++;
1034 }
1035 return j;
1036}
1037
Andrew Lunndfafe442016-11-21 23:27:02 +01001038static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1039{
1040 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1041 STATS_TYPE_PORT);
1042}
1043
1044static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1045{
1046 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1047 STATS_TYPE_BANK1);
1048}
1049
Florian Fainelli89f09042018-04-25 12:12:50 -07001050static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001051{
1052 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001053 int serdes_count = 0;
1054 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001055
Florian Fainelli89f09042018-04-25 12:12:50 -07001056 if (sset != ETH_SS_STATS)
1057 return 0;
1058
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001059 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001060 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001061 count = chip->info->ops->stats_get_sset_count(chip);
1062 if (count < 0)
1063 goto out;
1064
1065 if (chip->info->ops->serdes_get_sset_count)
1066 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1067 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001068 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001069 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001070 goto out;
1071 }
1072 count += serdes_count;
1073 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1074
Andrew Lunn436fe172018-03-01 02:02:29 +01001075out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001076 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001077
Andrew Lunn436fe172018-03-01 02:02:29 +01001078 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001079}
1080
Andrew Lunn436fe172018-03-01 02:02:29 +01001081static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1082 uint64_t *data, int types,
1083 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001084{
1085 struct mv88e6xxx_hw_stat *stat;
1086 int i, j;
1087
1088 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1089 stat = &mv88e6xxx_hw_stats[i];
1090 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001091 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001092 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1093 bank1_select,
1094 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001095 mutex_unlock(&chip->reg_lock);
1096
Andrew Lunn052f9472016-11-21 23:27:03 +01001097 j++;
1098 }
1099 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001100 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001101}
1102
Andrew Lunn436fe172018-03-01 02:02:29 +01001103static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1104 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001105{
1106 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001107 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001108 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001109}
1110
Andrew Lunn436fe172018-03-01 02:02:29 +01001111static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1112 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001113{
1114 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001115 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001116 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1117 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001118}
1119
Andrew Lunn436fe172018-03-01 02:02:29 +01001120static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1121 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001122{
1123 return mv88e6xxx_stats_get_stats(chip, port, data,
1124 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001125 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1126 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001127}
1128
Andrew Lunn65f60e42018-03-28 23:50:28 +02001129static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1130 uint64_t *data)
1131{
1132 *data++ = chip->ports[port].atu_member_violation;
1133 *data++ = chip->ports[port].atu_miss_violation;
1134 *data++ = chip->ports[port].atu_full_violation;
1135 *data++ = chip->ports[port].vtu_member_violation;
1136 *data++ = chip->ports[port].vtu_miss_violation;
1137}
1138
Andrew Lunn052f9472016-11-21 23:27:03 +01001139static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1140 uint64_t *data)
1141{
Andrew Lunn436fe172018-03-01 02:02:29 +01001142 int count = 0;
1143
Andrew Lunn052f9472016-11-21 23:27:03 +01001144 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001145 count = chip->info->ops->stats_get_stats(chip, port, data);
1146
Andrew Lunn65f60e42018-03-28 23:50:28 +02001147 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001148 if (chip->info->ops->serdes_get_stats) {
1149 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001150 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001151 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001152 data += count;
1153 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1154 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001155}
1156
Vivien Didelotf81ec902016-05-09 13:22:58 -04001157static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1158 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001159{
Vivien Didelot04bed142016-08-31 18:06:13 -04001160 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001161 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001162
Vivien Didelotfad09c72016-06-21 12:28:20 -04001163 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001164
Andrew Lunna605a0f2016-11-21 23:26:58 +01001165 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001166 mutex_unlock(&chip->reg_lock);
1167
1168 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001169 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001170
1171 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001172
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001173}
Ben Hutchings98e67302011-11-25 14:36:19 +00001174
Vivien Didelotf81ec902016-05-09 13:22:58 -04001175static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001176{
1177 return 32 * sizeof(u16);
1178}
1179
Vivien Didelotf81ec902016-05-09 13:22:58 -04001180static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1181 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001182{
Vivien Didelot04bed142016-08-31 18:06:13 -04001183 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001184 int err;
1185 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001186 u16 *p = _p;
1187 int i;
1188
Vivien Didelota5f39322018-12-17 16:05:21 -05001189 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001190
1191 memset(p, 0xff, 32 * sizeof(u16));
1192
Vivien Didelotfad09c72016-06-21 12:28:20 -04001193 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001194
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001195 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001196
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001197 err = mv88e6xxx_port_read(chip, port, i, &reg);
1198 if (!err)
1199 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001200 }
Vivien Didelot23062512016-05-09 13:22:45 -04001201
Vivien Didelotfad09c72016-06-21 12:28:20 -04001202 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001203}
1204
Vivien Didelot08f50062017-08-01 16:32:41 -04001205static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1206 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001207{
Vivien Didelot5480db62017-08-01 16:32:40 -04001208 /* Nothing to do on the port's MAC */
1209 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001210}
1211
Vivien Didelot08f50062017-08-01 16:32:41 -04001212static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1213 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001214{
Vivien Didelot5480db62017-08-01 16:32:40 -04001215 /* Nothing to do on the port's MAC */
1216 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001217}
1218
Vivien Didelote5887a22017-03-30 17:37:11 -04001219static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001220{
Vivien Didelote5887a22017-03-30 17:37:11 -04001221 struct dsa_switch *ds = NULL;
1222 struct net_device *br;
1223 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001224 int i;
1225
Vivien Didelote5887a22017-03-30 17:37:11 -04001226 if (dev < DSA_MAX_SWITCHES)
1227 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001228
Vivien Didelote5887a22017-03-30 17:37:11 -04001229 /* Prevent frames from unknown switch or port */
1230 if (!ds || port >= ds->num_ports)
1231 return 0;
1232
1233 /* Frames from DSA links and CPU ports can egress any local port */
1234 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1235 return mv88e6xxx_port_mask(chip);
1236
1237 br = ds->ports[port].bridge_dev;
1238 pvlan = 0;
1239
1240 /* Frames from user ports can egress any local DSA links and CPU ports,
1241 * as well as any local member of their bridge group.
1242 */
1243 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1244 if (dsa_is_cpu_port(chip->ds, i) ||
1245 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001246 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001247 pvlan |= BIT(i);
1248
1249 return pvlan;
1250}
1251
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001252static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001253{
1254 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001255
1256 /* prevent frames from going back out of the port they came in on */
1257 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001258
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001259 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001260}
1261
Vivien Didelotf81ec902016-05-09 13:22:58 -04001262static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1263 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001264{
Vivien Didelot04bed142016-08-31 18:06:13 -04001265 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001266 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001267
Vivien Didelotfad09c72016-06-21 12:28:20 -04001268 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001269 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001270 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001271
1272 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001273 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001274}
1275
Vivien Didelot93e18d62018-05-11 17:16:35 -04001276static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1277{
1278 int err;
1279
1280 if (chip->info->ops->ieee_pri_map) {
1281 err = chip->info->ops->ieee_pri_map(chip);
1282 if (err)
1283 return err;
1284 }
1285
1286 if (chip->info->ops->ip_pri_map) {
1287 err = chip->info->ops->ip_pri_map(chip);
1288 if (err)
1289 return err;
1290 }
1291
1292 return 0;
1293}
1294
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001295static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1296{
1297 int target, port;
1298 int err;
1299
1300 if (!chip->info->global2_addr)
1301 return 0;
1302
1303 /* Initialize the routing port to the 32 possible target devices */
1304 for (target = 0; target < 32; target++) {
1305 port = 0x1f;
1306 if (target < DSA_MAX_SWITCHES)
1307 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1308 port = chip->ds->rtable[target];
1309
1310 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1311 if (err)
1312 return err;
1313 }
1314
Vivien Didelot02317e62018-05-09 11:38:49 -04001315 if (chip->info->ops->set_cascade_port) {
1316 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1317 err = chip->info->ops->set_cascade_port(chip, port);
1318 if (err)
1319 return err;
1320 }
1321
Vivien Didelot23c98912018-05-09 11:38:50 -04001322 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1323 if (err)
1324 return err;
1325
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001326 return 0;
1327}
1328
Vivien Didelotb28f8722018-04-26 21:56:44 -04001329static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1330{
1331 /* Clear all trunk masks and mapping */
1332 if (chip->info->global2_addr)
1333 return mv88e6xxx_g2_trunk_clear(chip);
1334
1335 return 0;
1336}
1337
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001338static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1339{
1340 if (chip->info->ops->rmu_disable)
1341 return chip->info->ops->rmu_disable(chip);
1342
1343 return 0;
1344}
1345
Vivien Didelot9e907d72017-07-17 13:03:43 -04001346static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1347{
1348 if (chip->info->ops->pot_clear)
1349 return chip->info->ops->pot_clear(chip);
1350
1351 return 0;
1352}
1353
Vivien Didelot51c901a2017-07-17 13:03:41 -04001354static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1355{
1356 if (chip->info->ops->mgmt_rsvd2cpu)
1357 return chip->info->ops->mgmt_rsvd2cpu(chip);
1358
1359 return 0;
1360}
1361
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001362static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1363{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001364 int err;
1365
Vivien Didelotdaefc942017-03-11 16:12:54 -05001366 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1367 if (err)
1368 return err;
1369
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001370 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1371 if (err)
1372 return err;
1373
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001374 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1375}
1376
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001377static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1378{
1379 int port;
1380 int err;
1381
1382 if (!chip->info->ops->irl_init_all)
1383 return 0;
1384
1385 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1386 /* Disable ingress rate limiting by resetting all per port
1387 * ingress rate limit resources to their initial state.
1388 */
1389 err = chip->info->ops->irl_init_all(chip, port);
1390 if (err)
1391 return err;
1392 }
1393
1394 return 0;
1395}
1396
Vivien Didelot04a69a12017-10-13 14:18:05 -04001397static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1398{
1399 if (chip->info->ops->set_switch_mac) {
1400 u8 addr[ETH_ALEN];
1401
1402 eth_random_addr(addr);
1403
1404 return chip->info->ops->set_switch_mac(chip, addr);
1405 }
1406
1407 return 0;
1408}
1409
Vivien Didelot17a15942017-03-30 17:37:09 -04001410static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1411{
1412 u16 pvlan = 0;
1413
1414 if (!mv88e6xxx_has_pvt(chip))
1415 return -EOPNOTSUPP;
1416
1417 /* Skip the local source device, which uses in-chip port VLAN */
1418 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001419 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001420
1421 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1422}
1423
Vivien Didelot81228992017-03-30 17:37:08 -04001424static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1425{
Vivien Didelot17a15942017-03-30 17:37:09 -04001426 int dev, port;
1427 int err;
1428
Vivien Didelot81228992017-03-30 17:37:08 -04001429 if (!mv88e6xxx_has_pvt(chip))
1430 return 0;
1431
1432 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1433 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1434 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001435 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1436 if (err)
1437 return err;
1438
1439 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1440 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1441 err = mv88e6xxx_pvt_map(chip, dev, port);
1442 if (err)
1443 return err;
1444 }
1445 }
1446
1447 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001448}
1449
Vivien Didelot749efcb2016-09-22 16:49:24 -04001450static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1451{
1452 struct mv88e6xxx_chip *chip = ds->priv;
1453 int err;
1454
1455 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001456 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001457 mutex_unlock(&chip->reg_lock);
1458
1459 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001460 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001461}
1462
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001463static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1464{
1465 if (!chip->info->max_vid)
1466 return 0;
1467
1468 return mv88e6xxx_g1_vtu_flush(chip);
1469}
1470
Vivien Didelotf1394b782017-05-01 14:05:22 -04001471static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1472 struct mv88e6xxx_vtu_entry *entry)
1473{
1474 if (!chip->info->ops->vtu_getnext)
1475 return -EOPNOTSUPP;
1476
1477 return chip->info->ops->vtu_getnext(chip, entry);
1478}
1479
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001480static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1481 struct mv88e6xxx_vtu_entry *entry)
1482{
1483 if (!chip->info->ops->vtu_loadpurge)
1484 return -EOPNOTSUPP;
1485
1486 return chip->info->ops->vtu_loadpurge(chip, entry);
1487}
1488
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001489static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001490{
1491 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001492 struct mv88e6xxx_vtu_entry vlan = {
1493 .vid = chip->info->max_vid,
1494 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001495 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001496
1497 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1498
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001499 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001500 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001501 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001502 if (err)
1503 return err;
1504
1505 set_bit(*fid, fid_bitmap);
1506 }
1507
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001508 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001509 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001510 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001511 if (err)
1512 return err;
1513
1514 if (!vlan.valid)
1515 break;
1516
1517 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001518 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001519
1520 /* The reset value 0x000 is used to indicate that multiple address
1521 * databases are not needed. Return the next positive available.
1522 */
1523 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001524 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001525 return -ENOSPC;
1526
1527 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001528 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001529}
1530
Vivien Didelot567aa592017-05-01 14:05:25 -04001531static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1532 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001533{
1534 int err;
1535
1536 if (!vid)
1537 return -EINVAL;
1538
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001539 entry->vid = vid - 1;
1540 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001541
Vivien Didelotf1394b782017-05-01 14:05:22 -04001542 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001543 if (err)
1544 return err;
1545
Vivien Didelot567aa592017-05-01 14:05:25 -04001546 if (entry->vid == vid && entry->valid)
1547 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001548
Vivien Didelot567aa592017-05-01 14:05:25 -04001549 if (new) {
1550 int i;
1551
1552 /* Initialize a fresh VLAN entry */
1553 memset(entry, 0, sizeof(*entry));
1554 entry->valid = true;
1555 entry->vid = vid;
1556
Vivien Didelot553a7682017-06-07 18:12:16 -04001557 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001558 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001559 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001560 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001561
1562 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001563 }
1564
Vivien Didelot567aa592017-05-01 14:05:25 -04001565 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1566 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001567}
1568
Vivien Didelotda9c3592016-02-12 12:09:40 -05001569static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1570 u16 vid_begin, u16 vid_end)
1571{
Vivien Didelot04bed142016-08-31 18:06:13 -04001572 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001573 struct mv88e6xxx_vtu_entry vlan = {
1574 .vid = vid_begin - 1,
1575 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001576 int i, err;
1577
Andrew Lunndb06ae412017-09-25 23:32:20 +02001578 /* DSA and CPU ports have to be members of multiple vlans */
1579 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1580 return 0;
1581
Vivien Didelotda9c3592016-02-12 12:09:40 -05001582 if (!vid_begin)
1583 return -EOPNOTSUPP;
1584
Vivien Didelotfad09c72016-06-21 12:28:20 -04001585 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001586
Vivien Didelotda9c3592016-02-12 12:09:40 -05001587 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001588 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001589 if (err)
1590 goto unlock;
1591
1592 if (!vlan.valid)
1593 break;
1594
1595 if (vlan.vid > vid_end)
1596 break;
1597
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001598 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001599 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1600 continue;
1601
Andrew Lunncd886462017-11-09 22:29:53 +01001602 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001603 continue;
1604
Vivien Didelotbd00e052017-05-01 14:05:11 -04001605 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001606 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001607 continue;
1608
Vivien Didelotc8652c82017-10-16 11:12:19 -04001609 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001610 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001611 break; /* same bridge, check next VLAN */
1612
Vivien Didelotc8652c82017-10-16 11:12:19 -04001613 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001614 continue;
1615
Andrew Lunn743fcc22017-11-09 22:29:54 +01001616 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1617 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001618 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001619 err = -EOPNOTSUPP;
1620 goto unlock;
1621 }
1622 } while (vlan.vid < vid_end);
1623
1624unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001625 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001626
1627 return err;
1628}
1629
Vivien Didelotf81ec902016-05-09 13:22:58 -04001630static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1631 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001632{
Vivien Didelot04bed142016-08-31 18:06:13 -04001633 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001634 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1635 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001636 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001637
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001638 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001639 return -EOPNOTSUPP;
1640
Vivien Didelotfad09c72016-06-21 12:28:20 -04001641 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001642 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001643 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001644
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001645 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001646}
1647
Vivien Didelot57d32312016-06-20 13:13:58 -04001648static int
1649mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001650 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001651{
Vivien Didelot04bed142016-08-31 18:06:13 -04001652 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001653 int err;
1654
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001655 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001656 return -EOPNOTSUPP;
1657
Vivien Didelotda9c3592016-02-12 12:09:40 -05001658 /* If the requested port doesn't belong to the same bridge as the VLAN
1659 * members, do not support it (yet) and fallback to software VLAN.
1660 */
1661 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1662 vlan->vid_end);
1663 if (err)
1664 return err;
1665
Vivien Didelot76e398a2015-11-01 12:33:55 -05001666 /* We don't need any dynamic resource from the kernel (yet),
1667 * so skip the prepare phase.
1668 */
1669 return 0;
1670}
1671
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001672static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1673 const unsigned char *addr, u16 vid,
1674 u8 state)
1675{
1676 struct mv88e6xxx_vtu_entry vlan;
1677 struct mv88e6xxx_atu_entry entry;
1678 int err;
1679
1680 /* Null VLAN ID corresponds to the port private database */
1681 if (vid == 0)
1682 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1683 else
1684 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1685 if (err)
1686 return err;
1687
1688 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1689 ether_addr_copy(entry.mac, addr);
1690 eth_addr_dec(entry.mac);
1691
1692 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1693 if (err)
1694 return err;
1695
1696 /* Initialize a fresh ATU entry if it isn't found */
1697 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1698 !ether_addr_equal(entry.mac, addr)) {
1699 memset(&entry, 0, sizeof(entry));
1700 ether_addr_copy(entry.mac, addr);
1701 }
1702
1703 /* Purge the ATU entry only if no port is using it anymore */
1704 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1705 entry.portvec &= ~BIT(port);
1706 if (!entry.portvec)
1707 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1708 } else {
1709 entry.portvec |= BIT(port);
1710 entry.state = state;
1711 }
1712
1713 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1714}
1715
Andrew Lunn87fa8862017-11-09 22:29:56 +01001716static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1717 u16 vid)
1718{
1719 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1720 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1721
1722 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1723}
1724
1725static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1726{
1727 int port;
1728 int err;
1729
1730 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1731 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1732 if (err)
1733 return err;
1734 }
1735
1736 return 0;
1737}
1738
Vivien Didelotfad09c72016-06-21 12:28:20 -04001739static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001740 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001741{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001742 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001743 int err;
1744
Vivien Didelot567aa592017-05-01 14:05:25 -04001745 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001746 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001747 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001748
Vivien Didelotc91498e2017-06-07 18:12:13 -04001749 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001750
Andrew Lunn87fa8862017-11-09 22:29:56 +01001751 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1752 if (err)
1753 return err;
1754
1755 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001756}
1757
Vivien Didelotf81ec902016-05-09 13:22:58 -04001758static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001759 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001760{
Vivien Didelot04bed142016-08-31 18:06:13 -04001761 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001762 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1763 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001764 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001765 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001766
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001767 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001768 return;
1769
Vivien Didelotc91498e2017-06-07 18:12:13 -04001770 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001771 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001772 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001773 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001774 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001775 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001776
Vivien Didelotfad09c72016-06-21 12:28:20 -04001777 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001778
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001779 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001780 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001781 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1782 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001783
Vivien Didelot77064f32016-11-04 03:23:30 +01001784 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001785 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1786 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001787
Vivien Didelotfad09c72016-06-21 12:28:20 -04001788 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001789}
1790
Vivien Didelotfad09c72016-06-21 12:28:20 -04001791static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001792 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001793{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001794 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001795 int i, err;
1796
Vivien Didelot567aa592017-05-01 14:05:25 -04001797 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001798 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001799 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001800
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001801 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001802 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001803 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001804
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001805 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001806
1807 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001808 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001809 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001810 if (vlan.member[i] !=
1811 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001812 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001813 break;
1814 }
1815 }
1816
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001817 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001818 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001819 return err;
1820
Vivien Didelote606ca32017-03-11 16:12:55 -05001821 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001822}
1823
Vivien Didelotf81ec902016-05-09 13:22:58 -04001824static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1825 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001826{
Vivien Didelot04bed142016-08-31 18:06:13 -04001827 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001828 u16 pvid, vid;
1829 int err = 0;
1830
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001831 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001832 return -EOPNOTSUPP;
1833
Vivien Didelotfad09c72016-06-21 12:28:20 -04001834 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001835
Vivien Didelot77064f32016-11-04 03:23:30 +01001836 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001837 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001838 goto unlock;
1839
Vivien Didelot76e398a2015-11-01 12:33:55 -05001840 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001841 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001842 if (err)
1843 goto unlock;
1844
1845 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001846 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001847 if (err)
1848 goto unlock;
1849 }
1850 }
1851
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001852unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001853 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001854
1855 return err;
1856}
1857
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001858static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1859 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001860{
Vivien Didelot04bed142016-08-31 18:06:13 -04001861 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001862 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001863
Vivien Didelotfad09c72016-06-21 12:28:20 -04001864 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001865 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1866 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001867 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001868
1869 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001870}
1871
Vivien Didelotf81ec902016-05-09 13:22:58 -04001872static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001873 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001874{
Vivien Didelot04bed142016-08-31 18:06:13 -04001875 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001876 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001877
Vivien Didelotfad09c72016-06-21 12:28:20 -04001878 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001879 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001880 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001881 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001882
Vivien Didelot83dabd12016-08-31 11:50:04 -04001883 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001884}
1885
Vivien Didelot83dabd12016-08-31 11:50:04 -04001886static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1887 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001888 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001889{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001890 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001891 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001892 int err;
1893
Vivien Didelot27c0e602017-06-15 12:14:01 -04001894 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001895 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001896
1897 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001898 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001899 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001900 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001901 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001902 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001903
Vivien Didelot27c0e602017-06-15 12:14:01 -04001904 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001905 break;
1906
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001907 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001908 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001909
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001910 if (!is_unicast_ether_addr(addr.mac))
1911 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001912
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001913 is_static = (addr.state ==
1914 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1915 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001916 if (err)
1917 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001918 } while (!is_broadcast_ether_addr(addr.mac));
1919
1920 return err;
1921}
1922
Vivien Didelot83dabd12016-08-31 11:50:04 -04001923static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001924 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001925{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001926 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001927 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001928 };
1929 u16 fid;
1930 int err;
1931
1932 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001933 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001934 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001935 mutex_unlock(&chip->reg_lock);
1936
Vivien Didelot83dabd12016-08-31 11:50:04 -04001937 if (err)
1938 return err;
1939
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001940 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001941 if (err)
1942 return err;
1943
1944 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001945 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001946 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001947 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001948 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001949 if (err)
1950 return err;
1951
1952 if (!vlan.valid)
1953 break;
1954
1955 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001956 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001957 if (err)
1958 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001959 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001960
1961 return err;
1962}
1963
Vivien Didelotf81ec902016-05-09 13:22:58 -04001964static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001965 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001966{
Vivien Didelot04bed142016-08-31 18:06:13 -04001967 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001968
Andrew Lunna61e5402018-02-15 14:38:35 +01001969 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001970}
1971
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001972static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1973 struct net_device *br)
1974{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001975 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001976 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001977 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001978 int err;
1979
1980 /* Remap the Port VLAN of each local bridge group member */
1981 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1982 if (chip->ds->ports[port].bridge_dev == br) {
1983 err = mv88e6xxx_port_vlan_map(chip, port);
1984 if (err)
1985 return err;
1986 }
1987 }
1988
Vivien Didelote96a6e02017-03-30 17:37:13 -04001989 if (!mv88e6xxx_has_pvt(chip))
1990 return 0;
1991
1992 /* Remap the Port VLAN of each cross-chip bridge group member */
1993 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1994 ds = chip->ds->dst->ds[dev];
1995 if (!ds)
1996 break;
1997
1998 for (port = 0; port < ds->num_ports; ++port) {
1999 if (ds->ports[port].bridge_dev == br) {
2000 err = mv88e6xxx_pvt_map(chip, dev, port);
2001 if (err)
2002 return err;
2003 }
2004 }
2005 }
2006
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002007 return 0;
2008}
2009
Vivien Didelotf81ec902016-05-09 13:22:58 -04002010static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002011 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002012{
Vivien Didelot04bed142016-08-31 18:06:13 -04002013 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002014 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002015
Vivien Didelotfad09c72016-06-21 12:28:20 -04002016 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002017 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002018 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05002019
Vivien Didelot466dfa02016-02-26 13:16:05 -05002020 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002021}
2022
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002023static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2024 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002025{
Vivien Didelot04bed142016-08-31 18:06:13 -04002026 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002027
Vivien Didelotfad09c72016-06-21 12:28:20 -04002028 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002029 if (mv88e6xxx_bridge_map(chip, br) ||
2030 mv88e6xxx_port_vlan_map(chip, port))
2031 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04002032 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002033}
2034
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002035static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2036 int port, struct net_device *br)
2037{
2038 struct mv88e6xxx_chip *chip = ds->priv;
2039 int err;
2040
2041 if (!mv88e6xxx_has_pvt(chip))
2042 return 0;
2043
2044 mutex_lock(&chip->reg_lock);
2045 err = mv88e6xxx_pvt_map(chip, dev, port);
2046 mutex_unlock(&chip->reg_lock);
2047
2048 return err;
2049}
2050
2051static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2052 int port, struct net_device *br)
2053{
2054 struct mv88e6xxx_chip *chip = ds->priv;
2055
2056 if (!mv88e6xxx_has_pvt(chip))
2057 return;
2058
2059 mutex_lock(&chip->reg_lock);
2060 if (mv88e6xxx_pvt_map(chip, dev, port))
2061 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2062 mutex_unlock(&chip->reg_lock);
2063}
2064
Vivien Didelot17e708b2016-12-05 17:30:27 -05002065static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2066{
2067 if (chip->info->ops->reset)
2068 return chip->info->ops->reset(chip);
2069
2070 return 0;
2071}
2072
Vivien Didelot309eca62016-12-05 17:30:26 -05002073static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2074{
2075 struct gpio_desc *gpiod = chip->reset;
2076
2077 /* If there is a GPIO connected to the reset pin, toggle it */
2078 if (gpiod) {
2079 gpiod_set_value_cansleep(gpiod, 1);
2080 usleep_range(10000, 20000);
2081 gpiod_set_value_cansleep(gpiod, 0);
2082 usleep_range(10000, 20000);
2083 }
2084}
2085
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002086static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2087{
2088 int i, err;
2089
2090 /* Set all ports to the Disabled state */
2091 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002092 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002093 if (err)
2094 return err;
2095 }
2096
2097 /* Wait for transmit queues to drain,
2098 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2099 */
2100 usleep_range(2000, 4000);
2101
2102 return 0;
2103}
2104
Vivien Didelotfad09c72016-06-21 12:28:20 -04002105static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002106{
Vivien Didelota935c052016-09-29 12:21:53 -04002107 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002108
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002109 err = mv88e6xxx_disable_ports(chip);
2110 if (err)
2111 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002112
Vivien Didelot309eca62016-12-05 17:30:26 -05002113 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002114
Vivien Didelot17e708b2016-12-05 17:30:27 -05002115 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002116}
2117
Vivien Didelot43145572017-03-11 16:12:59 -05002118static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002119 enum mv88e6xxx_frame_mode frame,
2120 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002121{
2122 int err;
2123
Vivien Didelot43145572017-03-11 16:12:59 -05002124 if (!chip->info->ops->port_set_frame_mode)
2125 return -EOPNOTSUPP;
2126
2127 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002128 if (err)
2129 return err;
2130
Vivien Didelot43145572017-03-11 16:12:59 -05002131 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2132 if (err)
2133 return err;
2134
2135 if (chip->info->ops->port_set_ether_type)
2136 return chip->info->ops->port_set_ether_type(chip, port, etype);
2137
2138 return 0;
2139}
2140
2141static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2142{
2143 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002144 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002145 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002146}
2147
2148static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2149{
2150 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002151 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002152 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002153}
2154
2155static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2156{
2157 return mv88e6xxx_set_port_mode(chip, port,
2158 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002159 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2160 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002161}
2162
2163static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2164{
2165 if (dsa_is_dsa_port(chip->ds, port))
2166 return mv88e6xxx_set_port_mode_dsa(chip, port);
2167
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002168 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002169 return mv88e6xxx_set_port_mode_normal(chip, port);
2170
2171 /* Setup CPU port mode depending on its supported tag format */
2172 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2173 return mv88e6xxx_set_port_mode_dsa(chip, port);
2174
2175 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2176 return mv88e6xxx_set_port_mode_edsa(chip, port);
2177
2178 return -EINVAL;
2179}
2180
Vivien Didelotea698f42017-03-11 16:12:50 -05002181static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2182{
2183 bool message = dsa_is_dsa_port(chip->ds, port);
2184
2185 return mv88e6xxx_port_set_message_port(chip, port, message);
2186}
2187
Vivien Didelot601aeed2017-03-11 16:13:00 -05002188static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2189{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002190 struct dsa_switch *ds = chip->ds;
2191 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002192
2193 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002194 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002195 if (chip->info->ops->port_set_egress_floods)
2196 return chip->info->ops->port_set_egress_floods(chip, port,
2197 flood, flood);
2198
2199 return 0;
2200}
2201
Andrew Lunn6d917822017-05-26 01:03:21 +02002202static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2203 bool on)
2204{
Vivien Didelot523a8902017-05-26 18:02:42 -04002205 if (chip->info->ops->serdes_power)
2206 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002207
Vivien Didelot523a8902017-05-26 18:02:42 -04002208 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002209}
2210
Vivien Didelotfa371c82017-12-05 15:34:10 -05002211static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2212{
2213 struct dsa_switch *ds = chip->ds;
2214 int upstream_port;
2215 int err;
2216
Vivien Didelot07073c72017-12-05 15:34:13 -05002217 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002218 if (chip->info->ops->port_set_upstream_port) {
2219 err = chip->info->ops->port_set_upstream_port(chip, port,
2220 upstream_port);
2221 if (err)
2222 return err;
2223 }
2224
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002225 if (port == upstream_port) {
2226 if (chip->info->ops->set_cpu_port) {
2227 err = chip->info->ops->set_cpu_port(chip,
2228 upstream_port);
2229 if (err)
2230 return err;
2231 }
2232
2233 if (chip->info->ops->set_egress_port) {
2234 err = chip->info->ops->set_egress_port(chip,
2235 upstream_port);
2236 if (err)
2237 return err;
2238 }
2239 }
2240
Vivien Didelotfa371c82017-12-05 15:34:10 -05002241 return 0;
2242}
2243
Vivien Didelotfad09c72016-06-21 12:28:20 -04002244static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002245{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002246 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002247 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002248 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002249
Andrew Lunn7b898462018-08-09 15:38:47 +02002250 chip->ports[port].chip = chip;
2251 chip->ports[port].port = port;
2252
Vivien Didelotd78343d2016-11-04 03:23:36 +01002253 /* MAC Forcing register: don't force link, speed, duplex or flow control
2254 * state to any particular values on physical ports, but force the CPU
2255 * port and all DSA ports to their maximum bandwidth and full duplex.
2256 */
2257 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2258 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2259 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002260 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002261 PHY_INTERFACE_MODE_NA);
2262 else
2263 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2264 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002265 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002266 PHY_INTERFACE_MODE_NA);
2267 if (err)
2268 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002269
2270 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2271 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2272 * tunneling, determine priority by looking at 802.1p and IP
2273 * priority fields (IP prio has precedence), and set STP state
2274 * to Forwarding.
2275 *
2276 * If this is the CPU link, use DSA or EDSA tagging depending
2277 * on which tagging mode was configured.
2278 *
2279 * If this is a link to another switch, use DSA tagging mode.
2280 *
2281 * If this is the upstream port for this switch, enable
2282 * forwarding of unknown unicasts and multicasts.
2283 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002284 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2285 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2286 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2287 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002288 if (err)
2289 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002290
Vivien Didelot601aeed2017-03-11 16:13:00 -05002291 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002292 if (err)
2293 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002294
Vivien Didelot601aeed2017-03-11 16:13:00 -05002295 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002296 if (err)
2297 return err;
2298
Andrew Lunn04aca992017-05-26 01:03:24 +02002299 /* Enable the SERDES interface for DSA and CPU ports. Normal
2300 * ports SERDES are enabled when the port is enabled, thus
2301 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002302 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002303 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2304 err = mv88e6xxx_serdes_power(chip, port, true);
2305 if (err)
2306 return err;
2307 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002308
Vivien Didelot8efdda42015-08-13 12:52:23 -04002309 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002310 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002311 * untagged frames on this port, do a destination address lookup on all
2312 * received packets as usual, disable ARP mirroring and don't send a
2313 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002314 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002315 err = mv88e6xxx_port_set_map_da(chip, port);
2316 if (err)
2317 return err;
2318
Vivien Didelotfa371c82017-12-05 15:34:10 -05002319 err = mv88e6xxx_setup_upstream_port(chip, port);
2320 if (err)
2321 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002322
Andrew Lunna23b2962017-02-04 20:15:28 +01002323 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002324 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002325 if (err)
2326 return err;
2327
Vivien Didelotcd782652017-06-08 18:34:13 -04002328 if (chip->info->ops->port_set_jumbo_size) {
2329 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002330 if (err)
2331 return err;
2332 }
2333
Andrew Lunn54d792f2015-05-06 01:09:47 +02002334 /* Port Association Vector: when learning source addresses
2335 * of packets, add the address to the address database using
2336 * a port bitmap that has only the bit for this port set and
2337 * the other bits clear.
2338 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002339 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002340 /* Disable learning for CPU port */
2341 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002342 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002343
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002344 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2345 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002346 if (err)
2347 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002348
2349 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002350 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2351 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002352 if (err)
2353 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002354
Vivien Didelot08984322017-06-08 18:34:12 -04002355 if (chip->info->ops->port_pause_limit) {
2356 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002357 if (err)
2358 return err;
2359 }
2360
Vivien Didelotc8c94892017-03-11 16:13:01 -05002361 if (chip->info->ops->port_disable_learn_limit) {
2362 err = chip->info->ops->port_disable_learn_limit(chip, port);
2363 if (err)
2364 return err;
2365 }
2366
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002367 if (chip->info->ops->port_disable_pri_override) {
2368 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002369 if (err)
2370 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002371 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002372
Andrew Lunnef0a7312016-12-03 04:35:16 +01002373 if (chip->info->ops->port_tag_remap) {
2374 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002375 if (err)
2376 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002377 }
2378
Andrew Lunnef70b112016-12-03 04:45:18 +01002379 if (chip->info->ops->port_egress_rate_limiting) {
2380 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002381 if (err)
2382 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002383 }
2384
Vivien Didelotea698f42017-03-11 16:12:50 -05002385 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002386 if (err)
2387 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002388
Vivien Didelot207afda2016-04-14 14:42:09 -04002389 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002390 * database, and allow bidirectional communication between the
2391 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002392 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002393 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002394 if (err)
2395 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002396
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002397 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002398 if (err)
2399 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002400
2401 /* Default VLAN ID and priority: don't set a default VLAN
2402 * ID, and set the default packet priority to zero.
2403 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002404 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002405}
2406
Andrew Lunn04aca992017-05-26 01:03:24 +02002407static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2408 struct phy_device *phydev)
2409{
2410 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002411 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002412
2413 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002414
Vivien Didelot523a8902017-05-26 18:02:42 -04002415 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002416
2417 if (!err && chip->info->ops->serdes_irq_setup)
2418 err = chip->info->ops->serdes_irq_setup(chip, port);
2419
Andrew Lunn04aca992017-05-26 01:03:24 +02002420 mutex_unlock(&chip->reg_lock);
2421
2422 return err;
2423}
2424
Andrew Lunn75104db2019-02-24 20:44:43 +01002425static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002426{
2427 struct mv88e6xxx_chip *chip = ds->priv;
2428
2429 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002430
2431 if (chip->info->ops->serdes_irq_free)
2432 chip->info->ops->serdes_irq_free(chip, port);
2433
Vivien Didelot523a8902017-05-26 18:02:42 -04002434 if (mv88e6xxx_serdes_power(chip, port, false))
2435 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002436
Andrew Lunn04aca992017-05-26 01:03:24 +02002437 mutex_unlock(&chip->reg_lock);
2438}
2439
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002440static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2441 unsigned int ageing_time)
2442{
Vivien Didelot04bed142016-08-31 18:06:13 -04002443 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002444 int err;
2445
2446 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002447 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002448 mutex_unlock(&chip->reg_lock);
2449
2450 return err;
2451}
2452
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002453static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002454{
2455 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002456
Andrew Lunnde2273872016-11-21 23:27:01 +01002457 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002458 if (chip->info->ops->stats_set_histogram) {
2459 err = chip->info->ops->stats_set_histogram(chip);
2460 if (err)
2461 return err;
2462 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002463
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002464 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002465}
2466
Andrew Lunnea890982019-01-09 00:24:03 +01002467/* The mv88e6390 has some hidden registers used for debug and
2468 * development. The errata also makes use of them.
2469 */
2470static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2471 int reg, u16 val)
2472{
2473 u16 ctrl;
2474 int err;
2475
2476 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2477 PORT_RESERVED_1A, val);
2478 if (err)
2479 return err;
2480
2481 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2482 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2483 reg;
2484
2485 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2486 PORT_RESERVED_1A, ctrl);
2487}
2488
2489static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2490{
2491 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2492 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2493}
2494
2495
2496static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2497 int reg, u16 *val)
2498{
2499 u16 ctrl;
2500 int err;
2501
2502 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2503 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2504 reg;
2505
2506 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2507 PORT_RESERVED_1A, ctrl);
2508 if (err)
2509 return err;
2510
2511 err = mv88e6390_hidden_wait(chip);
2512 if (err)
2513 return err;
2514
2515 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2516 PORT_RESERVED_1A, val);
2517}
2518
2519/* Check if the errata has already been applied. */
2520static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2521{
2522 int port;
2523 int err;
2524 u16 val;
2525
2526 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2527 err = mv88e6390_hidden_read(chip, port, 0, &val);
2528 if (err) {
2529 dev_err(chip->dev,
2530 "Error reading hidden register: %d\n", err);
2531 return false;
2532 }
2533 if (val != 0x01c0)
2534 return false;
2535 }
2536
2537 return true;
2538}
2539
2540/* The 6390 copper ports have an errata which require poking magic
2541 * values into undocumented hidden registers and then performing a
2542 * software reset.
2543 */
2544static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2545{
2546 int port;
2547 int err;
2548
2549 if (mv88e6390_setup_errata_applied(chip))
2550 return 0;
2551
2552 /* Set the ports into blocking mode */
2553 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2554 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2555 if (err)
2556 return err;
2557 }
2558
2559 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2560 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2561 if (err)
2562 return err;
2563 }
2564
2565 return mv88e6xxx_software_reset(chip);
2566}
2567
Vivien Didelotf81ec902016-05-09 13:22:58 -04002568static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002569{
Vivien Didelot04bed142016-08-31 18:06:13 -04002570 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002571 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002572 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002573 int i;
2574
Vivien Didelotfad09c72016-06-21 12:28:20 -04002575 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002576 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002577
Vivien Didelotfad09c72016-06-21 12:28:20 -04002578 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002579
Andrew Lunnea890982019-01-09 00:24:03 +01002580 if (chip->info->ops->setup_errata) {
2581 err = chip->info->ops->setup_errata(chip);
2582 if (err)
2583 goto unlock;
2584 }
2585
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002586 /* Cache the cmode of each port. */
2587 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2588 if (chip->info->ops->port_get_cmode) {
2589 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2590 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002591 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002592
2593 chip->ports[i].cmode = cmode;
2594 }
2595 }
2596
Vivien Didelot97299342016-07-18 20:45:30 -04002597 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002598 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002599 if (dsa_is_unused_port(ds, i))
2600 continue;
2601
Vivien Didelot97299342016-07-18 20:45:30 -04002602 err = mv88e6xxx_setup_port(chip, i);
2603 if (err)
2604 goto unlock;
2605 }
2606
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002607 err = mv88e6xxx_irl_setup(chip);
2608 if (err)
2609 goto unlock;
2610
Vivien Didelot04a69a12017-10-13 14:18:05 -04002611 err = mv88e6xxx_mac_setup(chip);
2612 if (err)
2613 goto unlock;
2614
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002615 err = mv88e6xxx_phy_setup(chip);
2616 if (err)
2617 goto unlock;
2618
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002619 err = mv88e6xxx_vtu_setup(chip);
2620 if (err)
2621 goto unlock;
2622
Vivien Didelot81228992017-03-30 17:37:08 -04002623 err = mv88e6xxx_pvt_setup(chip);
2624 if (err)
2625 goto unlock;
2626
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002627 err = mv88e6xxx_atu_setup(chip);
2628 if (err)
2629 goto unlock;
2630
Andrew Lunn87fa8862017-11-09 22:29:56 +01002631 err = mv88e6xxx_broadcast_setup(chip, 0);
2632 if (err)
2633 goto unlock;
2634
Vivien Didelot9e907d72017-07-17 13:03:43 -04002635 err = mv88e6xxx_pot_setup(chip);
2636 if (err)
2637 goto unlock;
2638
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002639 err = mv88e6xxx_rmu_setup(chip);
2640 if (err)
2641 goto unlock;
2642
Vivien Didelot51c901a2017-07-17 13:03:41 -04002643 err = mv88e6xxx_rsvd2cpu_setup(chip);
2644 if (err)
2645 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002646
Vivien Didelotb28f8722018-04-26 21:56:44 -04002647 err = mv88e6xxx_trunk_setup(chip);
2648 if (err)
2649 goto unlock;
2650
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002651 err = mv88e6xxx_devmap_setup(chip);
2652 if (err)
2653 goto unlock;
2654
Vivien Didelot93e18d62018-05-11 17:16:35 -04002655 err = mv88e6xxx_pri_setup(chip);
2656 if (err)
2657 goto unlock;
2658
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002659 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002660 if (chip->info->ptp_support) {
2661 err = mv88e6xxx_ptp_setup(chip);
2662 if (err)
2663 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002664
2665 err = mv88e6xxx_hwtstamp_setup(chip);
2666 if (err)
2667 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002668 }
2669
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002670 err = mv88e6xxx_stats_setup(chip);
2671 if (err)
2672 goto unlock;
2673
Vivien Didelot6b17e862015-08-13 12:52:18 -04002674unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002675 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002676
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002677 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002678}
2679
Vivien Didelote57e5e72016-08-15 17:19:00 -04002680static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002681{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002682 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2683 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002684 u16 val;
2685 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002686
Andrew Lunnee26a222017-01-24 14:53:48 +01002687 if (!chip->info->ops->phy_read)
2688 return -EOPNOTSUPP;
2689
Vivien Didelotfad09c72016-06-21 12:28:20 -04002690 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002691 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002692 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002693
Andrew Lunnda9f3302017-02-01 03:40:05 +01002694 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002695 /* Some internal PHYs don't have a model number. */
2696 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2697 /* Then there is the 6165 family. It gets is
2698 * PHYs correct. But it can also have two
2699 * SERDES interfaces in the PHY address
2700 * space. And these don't have a model
2701 * number. But they are not PHYs, so we don't
2702 * want to give them something a PHY driver
2703 * will recognise.
2704 *
2705 * Use the mv88e6390 family model number
2706 * instead, for anything which really could be
2707 * a PHY,
2708 */
2709 if (!(val & 0x3f0))
2710 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002711 }
2712
Vivien Didelote57e5e72016-08-15 17:19:00 -04002713 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002714}
2715
Vivien Didelote57e5e72016-08-15 17:19:00 -04002716static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002717{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002718 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2719 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002720 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002721
Andrew Lunnee26a222017-01-24 14:53:48 +01002722 if (!chip->info->ops->phy_write)
2723 return -EOPNOTSUPP;
2724
Vivien Didelotfad09c72016-06-21 12:28:20 -04002725 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002726 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002727 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002728
2729 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002730}
2731
Vivien Didelotfad09c72016-06-21 12:28:20 -04002732static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002733 struct device_node *np,
2734 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002735{
2736 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002737 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002738 struct mii_bus *bus;
2739 int err;
2740
Andrew Lunn2510bab2018-02-22 01:51:49 +01002741 if (external) {
2742 mutex_lock(&chip->reg_lock);
2743 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2744 mutex_unlock(&chip->reg_lock);
2745
2746 if (err)
2747 return err;
2748 }
2749
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002750 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002751 if (!bus)
2752 return -ENOMEM;
2753
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002754 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002755 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002756 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002757 INIT_LIST_HEAD(&mdio_bus->list);
2758 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002759
Andrew Lunnb516d452016-06-04 21:17:06 +02002760 if (np) {
2761 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002762 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002763 } else {
2764 bus->name = "mv88e6xxx SMI";
2765 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2766 }
2767
2768 bus->read = mv88e6xxx_mdio_read;
2769 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002770 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002771
Andrew Lunn6f882842018-03-17 20:32:05 +01002772 if (!external) {
2773 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2774 if (err)
2775 return err;
2776 }
2777
Florian Fainelli00e798c2018-05-15 16:56:19 -07002778 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002779 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002780 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002781 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002782 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002783 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002784
2785 if (external)
2786 list_add_tail(&mdio_bus->list, &chip->mdios);
2787 else
2788 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002789
2790 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002791}
2792
Andrew Lunna3c53be52017-01-24 14:53:50 +01002793static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2794 { .compatible = "marvell,mv88e6xxx-mdio-external",
2795 .data = (void *)true },
2796 { },
2797};
2798
Andrew Lunn3126aee2017-12-07 01:05:57 +01002799static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2800
2801{
2802 struct mv88e6xxx_mdio_bus *mdio_bus;
2803 struct mii_bus *bus;
2804
2805 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2806 bus = mdio_bus->bus;
2807
Andrew Lunn6f882842018-03-17 20:32:05 +01002808 if (!mdio_bus->external)
2809 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2810
Andrew Lunn3126aee2017-12-07 01:05:57 +01002811 mdiobus_unregister(bus);
2812 }
2813}
2814
Andrew Lunna3c53be52017-01-24 14:53:50 +01002815static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2816 struct device_node *np)
2817{
2818 const struct of_device_id *match;
2819 struct device_node *child;
2820 int err;
2821
2822 /* Always register one mdio bus for the internal/default mdio
2823 * bus. This maybe represented in the device tree, but is
2824 * optional.
2825 */
2826 child = of_get_child_by_name(np, "mdio");
2827 err = mv88e6xxx_mdio_register(chip, child, false);
2828 if (err)
2829 return err;
2830
2831 /* Walk the device tree, and see if there are any other nodes
2832 * which say they are compatible with the external mdio
2833 * bus.
2834 */
2835 for_each_available_child_of_node(np, child) {
2836 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2837 if (match) {
2838 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002839 if (err) {
2840 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002841 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002842 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002843 }
2844 }
2845
2846 return 0;
2847}
2848
Vivien Didelot855b1932016-07-20 18:18:35 -04002849static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2850{
Vivien Didelot04bed142016-08-31 18:06:13 -04002851 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002852
2853 return chip->eeprom_len;
2854}
2855
Vivien Didelot855b1932016-07-20 18:18:35 -04002856static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2857 struct ethtool_eeprom *eeprom, u8 *data)
2858{
Vivien Didelot04bed142016-08-31 18:06:13 -04002859 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002860 int err;
2861
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002862 if (!chip->info->ops->get_eeprom)
2863 return -EOPNOTSUPP;
2864
Vivien Didelot855b1932016-07-20 18:18:35 -04002865 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002866 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002867 mutex_unlock(&chip->reg_lock);
2868
2869 if (err)
2870 return err;
2871
2872 eeprom->magic = 0xc3ec4951;
2873
2874 return 0;
2875}
2876
Vivien Didelot855b1932016-07-20 18:18:35 -04002877static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2878 struct ethtool_eeprom *eeprom, u8 *data)
2879{
Vivien Didelot04bed142016-08-31 18:06:13 -04002880 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002881 int err;
2882
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002883 if (!chip->info->ops->set_eeprom)
2884 return -EOPNOTSUPP;
2885
Vivien Didelot855b1932016-07-20 18:18:35 -04002886 if (eeprom->magic != 0xc3ec4951)
2887 return -EINVAL;
2888
2889 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002890 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002891 mutex_unlock(&chip->reg_lock);
2892
2893 return err;
2894}
2895
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002896static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002897 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002898 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2899 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002900 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002901 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002902 .phy_read = mv88e6185_phy_ppu_read,
2903 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002904 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002905 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002906 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002907 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002908 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002909 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002910 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002911 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002912 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002913 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002914 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002915 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002916 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002917 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002918 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002919 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2920 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002921 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002922 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2923 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002924 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002925 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002926 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002927 .ppu_enable = mv88e6185_g1_ppu_enable,
2928 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002929 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002930 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002931 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002932 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002933 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002934};
2935
2936static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002937 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002938 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2939 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002940 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002941 .phy_read = mv88e6185_phy_ppu_read,
2942 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002943 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002944 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002945 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002946 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002947 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002948 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002949 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002950 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002951 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002952 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002953 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2954 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002955 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002956 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002957 .ppu_enable = mv88e6185_g1_ppu_enable,
2958 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002959 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002960 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002961 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002962 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002963};
2964
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002965static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002966 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002967 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2968 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002969 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002970 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2971 .phy_read = mv88e6xxx_g2_smi_phy_read,
2972 .phy_write = mv88e6xxx_g2_smi_phy_write,
2973 .port_set_link = mv88e6xxx_port_set_link,
2974 .port_set_duplex = mv88e6xxx_port_set_duplex,
2975 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002976 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002977 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002978 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002979 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002980 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002981 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002982 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002983 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002984 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002985 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002986 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002987 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002988 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002989 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2990 .stats_get_strings = mv88e6095_stats_get_strings,
2991 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002992 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2993 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002994 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002995 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002996 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002997 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002998 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002999 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003000 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003001 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003002};
3003
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003004static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003005 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003006 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3007 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003008 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003009 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003010 .phy_read = mv88e6xxx_g2_smi_phy_read,
3011 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003012 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003013 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003014 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003015 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003016 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003017 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003018 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003019 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003020 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003021 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003022 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003023 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3024 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003025 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003026 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3027 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003028 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003029 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003030 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003031 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003032 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003033 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003034 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003035};
3036
3037static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003038 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003039 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3040 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003041 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003042 .phy_read = mv88e6185_phy_ppu_read,
3043 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003044 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003045 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003046 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003047 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003048 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003049 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003050 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003051 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003052 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003053 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003054 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003055 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003056 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003057 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003058 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003059 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003060 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3061 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003062 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003063 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3064 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003065 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003066 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003067 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003068 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003069 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003070 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003071 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003072 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003073 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003074};
3075
Vivien Didelot990e27b2017-03-28 13:50:32 -04003076static const struct mv88e6xxx_ops mv88e6141_ops = {
3077 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003078 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3079 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003080 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003081 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3082 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3083 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3084 .phy_read = mv88e6xxx_g2_smi_phy_read,
3085 .phy_write = mv88e6xxx_g2_smi_phy_write,
3086 .port_set_link = mv88e6xxx_port_set_link,
3087 .port_set_duplex = mv88e6xxx_port_set_duplex,
3088 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003089 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003090 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003091 .port_tag_remap = mv88e6095_port_tag_remap,
3092 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3093 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3094 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003095 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003096 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003097 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003098 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3099 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003100 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003101 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003102 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003103 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003104 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3105 .stats_get_strings = mv88e6320_stats_get_strings,
3106 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003107 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3108 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003109 .watchdog_ops = &mv88e6390_watchdog_ops,
3110 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003111 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003112 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003113 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003114 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003115 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003116 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003117 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003118};
3119
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003120static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003121 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003122 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3123 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003124 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003125 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003126 .phy_read = mv88e6xxx_g2_smi_phy_read,
3127 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003128 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003129 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003130 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003131 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003132 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003133 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003134 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003135 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003136 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003137 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003138 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003139 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003140 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003141 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003142 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003143 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003144 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3145 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003146 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003147 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3148 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003149 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003150 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003151 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003152 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003153 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003154 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003155 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003156 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003157 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003158};
3159
3160static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003161 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003162 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3163 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003164 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003165 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003166 .phy_read = mv88e6165_phy_read,
3167 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003168 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003169 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003170 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003171 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003172 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003173 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003174 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003175 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003176 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003177 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3178 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003179 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003180 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3181 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003182 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003183 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003184 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003185 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003186 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003187 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003188 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003189 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003190 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003191};
3192
3193static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003194 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003195 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3196 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003197 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003198 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003199 .phy_read = mv88e6xxx_g2_smi_phy_read,
3200 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003201 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003202 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003203 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003204 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003205 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003206 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003207 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003208 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003209 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003210 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003211 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003212 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003213 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003214 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003215 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003216 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003217 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003218 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3219 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003220 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003221 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3222 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003223 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003224 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003225 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003226 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003227 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003228 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003229 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003230};
3231
3232static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003233 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003234 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3235 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003236 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003237 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3238 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003239 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003240 .phy_read = mv88e6xxx_g2_smi_phy_read,
3241 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003242 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003243 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003244 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003245 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003246 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003247 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003248 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003249 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003250 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003251 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003252 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003253 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003254 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003255 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003256 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003257 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003258 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003259 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3260 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003261 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003262 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3263 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003264 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003265 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003266 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003267 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003268 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003269 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003270 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003271 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003272 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003273 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003274};
3275
3276static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003277 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003278 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3279 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003280 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003281 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003282 .phy_read = mv88e6xxx_g2_smi_phy_read,
3283 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003284 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003285 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003286 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003287 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003288 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003289 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003290 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003291 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003292 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003293 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003294 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003295 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003296 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003297 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003298 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003299 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003300 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003301 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3302 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003303 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003304 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3305 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003306 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003307 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003308 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003309 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003310 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003311 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003312 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003313};
3314
3315static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003316 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003317 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3318 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003319 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003320 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3321 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003322 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003323 .phy_read = mv88e6xxx_g2_smi_phy_read,
3324 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003325 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003326 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003327 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003328 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003329 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003330 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003331 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003332 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003333 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003334 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003335 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003336 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003337 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003338 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003339 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003340 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003341 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003342 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3343 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003344 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003345 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3346 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003347 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003348 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003349 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003350 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003351 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003352 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003353 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003354 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003355 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3356 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003357 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003358 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003359};
3360
3361static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003362 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003363 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3364 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003365 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003366 .phy_read = mv88e6185_phy_ppu_read,
3367 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003368 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003369 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003370 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003371 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003372 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003373 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003374 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003375 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003376 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003377 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003378 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003379 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003380 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3381 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003382 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003383 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3384 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003385 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003386 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003387 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003388 .ppu_enable = mv88e6185_g1_ppu_enable,
3389 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003390 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003391 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003392 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003393 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003394};
3395
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003396static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003397 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003398 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003399 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003400 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3401 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003402 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3403 .phy_read = mv88e6xxx_g2_smi_phy_read,
3404 .phy_write = mv88e6xxx_g2_smi_phy_write,
3405 .port_set_link = mv88e6xxx_port_set_link,
3406 .port_set_duplex = mv88e6xxx_port_set_duplex,
3407 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3408 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003409 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003410 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003411 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003412 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003413 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003414 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003415 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003416 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003417 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003418 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003419 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003420 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003421 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003422 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3423 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003424 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003425 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3426 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003427 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003428 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003429 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003430 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003431 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003432 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3433 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003434 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003435 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3436 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003437 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003438 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003439};
3440
3441static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003442 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003443 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003444 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003445 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3446 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003447 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3448 .phy_read = mv88e6xxx_g2_smi_phy_read,
3449 .phy_write = mv88e6xxx_g2_smi_phy_write,
3450 .port_set_link = mv88e6xxx_port_set_link,
3451 .port_set_duplex = mv88e6xxx_port_set_duplex,
3452 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3453 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003454 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003455 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003456 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003457 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003458 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003459 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003460 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003461 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003462 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003463 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003464 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003465 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003466 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003467 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3468 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003469 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003470 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3471 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003472 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003473 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003474 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003475 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003476 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003477 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3478 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003479 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003480 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3481 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003482 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003483 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003484};
3485
3486static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003487 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003488 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003489 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003490 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3491 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003492 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3493 .phy_read = mv88e6xxx_g2_smi_phy_read,
3494 .phy_write = mv88e6xxx_g2_smi_phy_write,
3495 .port_set_link = mv88e6xxx_port_set_link,
3496 .port_set_duplex = mv88e6xxx_port_set_duplex,
3497 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3498 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003499 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003500 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003501 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003502 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003503 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003504 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003505 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003506 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003507 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003508 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003509 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003510 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003511 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003512 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3513 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003514 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003515 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3516 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003517 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003518 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003519 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003520 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003521 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003522 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3523 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003524 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003525 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3526 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003527 .avb_ops = &mv88e6390_avb_ops,
3528 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003529 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003530};
3531
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003532static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003533 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003534 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3535 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003536 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003537 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3538 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003539 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003540 .phy_read = mv88e6xxx_g2_smi_phy_read,
3541 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003542 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003543 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003544 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003545 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003546 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003547 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003548 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003549 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003550 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003551 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003552 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003553 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003554 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003555 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003556 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003557 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003558 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003559 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3560 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003561 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003562 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3563 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003564 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003565 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003566 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003567 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003568 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003569 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003570 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003571 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003572 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3573 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003574 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003575 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003576 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003577 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003578};
3579
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003580static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003581 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003582 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003583 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003584 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3585 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003586 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3587 .phy_read = mv88e6xxx_g2_smi_phy_read,
3588 .phy_write = mv88e6xxx_g2_smi_phy_write,
3589 .port_set_link = mv88e6xxx_port_set_link,
3590 .port_set_duplex = mv88e6xxx_port_set_duplex,
3591 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3592 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003593 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003594 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003595 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003596 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003597 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003598 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003599 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003600 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003601 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003602 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003603 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003604 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003605 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003606 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3607 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003608 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003609 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3610 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003611 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003612 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003613 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003614 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003615 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003616 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3617 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003618 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003619 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3620 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003621 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003622 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003623 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003624 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003625};
3626
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003627static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003628 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003629 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3630 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003631 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003632 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3633 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003634 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003635 .phy_read = mv88e6xxx_g2_smi_phy_read,
3636 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003637 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003638 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003639 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003640 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003641 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003642 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003643 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003644 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003645 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003646 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003647 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003648 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003649 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003650 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003651 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003652 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003653 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3654 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003655 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003656 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3657 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003658 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003659 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003660 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003661 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003662 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003663 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003664 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003665 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003666 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003667 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003668};
3669
3670static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003671 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003672 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3673 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003674 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003675 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3676 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003677 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003678 .phy_read = mv88e6xxx_g2_smi_phy_read,
3679 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003680 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003681 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003682 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003683 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003684 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003685 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003686 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003687 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003688 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003689 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003690 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003691 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003692 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003693 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003694 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003695 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003696 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3697 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003698 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003699 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3700 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003701 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003702 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003703 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003704 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003705 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003706 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003707 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003708 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003709};
3710
Vivien Didelot16e329a2017-03-28 13:50:33 -04003711static const struct mv88e6xxx_ops mv88e6341_ops = {
3712 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003713 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3714 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003715 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003716 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3717 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3718 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3719 .phy_read = mv88e6xxx_g2_smi_phy_read,
3720 .phy_write = mv88e6xxx_g2_smi_phy_write,
3721 .port_set_link = mv88e6xxx_port_set_link,
3722 .port_set_duplex = mv88e6xxx_port_set_duplex,
3723 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003724 .port_set_speed = mv88e6341_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003725 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003726 .port_tag_remap = mv88e6095_port_tag_remap,
3727 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3728 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3729 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003730 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003731 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003732 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003733 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3734 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003735 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003736 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003737 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003738 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003739 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3740 .stats_get_strings = mv88e6320_stats_get_strings,
3741 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003742 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3743 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003744 .watchdog_ops = &mv88e6390_watchdog_ops,
3745 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003746 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003747 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003748 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003749 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003750 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003751 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003752 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003753 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003754 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003755};
3756
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003757static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003758 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003759 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3760 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003761 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003762 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003763 .phy_read = mv88e6xxx_g2_smi_phy_read,
3764 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003765 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003766 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003767 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003768 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003769 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003770 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003771 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003772 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003773 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003774 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003775 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003776 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003777 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003778 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003779 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003780 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003781 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003782 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3783 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003784 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003785 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3786 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003787 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003788 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003789 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003790 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003791 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003792 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003793 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003794};
3795
3796static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003797 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003798 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3799 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003800 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003801 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003802 .phy_read = mv88e6xxx_g2_smi_phy_read,
3803 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003804 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003805 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003806 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003807 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003808 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003809 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003810 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003811 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003812 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003813 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003814 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003815 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003816 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003817 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003818 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003819 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003820 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003821 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3822 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003823 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003824 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3825 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003826 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003827 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003828 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003829 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003830 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003831 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003832 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003833 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003834 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003835};
3836
3837static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003838 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003839 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3840 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003841 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003842 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3843 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003844 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003845 .phy_read = mv88e6xxx_g2_smi_phy_read,
3846 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003847 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003848 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003849 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003850 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003851 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003852 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003853 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003854 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003855 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003856 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003857 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003858 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003859 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003860 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003861 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003862 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003863 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003864 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3865 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003866 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003867 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3868 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003869 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003870 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003871 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003872 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003873 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003874 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003875 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003876 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003877 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3878 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003879 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003880 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003881 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003882 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3883 .serdes_get_strings = mv88e6352_serdes_get_strings,
3884 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003885 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003886};
3887
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003888static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003889 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003890 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003891 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003892 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3893 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003894 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3895 .phy_read = mv88e6xxx_g2_smi_phy_read,
3896 .phy_write = mv88e6xxx_g2_smi_phy_write,
3897 .port_set_link = mv88e6xxx_port_set_link,
3898 .port_set_duplex = mv88e6xxx_port_set_duplex,
3899 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3900 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003901 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003902 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003903 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003904 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003905 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003906 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003907 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003908 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003909 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003910 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003911 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003912 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003913 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003914 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003915 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003916 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3917 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003918 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003919 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3920 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003921 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003922 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003923 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003924 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003925 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003926 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3927 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003928 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003929 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3930 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003931 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003932 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003933 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003934 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003935};
3936
3937static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003938 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003939 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003940 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003941 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3942 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003943 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3944 .phy_read = mv88e6xxx_g2_smi_phy_read,
3945 .phy_write = mv88e6xxx_g2_smi_phy_write,
3946 .port_set_link = mv88e6xxx_port_set_link,
3947 .port_set_duplex = mv88e6xxx_port_set_duplex,
3948 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3949 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003950 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003951 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003952 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003953 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003954 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003955 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003956 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003957 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003958 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003959 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003960 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003961 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003962 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003963 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003964 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003965 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3966 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003967 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003968 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3969 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003970 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003971 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003972 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003973 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003974 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003975 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3976 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003977 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003978 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3979 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003980 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003981 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003982 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003983 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003984};
3985
Vivien Didelotf81ec902016-05-09 13:22:58 -04003986static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3987 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003988 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003989 .family = MV88E6XXX_FAMILY_6097,
3990 .name = "Marvell 88E6085",
3991 .num_databases = 4096,
3992 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003993 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003994 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003995 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003996 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003997 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003998 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003999 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004000 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004001 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004002 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004003 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004004 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004005 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004006 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004007 },
4008
4009 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004010 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004011 .family = MV88E6XXX_FAMILY_6095,
4012 .name = "Marvell 88E6095/88E6095F",
4013 .num_databases = 256,
4014 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004015 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004016 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004017 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004018 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004019 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004020 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004021 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004022 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004023 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004024 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004025 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004026 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004027 },
4028
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004029 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004030 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004031 .family = MV88E6XXX_FAMILY_6097,
4032 .name = "Marvell 88E6097/88E6097F",
4033 .num_databases = 4096,
4034 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004035 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004036 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004037 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004038 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004039 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004040 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004041 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004042 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004043 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004044 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004045 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004046 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004047 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004048 .ops = &mv88e6097_ops,
4049 },
4050
Vivien Didelotf81ec902016-05-09 13:22:58 -04004051 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004052 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004053 .family = MV88E6XXX_FAMILY_6165,
4054 .name = "Marvell 88E6123",
4055 .num_databases = 4096,
4056 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004057 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004058 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004059 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004060 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004061 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004062 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004063 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004064 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004065 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004066 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004067 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004068 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004069 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004070 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004071 },
4072
4073 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004074 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004075 .family = MV88E6XXX_FAMILY_6185,
4076 .name = "Marvell 88E6131",
4077 .num_databases = 256,
4078 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004079 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004080 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004081 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004082 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004083 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004084 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004085 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004086 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004087 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004088 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004089 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004090 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004091 },
4092
Vivien Didelot990e27b2017-03-28 13:50:32 -04004093 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004094 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004095 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004096 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004097 .num_databases = 4096,
4098 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004099 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004100 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004101 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004102 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004103 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004104 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004105 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004106 .age_time_coeff = 3750,
4107 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004108 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004109 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004110 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004111 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004112 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004113 .ops = &mv88e6141_ops,
4114 },
4115
Vivien Didelotf81ec902016-05-09 13:22:58 -04004116 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004117 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004118 .family = MV88E6XXX_FAMILY_6165,
4119 .name = "Marvell 88E6161",
4120 .num_databases = 4096,
4121 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004122 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004123 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004124 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004125 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004126 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004127 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004128 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004129 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004130 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004131 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004132 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004133 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004134 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004135 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004136 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004137 },
4138
4139 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004140 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004141 .family = MV88E6XXX_FAMILY_6165,
4142 .name = "Marvell 88E6165",
4143 .num_databases = 4096,
4144 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004145 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004146 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004147 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004148 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004149 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004150 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004151 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004152 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004153 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004154 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004155 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004156 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004157 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004158 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004159 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004160 },
4161
4162 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004163 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004164 .family = MV88E6XXX_FAMILY_6351,
4165 .name = "Marvell 88E6171",
4166 .num_databases = 4096,
4167 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004168 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004169 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004170 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004171 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004172 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004173 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004174 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004175 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004176 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004177 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004178 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004179 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004180 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004181 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004182 },
4183
4184 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004185 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004186 .family = MV88E6XXX_FAMILY_6352,
4187 .name = "Marvell 88E6172",
4188 .num_databases = 4096,
4189 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004190 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004191 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004192 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004193 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004194 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004195 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004196 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004197 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004198 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004199 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004200 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004201 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004202 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004203 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004204 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004205 },
4206
4207 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004208 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004209 .family = MV88E6XXX_FAMILY_6351,
4210 .name = "Marvell 88E6175",
4211 .num_databases = 4096,
4212 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004213 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004214 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004215 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004216 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004217 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004218 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004219 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004220 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004221 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004222 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004223 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004224 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004225 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004226 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004227 },
4228
4229 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004230 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004231 .family = MV88E6XXX_FAMILY_6352,
4232 .name = "Marvell 88E6176",
4233 .num_databases = 4096,
4234 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004235 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004236 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004237 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004238 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004239 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004240 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004241 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004242 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004243 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004244 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004245 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004246 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004247 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004248 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004249 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004250 },
4251
4252 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004253 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004254 .family = MV88E6XXX_FAMILY_6185,
4255 .name = "Marvell 88E6185",
4256 .num_databases = 256,
4257 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004258 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004259 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004260 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004261 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004262 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004263 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004264 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004265 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004266 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004267 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004268 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004269 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004270 },
4271
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004272 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004273 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004274 .family = MV88E6XXX_FAMILY_6390,
4275 .name = "Marvell 88E6190",
4276 .num_databases = 4096,
4277 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004278 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004279 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004280 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004281 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004282 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004283 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004284 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004285 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004286 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004287 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004288 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004289 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004290 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004291 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004292 .ops = &mv88e6190_ops,
4293 },
4294
4295 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004296 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004297 .family = MV88E6XXX_FAMILY_6390,
4298 .name = "Marvell 88E6190X",
4299 .num_databases = 4096,
4300 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004301 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004302 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004303 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004304 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004305 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004306 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004307 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004308 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004309 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004310 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004311 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004312 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004313 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004314 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004315 .ops = &mv88e6190x_ops,
4316 },
4317
4318 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004319 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004320 .family = MV88E6XXX_FAMILY_6390,
4321 .name = "Marvell 88E6191",
4322 .num_databases = 4096,
4323 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004324 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004325 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004326 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004327 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004328 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004329 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004330 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004331 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004332 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004333 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004334 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004335 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004336 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004337 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004338 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004339 },
4340
Vivien Didelotf81ec902016-05-09 13:22:58 -04004341 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004342 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004343 .family = MV88E6XXX_FAMILY_6352,
4344 .name = "Marvell 88E6240",
4345 .num_databases = 4096,
4346 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004347 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004348 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004349 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004350 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004351 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004352 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004353 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004354 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004355 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004356 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004357 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004358 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004359 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004360 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004361 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004362 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004363 },
4364
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004365 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004366 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004367 .family = MV88E6XXX_FAMILY_6390,
4368 .name = "Marvell 88E6290",
4369 .num_databases = 4096,
4370 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004371 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004372 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004373 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004374 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004375 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004376 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004377 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004378 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004379 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004380 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004381 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004382 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004383 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004384 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004385 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004386 .ops = &mv88e6290_ops,
4387 },
4388
Vivien Didelotf81ec902016-05-09 13:22:58 -04004389 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004390 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004391 .family = MV88E6XXX_FAMILY_6320,
4392 .name = "Marvell 88E6320",
4393 .num_databases = 4096,
4394 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004395 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004396 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004397 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004398 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004399 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004400 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004401 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004402 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004403 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004404 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004405 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004406 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004407 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004408 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004409 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004410 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004411 },
4412
4413 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004414 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004415 .family = MV88E6XXX_FAMILY_6320,
4416 .name = "Marvell 88E6321",
4417 .num_databases = 4096,
4418 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004419 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004420 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004421 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004422 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004423 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004424 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004425 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004426 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004427 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004428 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004429 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004430 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004431 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004432 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004433 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004434 },
4435
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004436 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004437 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004438 .family = MV88E6XXX_FAMILY_6341,
4439 .name = "Marvell 88E6341",
4440 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004441 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004442 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004443 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004444 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004445 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004446 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004447 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004448 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004449 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004450 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004451 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004452 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004453 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004454 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004455 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004456 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004457 .ops = &mv88e6341_ops,
4458 },
4459
Vivien Didelotf81ec902016-05-09 13:22:58 -04004460 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004461 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004462 .family = MV88E6XXX_FAMILY_6351,
4463 .name = "Marvell 88E6350",
4464 .num_databases = 4096,
4465 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004466 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004467 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004468 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004469 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004470 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004471 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004472 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004473 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004474 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004475 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004476 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004477 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004478 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004479 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004480 },
4481
4482 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004483 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004484 .family = MV88E6XXX_FAMILY_6351,
4485 .name = "Marvell 88E6351",
4486 .num_databases = 4096,
4487 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004488 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004489 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004490 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004491 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004492 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004493 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004494 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004495 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004496 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004497 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004498 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004499 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004500 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004501 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004502 },
4503
4504 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004505 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004506 .family = MV88E6XXX_FAMILY_6352,
4507 .name = "Marvell 88E6352",
4508 .num_databases = 4096,
4509 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004510 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004511 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004512 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004513 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004514 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004515 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004516 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004517 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004518 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004519 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004520 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004521 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004522 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004523 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004524 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004525 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004526 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004527 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004528 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004529 .family = MV88E6XXX_FAMILY_6390,
4530 .name = "Marvell 88E6390",
4531 .num_databases = 4096,
4532 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004533 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004534 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004535 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004536 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004537 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004538 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004539 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004540 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004541 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004542 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004543 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004544 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004545 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004546 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004547 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004548 .ops = &mv88e6390_ops,
4549 },
4550 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004551 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004552 .family = MV88E6XXX_FAMILY_6390,
4553 .name = "Marvell 88E6390X",
4554 .num_databases = 4096,
4555 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004556 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004557 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004558 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004559 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004560 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004561 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004562 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004563 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004564 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004565 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004566 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004567 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004568 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004569 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004570 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004571 .ops = &mv88e6390x_ops,
4572 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004573};
4574
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004575static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004576{
Vivien Didelota439c062016-04-17 13:23:58 -04004577 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004578
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004579 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4580 if (mv88e6xxx_table[i].prod_num == prod_num)
4581 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004582
Vivien Didelotb9b37712015-10-30 19:39:48 -04004583 return NULL;
4584}
4585
Vivien Didelotfad09c72016-06-21 12:28:20 -04004586static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004587{
4588 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004589 unsigned int prod_num, rev;
4590 u16 id;
4591 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004592
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004593 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004594 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004595 mutex_unlock(&chip->reg_lock);
4596 if (err)
4597 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004598
Vivien Didelot107fcc12017-06-12 12:37:36 -04004599 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4600 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004601
4602 info = mv88e6xxx_lookup_info(prod_num);
4603 if (!info)
4604 return -ENODEV;
4605
Vivien Didelotcaac8542016-06-20 13:14:09 -04004606 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004607 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004608
Vivien Didelotca070c12016-09-02 14:45:34 -04004609 err = mv88e6xxx_g2_require(chip);
4610 if (err)
4611 return err;
4612
Vivien Didelotfad09c72016-06-21 12:28:20 -04004613 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4614 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004615
4616 return 0;
4617}
4618
Vivien Didelotfad09c72016-06-21 12:28:20 -04004619static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004620{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004621 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004622
Vivien Didelotfad09c72016-06-21 12:28:20 -04004623 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4624 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004625 return NULL;
4626
Vivien Didelotfad09c72016-06-21 12:28:20 -04004627 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004628
Vivien Didelotfad09c72016-06-21 12:28:20 -04004629 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004630 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004631
Vivien Didelotfad09c72016-06-21 12:28:20 -04004632 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004633}
4634
Vivien Didelotfad09c72016-06-21 12:28:20 -04004635static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004636 struct mii_bus *bus, int sw_addr)
4637{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004638 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004639 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004640 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004641 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004642 else
4643 return -EINVAL;
4644
Vivien Didelotfad09c72016-06-21 12:28:20 -04004645 chip->bus = bus;
4646 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004647
4648 return 0;
4649}
4650
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004651static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4652 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004653{
Vivien Didelot04bed142016-08-31 18:06:13 -04004654 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004655
Andrew Lunn443d5a12016-12-03 04:35:18 +01004656 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004657}
4658
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004659#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004660static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4661 struct device *host_dev, int sw_addr,
4662 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004663{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004664 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004665 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004666 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004667
Vivien Didelota439c062016-04-17 13:23:58 -04004668 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004669 if (!bus)
4670 return NULL;
4671
Vivien Didelotfad09c72016-06-21 12:28:20 -04004672 chip = mv88e6xxx_alloc_chip(dsa_dev);
4673 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004674 return NULL;
4675
Vivien Didelotcaac8542016-06-20 13:14:09 -04004676 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004677 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004678
Vivien Didelotfad09c72016-06-21 12:28:20 -04004679 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004680 if (err)
4681 goto free;
4682
Vivien Didelotfad09c72016-06-21 12:28:20 -04004683 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004684 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004685 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004686
Andrew Lunndc30c352016-10-16 19:56:49 +02004687 mutex_lock(&chip->reg_lock);
4688 err = mv88e6xxx_switch_reset(chip);
4689 mutex_unlock(&chip->reg_lock);
4690 if (err)
4691 goto free;
4692
Vivien Didelote57e5e72016-08-15 17:19:00 -04004693 mv88e6xxx_phy_init(chip);
4694
Andrew Lunna3c53be52017-01-24 14:53:50 +01004695 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004696 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004697 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004698
Vivien Didelotfad09c72016-06-21 12:28:20 -04004699 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004700
Vivien Didelotfad09c72016-06-21 12:28:20 -04004701 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004702free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004703 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004704
4705 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004706}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004707#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004708
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004709static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004710 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004711{
4712 /* We don't need any dynamic resource from the kernel (yet),
4713 * so skip the prepare phase.
4714 */
4715
4716 return 0;
4717}
4718
4719static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004720 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004721{
Vivien Didelot04bed142016-08-31 18:06:13 -04004722 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004723
4724 mutex_lock(&chip->reg_lock);
4725 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004726 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004727 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4728 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004729 mutex_unlock(&chip->reg_lock);
4730}
4731
4732static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4733 const struct switchdev_obj_port_mdb *mdb)
4734{
Vivien Didelot04bed142016-08-31 18:06:13 -04004735 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004736 int err;
4737
4738 mutex_lock(&chip->reg_lock);
4739 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004740 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004741 mutex_unlock(&chip->reg_lock);
4742
4743 return err;
4744}
4745
Russell King4f859012019-02-20 15:35:05 -08004746static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4747 bool unicast, bool multicast)
4748{
4749 struct mv88e6xxx_chip *chip = ds->priv;
4750 int err = -EOPNOTSUPP;
4751
4752 mutex_lock(&chip->reg_lock);
4753 if (chip->info->ops->port_set_egress_floods)
4754 err = chip->info->ops->port_set_egress_floods(chip, port,
4755 unicast,
4756 multicast);
4757 mutex_unlock(&chip->reg_lock);
4758
4759 return err;
4760}
4761
Florian Fainellia82f67a2017-01-08 14:52:08 -08004762static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004763#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004764 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004765#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004766 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004767 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004768 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004769 .phylink_validate = mv88e6xxx_validate,
4770 .phylink_mac_link_state = mv88e6xxx_link_state,
4771 .phylink_mac_config = mv88e6xxx_mac_config,
4772 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4773 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004774 .get_strings = mv88e6xxx_get_strings,
4775 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4776 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004777 .port_enable = mv88e6xxx_port_enable,
4778 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004779 .get_mac_eee = mv88e6xxx_get_mac_eee,
4780 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004781 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004782 .get_eeprom = mv88e6xxx_get_eeprom,
4783 .set_eeprom = mv88e6xxx_set_eeprom,
4784 .get_regs_len = mv88e6xxx_get_regs_len,
4785 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004786 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004787 .port_bridge_join = mv88e6xxx_port_bridge_join,
4788 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004789 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004790 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004791 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004792 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4793 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4794 .port_vlan_add = mv88e6xxx_port_vlan_add,
4795 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004796 .port_fdb_add = mv88e6xxx_port_fdb_add,
4797 .port_fdb_del = mv88e6xxx_port_fdb_del,
4798 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004799 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4800 .port_mdb_add = mv88e6xxx_port_mdb_add,
4801 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004802 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4803 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004804 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4805 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4806 .port_txtstamp = mv88e6xxx_port_txtstamp,
4807 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4808 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004809};
4810
Florian Fainelliab3d4082017-01-08 14:52:07 -08004811static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4812 .ops = &mv88e6xxx_switch_ops,
4813};
4814
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004815static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004816{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004817 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004818 struct dsa_switch *ds;
4819
Vivien Didelot73b12042017-03-30 17:37:10 -04004820 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004821 if (!ds)
4822 return -ENOMEM;
4823
Vivien Didelotfad09c72016-06-21 12:28:20 -04004824 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004825 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004826 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004827 ds->ageing_time_min = chip->info->age_time_coeff;
4828 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004829
4830 dev_set_drvdata(dev, ds);
4831
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004832 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004833}
4834
Vivien Didelotfad09c72016-06-21 12:28:20 -04004835static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004836{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004837 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004838}
4839
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004840static const void *pdata_device_get_match_data(struct device *dev)
4841{
4842 const struct of_device_id *matches = dev->driver->of_match_table;
4843 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4844
4845 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4846 matches++) {
4847 if (!strcmp(pdata->compatible, matches->compatible))
4848 return matches->data;
4849 }
4850 return NULL;
4851}
4852
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004853/* There is no suspend to RAM support at DSA level yet, the switch configuration
4854 * would be lost after a power cycle so prevent it to be suspended.
4855 */
4856static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4857{
4858 return -EOPNOTSUPP;
4859}
4860
4861static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4862{
4863 return 0;
4864}
4865
4866static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4867
Vivien Didelot57d32312016-06-20 13:13:58 -04004868static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004869{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004870 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004871 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004872 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004873 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004874 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004875 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004876 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004877
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004878 if (!np && !pdata)
4879 return -EINVAL;
4880
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004881 if (np)
4882 compat_info = of_device_get_match_data(dev);
4883
4884 if (pdata) {
4885 compat_info = pdata_device_get_match_data(dev);
4886
4887 if (!pdata->netdev)
4888 return -EINVAL;
4889
4890 for (port = 0; port < DSA_MAX_PORTS; port++) {
4891 if (!(pdata->enabled_ports & (1 << port)))
4892 continue;
4893 if (strcmp(pdata->cd.port_names[port], "cpu"))
4894 continue;
4895 pdata->cd.netdev[port] = &pdata->netdev->dev;
4896 break;
4897 }
4898 }
4899
Vivien Didelotcaac8542016-06-20 13:14:09 -04004900 if (!compat_info)
4901 return -EINVAL;
4902
Vivien Didelotfad09c72016-06-21 12:28:20 -04004903 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004904 if (!chip) {
4905 err = -ENOMEM;
4906 goto out;
4907 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004908
Vivien Didelotfad09c72016-06-21 12:28:20 -04004909 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004910
Vivien Didelotfad09c72016-06-21 12:28:20 -04004911 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004912 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004913 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004914
Andrew Lunnb4308f02016-11-21 23:26:55 +01004915 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004916 if (IS_ERR(chip->reset)) {
4917 err = PTR_ERR(chip->reset);
4918 goto out;
4919 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004920
Vivien Didelotfad09c72016-06-21 12:28:20 -04004921 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004922 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004923 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004924
Vivien Didelote57e5e72016-08-15 17:19:00 -04004925 mv88e6xxx_phy_init(chip);
4926
Andrew Lunn00baabe2018-05-19 22:31:35 +02004927 if (chip->info->ops->get_eeprom) {
4928 if (np)
4929 of_property_read_u32(np, "eeprom-length",
4930 &chip->eeprom_len);
4931 else
4932 chip->eeprom_len = pdata->eeprom_len;
4933 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004934
Andrew Lunndc30c352016-10-16 19:56:49 +02004935 mutex_lock(&chip->reg_lock);
4936 err = mv88e6xxx_switch_reset(chip);
4937 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004938 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004939 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004940
Andrew Lunndc30c352016-10-16 19:56:49 +02004941 chip->irq = of_irq_get(np, 0);
4942 if (chip->irq == -EPROBE_DEFER) {
4943 err = chip->irq;
4944 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004945 }
4946
Andrew Lunn294d7112018-02-22 22:58:32 +01004947 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004948 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004949 * controllers
4950 */
4951 mutex_lock(&chip->reg_lock);
4952 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004953 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004954 else
4955 err = mv88e6xxx_irq_poll_setup(chip);
4956 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004957
Andrew Lunn294d7112018-02-22 22:58:32 +01004958 if (err)
4959 goto out;
4960
4961 if (chip->info->g2_irqs > 0) {
4962 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004963 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004964 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004965 }
4966
Andrew Lunn294d7112018-02-22 22:58:32 +01004967 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4968 if (err)
4969 goto out_g2_irq;
4970
4971 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4972 if (err)
4973 goto out_g1_atu_prob_irq;
4974
Andrew Lunna3c53be52017-01-24 14:53:50 +01004975 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004976 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004977 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004978
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004979 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004980 if (err)
4981 goto out_mdio;
4982
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004983 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004984
4985out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004986 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004987out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004988 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004989out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004990 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004991out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004992 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004993 mv88e6xxx_g2_irq_free(chip);
4994out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004995 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004996 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004997 else
4998 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004999out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005000 if (pdata)
5001 dev_put(pdata->netdev);
5002
Andrew Lunndc30c352016-10-16 19:56:49 +02005003 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005004}
5005
5006static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5007{
5008 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005009 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005010
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005011 if (chip->info->ptp_support) {
5012 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005013 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005014 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005015
Andrew Lunn930188c2016-08-22 16:01:03 +02005016 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005017 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005018 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005019
Andrew Lunn76f38f12018-03-17 20:21:09 +01005020 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5021 mv88e6xxx_g1_atu_prob_irq_free(chip);
5022
5023 if (chip->info->g2_irqs > 0)
5024 mv88e6xxx_g2_irq_free(chip);
5025
Andrew Lunn76f38f12018-03-17 20:21:09 +01005026 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005027 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005028 else
5029 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005030}
5031
5032static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005033 {
5034 .compatible = "marvell,mv88e6085",
5035 .data = &mv88e6xxx_table[MV88E6085],
5036 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005037 {
5038 .compatible = "marvell,mv88e6190",
5039 .data = &mv88e6xxx_table[MV88E6190],
5040 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005041 { /* sentinel */ },
5042};
5043
5044MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5045
5046static struct mdio_driver mv88e6xxx_driver = {
5047 .probe = mv88e6xxx_probe,
5048 .remove = mv88e6xxx_remove,
5049 .mdiodrv.driver = {
5050 .name = "mv88e6085",
5051 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005052 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005053 },
5054};
5055
Ben Hutchings98e67302011-11-25 14:36:19 +00005056static int __init mv88e6xxx_init(void)
5057{
Florian Fainelliab3d4082017-01-08 14:52:07 -08005058 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005059 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00005060}
5061module_init(mv88e6xxx_init);
5062
5063static void __exit mv88e6xxx_cleanup(void)
5064{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005065 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08005066 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00005067}
5068module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005069
5070MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5071MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5072MODULE_LICENSE("GPL");