blob: a3a2eb985aced2b75b8d829c256f62a9fe4d4ef4 [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
Vivien Didelotd78343d2016-11-04 03:23:36 +0100552static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
Andrew Lunn54186b92018-08-09 15:38:37 +0200553 int link, int speed, int duplex, int pause,
Vivien Didelotd78343d2016-11-04 03:23:36 +0100554 phy_interface_t mode)
555{
556 int err;
557
558 if (!chip->info->ops->port_set_link)
559 return 0;
560
561 /* Port's MAC control must not be changed unless the link is down */
562 err = chip->info->ops->port_set_link(chip, port, 0);
563 if (err)
564 return err;
565
566 if (chip->info->ops->port_set_speed) {
567 err = chip->info->ops->port_set_speed(chip, port, speed);
568 if (err && err != -EOPNOTSUPP)
569 goto restore_link;
570 }
571
Andrew Lunn54186b92018-08-09 15:38:37 +0200572 if (chip->info->ops->port_set_pause) {
573 err = chip->info->ops->port_set_pause(chip, port, pause);
574 if (err)
575 goto restore_link;
576 }
577
Vivien Didelotd78343d2016-11-04 03:23:36 +0100578 if (chip->info->ops->port_set_duplex) {
579 err = chip->info->ops->port_set_duplex(chip, port, duplex);
580 if (err && err != -EOPNOTSUPP)
581 goto restore_link;
582 }
583
584 if (chip->info->ops->port_set_rgmii_delay) {
585 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
586 if (err && err != -EOPNOTSUPP)
587 goto restore_link;
588 }
589
Andrew Lunnf39908d2017-02-04 20:02:50 +0100590 if (chip->info->ops->port_set_cmode) {
591 err = chip->info->ops->port_set_cmode(chip, port, mode);
592 if (err && err != -EOPNOTSUPP)
593 goto restore_link;
594 }
595
Vivien Didelotd78343d2016-11-04 03:23:36 +0100596 err = 0;
597restore_link:
598 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400599 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100600
601 return err;
602}
603
Marek Vasutd700ec42018-09-12 00:15:24 +0200604static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
605{
606 struct mv88e6xxx_chip *chip = ds->priv;
607
608 return port < chip->info->num_internal_phys;
609}
610
Andrew Lunndea87022015-08-31 15:56:47 +0200611/* We expect the switch to perform auto negotiation if there is a real
612 * phy. However, in the case of a fixed link phy, we force the port
613 * settings from the fixed link settings.
614 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400615static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
616 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200617{
Vivien Didelot04bed142016-08-31 18:06:13 -0400618 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200619 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200620
Marek Vasutd700ec42018-09-12 00:15:24 +0200621 if (!phy_is_pseudo_fixed_link(phydev) &&
622 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200623 return;
624
Vivien Didelotfad09c72016-06-21 12:28:20 -0400625 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100626 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200627 phydev->duplex, phydev->pause,
628 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400629 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100630
631 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400632 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200633}
634
Russell King6c422e32018-08-09 15:38:39 +0200635static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
636 unsigned long *mask,
637 struct phylink_link_state *state)
638{
639 if (!phy_interface_mode_is_8023z(state->interface)) {
640 /* 10M and 100M are only supported in non-802.3z mode */
641 phylink_set(mask, 10baseT_Half);
642 phylink_set(mask, 10baseT_Full);
643 phylink_set(mask, 100baseT_Half);
644 phylink_set(mask, 100baseT_Full);
645 }
646}
647
648static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
649 unsigned long *mask,
650 struct phylink_link_state *state)
651{
652 /* FIXME: if the port is in 1000Base-X mode, then it only supports
653 * 1000M FD speeds. In this case, CMODE will indicate 5.
654 */
655 phylink_set(mask, 1000baseT_Full);
656 phylink_set(mask, 1000baseX_Full);
657
658 mv88e6065_phylink_validate(chip, port, mask, state);
659}
660
Marek Behúne3af71a2019-02-25 12:39:55 +0100661static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
662 unsigned long *mask,
663 struct phylink_link_state *state)
664{
665 if (port >= 5)
666 phylink_set(mask, 2500baseX_Full);
667
668 /* No ethtool bits for 200Mbps */
669 phylink_set(mask, 1000baseT_Full);
670 phylink_set(mask, 1000baseX_Full);
671
672 mv88e6065_phylink_validate(chip, port, mask, state);
673}
674
Russell King6c422e32018-08-09 15:38:39 +0200675static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
676 unsigned long *mask,
677 struct phylink_link_state *state)
678{
679 /* No ethtool bits for 200Mbps */
680 phylink_set(mask, 1000baseT_Full);
681 phylink_set(mask, 1000baseX_Full);
682
683 mv88e6065_phylink_validate(chip, port, mask, state);
684}
685
686static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
687 unsigned long *mask,
688 struct phylink_link_state *state)
689{
Andrew Lunnec260162019-02-08 22:25:44 +0100690 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200691 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100692 phylink_set(mask, 2500baseT_Full);
693 }
Russell King6c422e32018-08-09 15:38:39 +0200694
695 /* No ethtool bits for 200Mbps */
696 phylink_set(mask, 1000baseT_Full);
697 phylink_set(mask, 1000baseX_Full);
698
699 mv88e6065_phylink_validate(chip, port, mask, state);
700}
701
702static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
703 unsigned long *mask,
704 struct phylink_link_state *state)
705{
706 if (port >= 9) {
707 phylink_set(mask, 10000baseT_Full);
708 phylink_set(mask, 10000baseKR_Full);
709 }
710
711 mv88e6390_phylink_validate(chip, port, mask, state);
712}
713
Russell Kingc9a23562018-05-10 13:17:35 -0700714static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
715 unsigned long *supported,
716 struct phylink_link_state *state)
717{
Russell King6c422e32018-08-09 15:38:39 +0200718 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
719 struct mv88e6xxx_chip *chip = ds->priv;
720
721 /* Allow all the expected bits */
722 phylink_set(mask, Autoneg);
723 phylink_set(mask, Pause);
724 phylink_set_port_modes(mask);
725
726 if (chip->info->ops->phylink_validate)
727 chip->info->ops->phylink_validate(chip, port, mask, state);
728
729 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
730 bitmap_and(state->advertising, state->advertising, mask,
731 __ETHTOOL_LINK_MODE_MASK_NBITS);
732
733 /* We can only operate at 2500BaseX or 1000BaseX. If requested
734 * to advertise both, only report advertising at 2500BaseX.
735 */
736 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700737}
738
739static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
740 struct phylink_link_state *state)
741{
742 struct mv88e6xxx_chip *chip = ds->priv;
743 int err;
744
745 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200746 if (chip->info->ops->port_link_state)
747 err = chip->info->ops->port_link_state(chip, port, state);
748 else
749 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700750 mutex_unlock(&chip->reg_lock);
751
752 return err;
753}
754
755static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
756 unsigned int mode,
757 const struct phylink_link_state *state)
758{
759 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200760 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700761
Marek Vasutd700ec42018-09-12 00:15:24 +0200762 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700763 return;
764
765 if (mode == MLO_AN_FIXED) {
766 link = LINK_FORCED_UP;
767 speed = state->speed;
768 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200769 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
770 link = state->link;
771 speed = state->speed;
772 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700773 } else {
774 speed = SPEED_UNFORCED;
775 duplex = DUPLEX_UNFORCED;
776 link = LINK_UNFORCED;
777 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200778 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700779
780 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200781 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700782 state->interface);
783 mutex_unlock(&chip->reg_lock);
784
785 if (err && err != -EOPNOTSUPP)
786 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
787}
788
789static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
790{
791 struct mv88e6xxx_chip *chip = ds->priv;
792 int err;
793
794 mutex_lock(&chip->reg_lock);
795 err = chip->info->ops->port_set_link(chip, port, link);
796 mutex_unlock(&chip->reg_lock);
797
798 if (err)
799 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
800}
801
802static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
803 unsigned int mode,
804 phy_interface_t interface)
805{
806 if (mode == MLO_AN_FIXED)
807 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
808}
809
810static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
811 unsigned int mode, phy_interface_t interface,
812 struct phy_device *phydev)
813{
814 if (mode == MLO_AN_FIXED)
815 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
816}
817
Andrew Lunna605a0f2016-11-21 23:26:58 +0100818static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000819{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100820 if (!chip->info->ops->stats_snapshot)
821 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000822
Andrew Lunna605a0f2016-11-21 23:26:58 +0100823 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000824}
825
Andrew Lunne413e7e2015-04-02 04:06:38 +0200826static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100827 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
828 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
829 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
830 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
831 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
832 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
833 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
834 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
835 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
836 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
837 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
838 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
839 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
840 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
841 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
842 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
843 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
844 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
845 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
846 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
847 { "single", 4, 0x14, STATS_TYPE_BANK0, },
848 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
849 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
850 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
851 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
852 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
853 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
854 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
855 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
856 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
857 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
858 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
859 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
860 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
861 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
862 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
863 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
864 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
865 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
866 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
867 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
868 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
869 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
870 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
871 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
872 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
873 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
874 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
875 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
876 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
877 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
878 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
879 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
880 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
881 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
882 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
883 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
884 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
885 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200886};
887
Vivien Didelotfad09c72016-06-21 12:28:20 -0400888static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100889 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100890 int port, u16 bank1_select,
891 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200892{
Andrew Lunn80c46272015-06-20 18:42:30 +0200893 u32 low;
894 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100895 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200896 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200897 u64 value;
898
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100899 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100900 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200901 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
902 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800903 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200904
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200905 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100906 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200907 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
908 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800909 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200910 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200911 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100912 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100913 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100914 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100915 /* fall through */
916 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100917 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100918 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100919 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100920 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500921 break;
922 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800923 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200924 }
925 value = (((u64)high) << 16) | low;
926 return value;
927}
928
Andrew Lunn436fe172018-03-01 02:02:29 +0100929static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
930 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100931{
932 struct mv88e6xxx_hw_stat *stat;
933 int i, j;
934
935 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
936 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100937 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100938 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
939 ETH_GSTRING_LEN);
940 j++;
941 }
942 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100943
944 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100945}
946
Andrew Lunn436fe172018-03-01 02:02:29 +0100947static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
948 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100949{
Andrew Lunn436fe172018-03-01 02:02:29 +0100950 return mv88e6xxx_stats_get_strings(chip, data,
951 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100952}
953
Andrew Lunn436fe172018-03-01 02:02:29 +0100954static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
955 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100956{
Andrew Lunn436fe172018-03-01 02:02:29 +0100957 return mv88e6xxx_stats_get_strings(chip, data,
958 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100959}
960
Andrew Lunn65f60e42018-03-28 23:50:28 +0200961static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
962 "atu_member_violation",
963 "atu_miss_violation",
964 "atu_full_violation",
965 "vtu_member_violation",
966 "vtu_miss_violation",
967};
968
969static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
970{
971 unsigned int i;
972
973 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
974 strlcpy(data + i * ETH_GSTRING_LEN,
975 mv88e6xxx_atu_vtu_stats_strings[i],
976 ETH_GSTRING_LEN);
977}
978
Andrew Lunndfafe442016-11-21 23:27:02 +0100979static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700980 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100981{
Vivien Didelot04bed142016-08-31 18:06:13 -0400982 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100983 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100984
Florian Fainelli89f09042018-04-25 12:12:50 -0700985 if (stringset != ETH_SS_STATS)
986 return;
987
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100988 mutex_lock(&chip->reg_lock);
989
Andrew Lunndfafe442016-11-21 23:27:02 +0100990 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100991 count = chip->info->ops->stats_get_strings(chip, data);
992
993 if (chip->info->ops->serdes_get_strings) {
994 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200995 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100996 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100997
Andrew Lunn65f60e42018-03-28 23:50:28 +0200998 data += count * ETH_GSTRING_LEN;
999 mv88e6xxx_atu_vtu_get_strings(data);
1000
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001001 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001002}
1003
1004static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
1005 int types)
1006{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001007 struct mv88e6xxx_hw_stat *stat;
1008 int i, j;
1009
1010 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1011 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +01001012 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001013 j++;
1014 }
1015 return j;
1016}
1017
Andrew Lunndfafe442016-11-21 23:27:02 +01001018static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1019{
1020 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1021 STATS_TYPE_PORT);
1022}
1023
1024static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1025{
1026 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1027 STATS_TYPE_BANK1);
1028}
1029
Florian Fainelli89f09042018-04-25 12:12:50 -07001030static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001031{
1032 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001033 int serdes_count = 0;
1034 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001035
Florian Fainelli89f09042018-04-25 12:12:50 -07001036 if (sset != ETH_SS_STATS)
1037 return 0;
1038
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001039 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001040 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001041 count = chip->info->ops->stats_get_sset_count(chip);
1042 if (count < 0)
1043 goto out;
1044
1045 if (chip->info->ops->serdes_get_sset_count)
1046 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1047 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001048 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001049 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001050 goto out;
1051 }
1052 count += serdes_count;
1053 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1054
Andrew Lunn436fe172018-03-01 02:02:29 +01001055out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001056 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001057
Andrew Lunn436fe172018-03-01 02:02:29 +01001058 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001059}
1060
Andrew Lunn436fe172018-03-01 02:02:29 +01001061static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1062 uint64_t *data, int types,
1063 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001064{
1065 struct mv88e6xxx_hw_stat *stat;
1066 int i, j;
1067
1068 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1069 stat = &mv88e6xxx_hw_stats[i];
1070 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001071 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001072 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1073 bank1_select,
1074 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001075 mutex_unlock(&chip->reg_lock);
1076
Andrew Lunn052f9472016-11-21 23:27:03 +01001077 j++;
1078 }
1079 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001080 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001081}
1082
Andrew Lunn436fe172018-03-01 02:02:29 +01001083static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1084 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001085{
1086 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001087 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001088 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001089}
1090
Andrew Lunn436fe172018-03-01 02:02:29 +01001091static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1092 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001093{
1094 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001095 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001096 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1097 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001098}
1099
Andrew Lunn436fe172018-03-01 02:02:29 +01001100static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1101 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001102{
1103 return mv88e6xxx_stats_get_stats(chip, port, data,
1104 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001105 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1106 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001107}
1108
Andrew Lunn65f60e42018-03-28 23:50:28 +02001109static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1110 uint64_t *data)
1111{
1112 *data++ = chip->ports[port].atu_member_violation;
1113 *data++ = chip->ports[port].atu_miss_violation;
1114 *data++ = chip->ports[port].atu_full_violation;
1115 *data++ = chip->ports[port].vtu_member_violation;
1116 *data++ = chip->ports[port].vtu_miss_violation;
1117}
1118
Andrew Lunn052f9472016-11-21 23:27:03 +01001119static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1120 uint64_t *data)
1121{
Andrew Lunn436fe172018-03-01 02:02:29 +01001122 int count = 0;
1123
Andrew Lunn052f9472016-11-21 23:27:03 +01001124 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001125 count = chip->info->ops->stats_get_stats(chip, port, data);
1126
Andrew Lunn65f60e42018-03-28 23:50:28 +02001127 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001128 if (chip->info->ops->serdes_get_stats) {
1129 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001130 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001131 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001132 data += count;
1133 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1134 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001135}
1136
Vivien Didelotf81ec902016-05-09 13:22:58 -04001137static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1138 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001139{
Vivien Didelot04bed142016-08-31 18:06:13 -04001140 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001141 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001142
Vivien Didelotfad09c72016-06-21 12:28:20 -04001143 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001144
Andrew Lunna605a0f2016-11-21 23:26:58 +01001145 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001146 mutex_unlock(&chip->reg_lock);
1147
1148 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001149 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001150
1151 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001152
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001153}
Ben Hutchings98e67302011-11-25 14:36:19 +00001154
Vivien Didelotf81ec902016-05-09 13:22:58 -04001155static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001156{
1157 return 32 * sizeof(u16);
1158}
1159
Vivien Didelotf81ec902016-05-09 13:22:58 -04001160static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1161 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001162{
Vivien Didelot04bed142016-08-31 18:06:13 -04001163 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001164 int err;
1165 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001166 u16 *p = _p;
1167 int i;
1168
Vivien Didelota5f39322018-12-17 16:05:21 -05001169 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001170
1171 memset(p, 0xff, 32 * sizeof(u16));
1172
Vivien Didelotfad09c72016-06-21 12:28:20 -04001173 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001174
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001175 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001176
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001177 err = mv88e6xxx_port_read(chip, port, i, &reg);
1178 if (!err)
1179 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001180 }
Vivien Didelot23062512016-05-09 13:22:45 -04001181
Vivien Didelotfad09c72016-06-21 12:28:20 -04001182 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001183}
1184
Vivien Didelot08f50062017-08-01 16:32:41 -04001185static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1186 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001187{
Vivien Didelot5480db62017-08-01 16:32:40 -04001188 /* Nothing to do on the port's MAC */
1189 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001190}
1191
Vivien Didelot08f50062017-08-01 16:32:41 -04001192static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1193 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001194{
Vivien Didelot5480db62017-08-01 16:32:40 -04001195 /* Nothing to do on the port's MAC */
1196 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001197}
1198
Vivien Didelote5887a22017-03-30 17:37:11 -04001199static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001200{
Vivien Didelote5887a22017-03-30 17:37:11 -04001201 struct dsa_switch *ds = NULL;
1202 struct net_device *br;
1203 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001204 int i;
1205
Vivien Didelote5887a22017-03-30 17:37:11 -04001206 if (dev < DSA_MAX_SWITCHES)
1207 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001208
Vivien Didelote5887a22017-03-30 17:37:11 -04001209 /* Prevent frames from unknown switch or port */
1210 if (!ds || port >= ds->num_ports)
1211 return 0;
1212
1213 /* Frames from DSA links and CPU ports can egress any local port */
1214 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1215 return mv88e6xxx_port_mask(chip);
1216
1217 br = ds->ports[port].bridge_dev;
1218 pvlan = 0;
1219
1220 /* Frames from user ports can egress any local DSA links and CPU ports,
1221 * as well as any local member of their bridge group.
1222 */
1223 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1224 if (dsa_is_cpu_port(chip->ds, i) ||
1225 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001226 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001227 pvlan |= BIT(i);
1228
1229 return pvlan;
1230}
1231
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001232static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001233{
1234 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001235
1236 /* prevent frames from going back out of the port they came in on */
1237 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001238
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001239 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001240}
1241
Vivien Didelotf81ec902016-05-09 13:22:58 -04001242static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1243 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001244{
Vivien Didelot04bed142016-08-31 18:06:13 -04001245 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001246 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001247
Vivien Didelotfad09c72016-06-21 12:28:20 -04001248 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001249 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001250 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001251
1252 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001253 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001254}
1255
Vivien Didelot93e18d62018-05-11 17:16:35 -04001256static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1257{
1258 int err;
1259
1260 if (chip->info->ops->ieee_pri_map) {
1261 err = chip->info->ops->ieee_pri_map(chip);
1262 if (err)
1263 return err;
1264 }
1265
1266 if (chip->info->ops->ip_pri_map) {
1267 err = chip->info->ops->ip_pri_map(chip);
1268 if (err)
1269 return err;
1270 }
1271
1272 return 0;
1273}
1274
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001275static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1276{
1277 int target, port;
1278 int err;
1279
1280 if (!chip->info->global2_addr)
1281 return 0;
1282
1283 /* Initialize the routing port to the 32 possible target devices */
1284 for (target = 0; target < 32; target++) {
1285 port = 0x1f;
1286 if (target < DSA_MAX_SWITCHES)
1287 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1288 port = chip->ds->rtable[target];
1289
1290 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1291 if (err)
1292 return err;
1293 }
1294
Vivien Didelot02317e62018-05-09 11:38:49 -04001295 if (chip->info->ops->set_cascade_port) {
1296 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1297 err = chip->info->ops->set_cascade_port(chip, port);
1298 if (err)
1299 return err;
1300 }
1301
Vivien Didelot23c98912018-05-09 11:38:50 -04001302 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1303 if (err)
1304 return err;
1305
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001306 return 0;
1307}
1308
Vivien Didelotb28f8722018-04-26 21:56:44 -04001309static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1310{
1311 /* Clear all trunk masks and mapping */
1312 if (chip->info->global2_addr)
1313 return mv88e6xxx_g2_trunk_clear(chip);
1314
1315 return 0;
1316}
1317
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001318static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1319{
1320 if (chip->info->ops->rmu_disable)
1321 return chip->info->ops->rmu_disable(chip);
1322
1323 return 0;
1324}
1325
Vivien Didelot9e907d72017-07-17 13:03:43 -04001326static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1327{
1328 if (chip->info->ops->pot_clear)
1329 return chip->info->ops->pot_clear(chip);
1330
1331 return 0;
1332}
1333
Vivien Didelot51c901a2017-07-17 13:03:41 -04001334static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1335{
1336 if (chip->info->ops->mgmt_rsvd2cpu)
1337 return chip->info->ops->mgmt_rsvd2cpu(chip);
1338
1339 return 0;
1340}
1341
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001342static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1343{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001344 int err;
1345
Vivien Didelotdaefc942017-03-11 16:12:54 -05001346 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1347 if (err)
1348 return err;
1349
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001350 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1351 if (err)
1352 return err;
1353
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001354 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1355}
1356
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001357static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1358{
1359 int port;
1360 int err;
1361
1362 if (!chip->info->ops->irl_init_all)
1363 return 0;
1364
1365 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1366 /* Disable ingress rate limiting by resetting all per port
1367 * ingress rate limit resources to their initial state.
1368 */
1369 err = chip->info->ops->irl_init_all(chip, port);
1370 if (err)
1371 return err;
1372 }
1373
1374 return 0;
1375}
1376
Vivien Didelot04a69a12017-10-13 14:18:05 -04001377static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1378{
1379 if (chip->info->ops->set_switch_mac) {
1380 u8 addr[ETH_ALEN];
1381
1382 eth_random_addr(addr);
1383
1384 return chip->info->ops->set_switch_mac(chip, addr);
1385 }
1386
1387 return 0;
1388}
1389
Vivien Didelot17a15942017-03-30 17:37:09 -04001390static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1391{
1392 u16 pvlan = 0;
1393
1394 if (!mv88e6xxx_has_pvt(chip))
1395 return -EOPNOTSUPP;
1396
1397 /* Skip the local source device, which uses in-chip port VLAN */
1398 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001399 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001400
1401 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1402}
1403
Vivien Didelot81228992017-03-30 17:37:08 -04001404static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1405{
Vivien Didelot17a15942017-03-30 17:37:09 -04001406 int dev, port;
1407 int err;
1408
Vivien Didelot81228992017-03-30 17:37:08 -04001409 if (!mv88e6xxx_has_pvt(chip))
1410 return 0;
1411
1412 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1413 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1414 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001415 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1416 if (err)
1417 return err;
1418
1419 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1420 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1421 err = mv88e6xxx_pvt_map(chip, dev, port);
1422 if (err)
1423 return err;
1424 }
1425 }
1426
1427 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001428}
1429
Vivien Didelot749efcb2016-09-22 16:49:24 -04001430static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1431{
1432 struct mv88e6xxx_chip *chip = ds->priv;
1433 int err;
1434
1435 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001436 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001437 mutex_unlock(&chip->reg_lock);
1438
1439 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001440 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001441}
1442
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001443static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1444{
1445 if (!chip->info->max_vid)
1446 return 0;
1447
1448 return mv88e6xxx_g1_vtu_flush(chip);
1449}
1450
Vivien Didelotf1394b782017-05-01 14:05:22 -04001451static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1452 struct mv88e6xxx_vtu_entry *entry)
1453{
1454 if (!chip->info->ops->vtu_getnext)
1455 return -EOPNOTSUPP;
1456
1457 return chip->info->ops->vtu_getnext(chip, entry);
1458}
1459
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001460static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1461 struct mv88e6xxx_vtu_entry *entry)
1462{
1463 if (!chip->info->ops->vtu_loadpurge)
1464 return -EOPNOTSUPP;
1465
1466 return chip->info->ops->vtu_loadpurge(chip, entry);
1467}
1468
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001469static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001470{
1471 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001472 struct mv88e6xxx_vtu_entry vlan = {
1473 .vid = chip->info->max_vid,
1474 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001475 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001476
1477 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1478
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001479 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001480 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001481 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001482 if (err)
1483 return err;
1484
1485 set_bit(*fid, fid_bitmap);
1486 }
1487
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001488 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001489 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001490 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001491 if (err)
1492 return err;
1493
1494 if (!vlan.valid)
1495 break;
1496
1497 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001498 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001499
1500 /* The reset value 0x000 is used to indicate that multiple address
1501 * databases are not needed. Return the next positive available.
1502 */
1503 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001504 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001505 return -ENOSPC;
1506
1507 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001508 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001509}
1510
Vivien Didelot567aa592017-05-01 14:05:25 -04001511static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1512 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001513{
1514 int err;
1515
1516 if (!vid)
1517 return -EINVAL;
1518
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001519 entry->vid = vid - 1;
1520 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001521
Vivien Didelotf1394b782017-05-01 14:05:22 -04001522 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001523 if (err)
1524 return err;
1525
Vivien Didelot567aa592017-05-01 14:05:25 -04001526 if (entry->vid == vid && entry->valid)
1527 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001528
Vivien Didelot567aa592017-05-01 14:05:25 -04001529 if (new) {
1530 int i;
1531
1532 /* Initialize a fresh VLAN entry */
1533 memset(entry, 0, sizeof(*entry));
1534 entry->valid = true;
1535 entry->vid = vid;
1536
Vivien Didelot553a7682017-06-07 18:12:16 -04001537 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001538 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001539 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001540 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001541
1542 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001543 }
1544
Vivien Didelot567aa592017-05-01 14:05:25 -04001545 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1546 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001547}
1548
Vivien Didelotda9c3592016-02-12 12:09:40 -05001549static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1550 u16 vid_begin, u16 vid_end)
1551{
Vivien Didelot04bed142016-08-31 18:06:13 -04001552 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001553 struct mv88e6xxx_vtu_entry vlan = {
1554 .vid = vid_begin - 1,
1555 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001556 int i, err;
1557
Andrew Lunndb06ae412017-09-25 23:32:20 +02001558 /* DSA and CPU ports have to be members of multiple vlans */
1559 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1560 return 0;
1561
Vivien Didelotda9c3592016-02-12 12:09:40 -05001562 if (!vid_begin)
1563 return -EOPNOTSUPP;
1564
Vivien Didelotfad09c72016-06-21 12:28:20 -04001565 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001566
Vivien Didelotda9c3592016-02-12 12:09:40 -05001567 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001568 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001569 if (err)
1570 goto unlock;
1571
1572 if (!vlan.valid)
1573 break;
1574
1575 if (vlan.vid > vid_end)
1576 break;
1577
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001578 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001579 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1580 continue;
1581
Andrew Lunncd886462017-11-09 22:29:53 +01001582 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001583 continue;
1584
Vivien Didelotbd00e052017-05-01 14:05:11 -04001585 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001586 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001587 continue;
1588
Vivien Didelotc8652c82017-10-16 11:12:19 -04001589 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001590 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001591 break; /* same bridge, check next VLAN */
1592
Vivien Didelotc8652c82017-10-16 11:12:19 -04001593 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001594 continue;
1595
Andrew Lunn743fcc22017-11-09 22:29:54 +01001596 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1597 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001598 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001599 err = -EOPNOTSUPP;
1600 goto unlock;
1601 }
1602 } while (vlan.vid < vid_end);
1603
1604unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001605 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001606
1607 return err;
1608}
1609
Vivien Didelotf81ec902016-05-09 13:22:58 -04001610static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1611 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001612{
Vivien Didelot04bed142016-08-31 18:06:13 -04001613 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001614 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1615 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001616 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001617
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001618 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001619 return -EOPNOTSUPP;
1620
Vivien Didelotfad09c72016-06-21 12:28:20 -04001621 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001622 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001623 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001624
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001625 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001626}
1627
Vivien Didelot57d32312016-06-20 13:13:58 -04001628static int
1629mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001630 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001631{
Vivien Didelot04bed142016-08-31 18:06:13 -04001632 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001633 int err;
1634
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001635 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001636 return -EOPNOTSUPP;
1637
Vivien Didelotda9c3592016-02-12 12:09:40 -05001638 /* If the requested port doesn't belong to the same bridge as the VLAN
1639 * members, do not support it (yet) and fallback to software VLAN.
1640 */
1641 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1642 vlan->vid_end);
1643 if (err)
1644 return err;
1645
Vivien Didelot76e398a2015-11-01 12:33:55 -05001646 /* We don't need any dynamic resource from the kernel (yet),
1647 * so skip the prepare phase.
1648 */
1649 return 0;
1650}
1651
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001652static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1653 const unsigned char *addr, u16 vid,
1654 u8 state)
1655{
1656 struct mv88e6xxx_vtu_entry vlan;
1657 struct mv88e6xxx_atu_entry entry;
1658 int err;
1659
1660 /* Null VLAN ID corresponds to the port private database */
1661 if (vid == 0)
1662 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1663 else
1664 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1665 if (err)
1666 return err;
1667
1668 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1669 ether_addr_copy(entry.mac, addr);
1670 eth_addr_dec(entry.mac);
1671
1672 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1673 if (err)
1674 return err;
1675
1676 /* Initialize a fresh ATU entry if it isn't found */
1677 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1678 !ether_addr_equal(entry.mac, addr)) {
1679 memset(&entry, 0, sizeof(entry));
1680 ether_addr_copy(entry.mac, addr);
1681 }
1682
1683 /* Purge the ATU entry only if no port is using it anymore */
1684 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1685 entry.portvec &= ~BIT(port);
1686 if (!entry.portvec)
1687 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1688 } else {
1689 entry.portvec |= BIT(port);
1690 entry.state = state;
1691 }
1692
1693 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1694}
1695
Andrew Lunn87fa8862017-11-09 22:29:56 +01001696static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1697 u16 vid)
1698{
1699 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1700 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1701
1702 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1703}
1704
1705static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1706{
1707 int port;
1708 int err;
1709
1710 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1711 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1712 if (err)
1713 return err;
1714 }
1715
1716 return 0;
1717}
1718
Vivien Didelotfad09c72016-06-21 12:28:20 -04001719static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001720 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001721{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001722 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001723 int err;
1724
Vivien Didelot567aa592017-05-01 14:05:25 -04001725 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001726 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001727 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001728
Vivien Didelotc91498e2017-06-07 18:12:13 -04001729 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001730
Andrew Lunn87fa8862017-11-09 22:29:56 +01001731 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1732 if (err)
1733 return err;
1734
1735 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001736}
1737
Vivien Didelotf81ec902016-05-09 13:22:58 -04001738static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001739 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001740{
Vivien Didelot04bed142016-08-31 18:06:13 -04001741 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001742 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1743 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001744 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001745 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001746
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001747 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001748 return;
1749
Vivien Didelotc91498e2017-06-07 18:12:13 -04001750 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001751 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001752 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001753 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001754 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001755 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001756
Vivien Didelotfad09c72016-06-21 12:28:20 -04001757 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001758
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001759 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001760 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001761 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1762 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001763
Vivien Didelot77064f32016-11-04 03:23:30 +01001764 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001765 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1766 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001767
Vivien Didelotfad09c72016-06-21 12:28:20 -04001768 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001769}
1770
Vivien Didelotfad09c72016-06-21 12:28:20 -04001771static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001772 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001773{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001774 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001775 int i, err;
1776
Vivien Didelot567aa592017-05-01 14:05:25 -04001777 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001778 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001779 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001780
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001781 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001782 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001783 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001784
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001785 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001786
1787 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001788 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001789 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001790 if (vlan.member[i] !=
1791 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001792 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001793 break;
1794 }
1795 }
1796
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001797 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001798 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001799 return err;
1800
Vivien Didelote606ca32017-03-11 16:12:55 -05001801 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001802}
1803
Vivien Didelotf81ec902016-05-09 13:22:58 -04001804static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1805 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001806{
Vivien Didelot04bed142016-08-31 18:06:13 -04001807 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001808 u16 pvid, vid;
1809 int err = 0;
1810
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001811 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001812 return -EOPNOTSUPP;
1813
Vivien Didelotfad09c72016-06-21 12:28:20 -04001814 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001815
Vivien Didelot77064f32016-11-04 03:23:30 +01001816 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001817 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001818 goto unlock;
1819
Vivien Didelot76e398a2015-11-01 12:33:55 -05001820 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001821 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001822 if (err)
1823 goto unlock;
1824
1825 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001826 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001827 if (err)
1828 goto unlock;
1829 }
1830 }
1831
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001832unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001833 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001834
1835 return err;
1836}
1837
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001838static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1839 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001840{
Vivien Didelot04bed142016-08-31 18:06:13 -04001841 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001842 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001843
Vivien Didelotfad09c72016-06-21 12:28:20 -04001844 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001845 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1846 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001847 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001848
1849 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001850}
1851
Vivien Didelotf81ec902016-05-09 13:22:58 -04001852static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001853 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001854{
Vivien Didelot04bed142016-08-31 18:06:13 -04001855 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001856 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001857
Vivien Didelotfad09c72016-06-21 12:28:20 -04001858 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001859 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001860 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001861 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001862
Vivien Didelot83dabd12016-08-31 11:50:04 -04001863 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001864}
1865
Vivien Didelot83dabd12016-08-31 11:50:04 -04001866static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1867 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001868 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001869{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001870 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001871 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001872 int err;
1873
Vivien Didelot27c0e602017-06-15 12:14:01 -04001874 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001875 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001876
1877 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001878 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001879 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001880 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001881 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001882 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001883
Vivien Didelot27c0e602017-06-15 12:14:01 -04001884 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001885 break;
1886
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001887 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001888 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001889
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001890 if (!is_unicast_ether_addr(addr.mac))
1891 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001892
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001893 is_static = (addr.state ==
1894 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1895 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001896 if (err)
1897 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001898 } while (!is_broadcast_ether_addr(addr.mac));
1899
1900 return err;
1901}
1902
Vivien Didelot83dabd12016-08-31 11:50:04 -04001903static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001904 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001905{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001906 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001907 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001908 };
1909 u16 fid;
1910 int err;
1911
1912 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001913 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001914 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001915 mutex_unlock(&chip->reg_lock);
1916
Vivien Didelot83dabd12016-08-31 11:50:04 -04001917 if (err)
1918 return err;
1919
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001920 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001921 if (err)
1922 return err;
1923
1924 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001925 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001926 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001927 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001928 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001929 if (err)
1930 return err;
1931
1932 if (!vlan.valid)
1933 break;
1934
1935 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001936 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001937 if (err)
1938 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001939 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001940
1941 return err;
1942}
1943
Vivien Didelotf81ec902016-05-09 13:22:58 -04001944static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001945 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001946{
Vivien Didelot04bed142016-08-31 18:06:13 -04001947 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001948
Andrew Lunna61e5402018-02-15 14:38:35 +01001949 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001950}
1951
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001952static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1953 struct net_device *br)
1954{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001955 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001956 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001957 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001958 int err;
1959
1960 /* Remap the Port VLAN of each local bridge group member */
1961 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1962 if (chip->ds->ports[port].bridge_dev == br) {
1963 err = mv88e6xxx_port_vlan_map(chip, port);
1964 if (err)
1965 return err;
1966 }
1967 }
1968
Vivien Didelote96a6e02017-03-30 17:37:13 -04001969 if (!mv88e6xxx_has_pvt(chip))
1970 return 0;
1971
1972 /* Remap the Port VLAN of each cross-chip bridge group member */
1973 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1974 ds = chip->ds->dst->ds[dev];
1975 if (!ds)
1976 break;
1977
1978 for (port = 0; port < ds->num_ports; ++port) {
1979 if (ds->ports[port].bridge_dev == br) {
1980 err = mv88e6xxx_pvt_map(chip, dev, port);
1981 if (err)
1982 return err;
1983 }
1984 }
1985 }
1986
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001987 return 0;
1988}
1989
Vivien Didelotf81ec902016-05-09 13:22:58 -04001990static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001991 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001992{
Vivien Didelot04bed142016-08-31 18:06:13 -04001993 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001994 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001995
Vivien Didelotfad09c72016-06-21 12:28:20 -04001996 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001997 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001998 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001999
Vivien Didelot466dfa02016-02-26 13:16:05 -05002000 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002001}
2002
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002003static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2004 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002005{
Vivien Didelot04bed142016-08-31 18:06:13 -04002006 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002007
Vivien Didelotfad09c72016-06-21 12:28:20 -04002008 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002009 if (mv88e6xxx_bridge_map(chip, br) ||
2010 mv88e6xxx_port_vlan_map(chip, port))
2011 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04002012 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002013}
2014
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002015static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2016 int port, struct net_device *br)
2017{
2018 struct mv88e6xxx_chip *chip = ds->priv;
2019 int err;
2020
2021 if (!mv88e6xxx_has_pvt(chip))
2022 return 0;
2023
2024 mutex_lock(&chip->reg_lock);
2025 err = mv88e6xxx_pvt_map(chip, dev, port);
2026 mutex_unlock(&chip->reg_lock);
2027
2028 return err;
2029}
2030
2031static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2032 int port, struct net_device *br)
2033{
2034 struct mv88e6xxx_chip *chip = ds->priv;
2035
2036 if (!mv88e6xxx_has_pvt(chip))
2037 return;
2038
2039 mutex_lock(&chip->reg_lock);
2040 if (mv88e6xxx_pvt_map(chip, dev, port))
2041 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2042 mutex_unlock(&chip->reg_lock);
2043}
2044
Vivien Didelot17e708b2016-12-05 17:30:27 -05002045static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2046{
2047 if (chip->info->ops->reset)
2048 return chip->info->ops->reset(chip);
2049
2050 return 0;
2051}
2052
Vivien Didelot309eca62016-12-05 17:30:26 -05002053static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2054{
2055 struct gpio_desc *gpiod = chip->reset;
2056
2057 /* If there is a GPIO connected to the reset pin, toggle it */
2058 if (gpiod) {
2059 gpiod_set_value_cansleep(gpiod, 1);
2060 usleep_range(10000, 20000);
2061 gpiod_set_value_cansleep(gpiod, 0);
2062 usleep_range(10000, 20000);
2063 }
2064}
2065
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002066static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2067{
2068 int i, err;
2069
2070 /* Set all ports to the Disabled state */
2071 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002072 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002073 if (err)
2074 return err;
2075 }
2076
2077 /* Wait for transmit queues to drain,
2078 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2079 */
2080 usleep_range(2000, 4000);
2081
2082 return 0;
2083}
2084
Vivien Didelotfad09c72016-06-21 12:28:20 -04002085static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002086{
Vivien Didelota935c052016-09-29 12:21:53 -04002087 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002088
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002089 err = mv88e6xxx_disable_ports(chip);
2090 if (err)
2091 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002092
Vivien Didelot309eca62016-12-05 17:30:26 -05002093 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002094
Vivien Didelot17e708b2016-12-05 17:30:27 -05002095 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002096}
2097
Vivien Didelot43145572017-03-11 16:12:59 -05002098static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002099 enum mv88e6xxx_frame_mode frame,
2100 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002101{
2102 int err;
2103
Vivien Didelot43145572017-03-11 16:12:59 -05002104 if (!chip->info->ops->port_set_frame_mode)
2105 return -EOPNOTSUPP;
2106
2107 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002108 if (err)
2109 return err;
2110
Vivien Didelot43145572017-03-11 16:12:59 -05002111 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2112 if (err)
2113 return err;
2114
2115 if (chip->info->ops->port_set_ether_type)
2116 return chip->info->ops->port_set_ether_type(chip, port, etype);
2117
2118 return 0;
2119}
2120
2121static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2122{
2123 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002124 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002125 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002126}
2127
2128static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2129{
2130 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002131 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002132 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002133}
2134
2135static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2136{
2137 return mv88e6xxx_set_port_mode(chip, port,
2138 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002139 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2140 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002141}
2142
2143static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2144{
2145 if (dsa_is_dsa_port(chip->ds, port))
2146 return mv88e6xxx_set_port_mode_dsa(chip, port);
2147
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002148 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002149 return mv88e6xxx_set_port_mode_normal(chip, port);
2150
2151 /* Setup CPU port mode depending on its supported tag format */
2152 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2153 return mv88e6xxx_set_port_mode_dsa(chip, port);
2154
2155 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2156 return mv88e6xxx_set_port_mode_edsa(chip, port);
2157
2158 return -EINVAL;
2159}
2160
Vivien Didelotea698f42017-03-11 16:12:50 -05002161static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2162{
2163 bool message = dsa_is_dsa_port(chip->ds, port);
2164
2165 return mv88e6xxx_port_set_message_port(chip, port, message);
2166}
2167
Vivien Didelot601aeed2017-03-11 16:13:00 -05002168static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2169{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002170 struct dsa_switch *ds = chip->ds;
2171 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002172
2173 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002174 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002175 if (chip->info->ops->port_set_egress_floods)
2176 return chip->info->ops->port_set_egress_floods(chip, port,
2177 flood, flood);
2178
2179 return 0;
2180}
2181
Andrew Lunn6d917822017-05-26 01:03:21 +02002182static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2183 bool on)
2184{
Vivien Didelot523a8902017-05-26 18:02:42 -04002185 if (chip->info->ops->serdes_power)
2186 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002187
Vivien Didelot523a8902017-05-26 18:02:42 -04002188 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002189}
2190
Vivien Didelotfa371c82017-12-05 15:34:10 -05002191static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2192{
2193 struct dsa_switch *ds = chip->ds;
2194 int upstream_port;
2195 int err;
2196
Vivien Didelot07073c72017-12-05 15:34:13 -05002197 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002198 if (chip->info->ops->port_set_upstream_port) {
2199 err = chip->info->ops->port_set_upstream_port(chip, port,
2200 upstream_port);
2201 if (err)
2202 return err;
2203 }
2204
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002205 if (port == upstream_port) {
2206 if (chip->info->ops->set_cpu_port) {
2207 err = chip->info->ops->set_cpu_port(chip,
2208 upstream_port);
2209 if (err)
2210 return err;
2211 }
2212
2213 if (chip->info->ops->set_egress_port) {
2214 err = chip->info->ops->set_egress_port(chip,
2215 upstream_port);
2216 if (err)
2217 return err;
2218 }
2219 }
2220
Vivien Didelotfa371c82017-12-05 15:34:10 -05002221 return 0;
2222}
2223
Vivien Didelotfad09c72016-06-21 12:28:20 -04002224static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002225{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002226 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002227 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002228 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002229
Andrew Lunn7b898462018-08-09 15:38:47 +02002230 chip->ports[port].chip = chip;
2231 chip->ports[port].port = port;
2232
Vivien Didelotd78343d2016-11-04 03:23:36 +01002233 /* MAC Forcing register: don't force link, speed, duplex or flow control
2234 * state to any particular values on physical ports, but force the CPU
2235 * port and all DSA ports to their maximum bandwidth and full duplex.
2236 */
2237 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2238 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2239 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002240 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002241 PHY_INTERFACE_MODE_NA);
2242 else
2243 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2244 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002245 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002246 PHY_INTERFACE_MODE_NA);
2247 if (err)
2248 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002249
2250 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2251 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2252 * tunneling, determine priority by looking at 802.1p and IP
2253 * priority fields (IP prio has precedence), and set STP state
2254 * to Forwarding.
2255 *
2256 * If this is the CPU link, use DSA or EDSA tagging depending
2257 * on which tagging mode was configured.
2258 *
2259 * If this is a link to another switch, use DSA tagging mode.
2260 *
2261 * If this is the upstream port for this switch, enable
2262 * forwarding of unknown unicasts and multicasts.
2263 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002264 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2265 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2266 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2267 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002268 if (err)
2269 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002270
Vivien Didelot601aeed2017-03-11 16:13:00 -05002271 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002272 if (err)
2273 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002274
Vivien Didelot601aeed2017-03-11 16:13:00 -05002275 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002276 if (err)
2277 return err;
2278
Andrew Lunn04aca992017-05-26 01:03:24 +02002279 /* Enable the SERDES interface for DSA and CPU ports. Normal
2280 * ports SERDES are enabled when the port is enabled, thus
2281 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002282 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002283 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2284 err = mv88e6xxx_serdes_power(chip, port, true);
2285 if (err)
2286 return err;
2287 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002288
Vivien Didelot8efdda42015-08-13 12:52:23 -04002289 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002290 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002291 * untagged frames on this port, do a destination address lookup on all
2292 * received packets as usual, disable ARP mirroring and don't send a
2293 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002294 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002295 err = mv88e6xxx_port_set_map_da(chip, port);
2296 if (err)
2297 return err;
2298
Vivien Didelotfa371c82017-12-05 15:34:10 -05002299 err = mv88e6xxx_setup_upstream_port(chip, port);
2300 if (err)
2301 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002302
Andrew Lunna23b2962017-02-04 20:15:28 +01002303 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002304 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002305 if (err)
2306 return err;
2307
Vivien Didelotcd782652017-06-08 18:34:13 -04002308 if (chip->info->ops->port_set_jumbo_size) {
2309 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002310 if (err)
2311 return err;
2312 }
2313
Andrew Lunn54d792f2015-05-06 01:09:47 +02002314 /* Port Association Vector: when learning source addresses
2315 * of packets, add the address to the address database using
2316 * a port bitmap that has only the bit for this port set and
2317 * the other bits clear.
2318 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002319 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002320 /* Disable learning for CPU port */
2321 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002322 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002323
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002324 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2325 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002326 if (err)
2327 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002328
2329 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002330 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2331 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002332 if (err)
2333 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002334
Vivien Didelot08984322017-06-08 18:34:12 -04002335 if (chip->info->ops->port_pause_limit) {
2336 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002337 if (err)
2338 return err;
2339 }
2340
Vivien Didelotc8c94892017-03-11 16:13:01 -05002341 if (chip->info->ops->port_disable_learn_limit) {
2342 err = chip->info->ops->port_disable_learn_limit(chip, port);
2343 if (err)
2344 return err;
2345 }
2346
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002347 if (chip->info->ops->port_disable_pri_override) {
2348 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002349 if (err)
2350 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002351 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002352
Andrew Lunnef0a7312016-12-03 04:35:16 +01002353 if (chip->info->ops->port_tag_remap) {
2354 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002355 if (err)
2356 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002357 }
2358
Andrew Lunnef70b112016-12-03 04:45:18 +01002359 if (chip->info->ops->port_egress_rate_limiting) {
2360 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002361 if (err)
2362 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002363 }
2364
Vivien Didelotea698f42017-03-11 16:12:50 -05002365 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002366 if (err)
2367 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002368
Vivien Didelot207afda2016-04-14 14:42:09 -04002369 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002370 * database, and allow bidirectional communication between the
2371 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002372 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002373 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002374 if (err)
2375 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002376
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002377 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002378 if (err)
2379 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002380
2381 /* Default VLAN ID and priority: don't set a default VLAN
2382 * ID, and set the default packet priority to zero.
2383 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002384 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002385}
2386
Andrew Lunn04aca992017-05-26 01:03:24 +02002387static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2388 struct phy_device *phydev)
2389{
2390 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002391 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002392
2393 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002394
Vivien Didelot523a8902017-05-26 18:02:42 -04002395 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002396
2397 if (!err && chip->info->ops->serdes_irq_setup)
2398 err = chip->info->ops->serdes_irq_setup(chip, port);
2399
Andrew Lunn04aca992017-05-26 01:03:24 +02002400 mutex_unlock(&chip->reg_lock);
2401
2402 return err;
2403}
2404
Andrew Lunn75104db2019-02-24 20:44:43 +01002405static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002406{
2407 struct mv88e6xxx_chip *chip = ds->priv;
2408
2409 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002410
2411 if (chip->info->ops->serdes_irq_free)
2412 chip->info->ops->serdes_irq_free(chip, port);
2413
Vivien Didelot523a8902017-05-26 18:02:42 -04002414 if (mv88e6xxx_serdes_power(chip, port, false))
2415 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002416
Andrew Lunn04aca992017-05-26 01:03:24 +02002417 mutex_unlock(&chip->reg_lock);
2418}
2419
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002420static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2421 unsigned int ageing_time)
2422{
Vivien Didelot04bed142016-08-31 18:06:13 -04002423 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002424 int err;
2425
2426 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002427 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002428 mutex_unlock(&chip->reg_lock);
2429
2430 return err;
2431}
2432
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002433static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002434{
2435 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002436
Andrew Lunnde2273872016-11-21 23:27:01 +01002437 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002438 if (chip->info->ops->stats_set_histogram) {
2439 err = chip->info->ops->stats_set_histogram(chip);
2440 if (err)
2441 return err;
2442 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002443
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002444 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002445}
2446
Andrew Lunnea890982019-01-09 00:24:03 +01002447/* The mv88e6390 has some hidden registers used for debug and
2448 * development. The errata also makes use of them.
2449 */
2450static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2451 int reg, u16 val)
2452{
2453 u16 ctrl;
2454 int err;
2455
2456 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2457 PORT_RESERVED_1A, val);
2458 if (err)
2459 return err;
2460
2461 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2462 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2463 reg;
2464
2465 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2466 PORT_RESERVED_1A, ctrl);
2467}
2468
2469static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2470{
2471 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2472 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2473}
2474
2475
2476static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2477 int reg, u16 *val)
2478{
2479 u16 ctrl;
2480 int err;
2481
2482 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2483 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2484 reg;
2485
2486 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2487 PORT_RESERVED_1A, ctrl);
2488 if (err)
2489 return err;
2490
2491 err = mv88e6390_hidden_wait(chip);
2492 if (err)
2493 return err;
2494
2495 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2496 PORT_RESERVED_1A, val);
2497}
2498
2499/* Check if the errata has already been applied. */
2500static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2501{
2502 int port;
2503 int err;
2504 u16 val;
2505
2506 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2507 err = mv88e6390_hidden_read(chip, port, 0, &val);
2508 if (err) {
2509 dev_err(chip->dev,
2510 "Error reading hidden register: %d\n", err);
2511 return false;
2512 }
2513 if (val != 0x01c0)
2514 return false;
2515 }
2516
2517 return true;
2518}
2519
2520/* The 6390 copper ports have an errata which require poking magic
2521 * values into undocumented hidden registers and then performing a
2522 * software reset.
2523 */
2524static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2525{
2526 int port;
2527 int err;
2528
2529 if (mv88e6390_setup_errata_applied(chip))
2530 return 0;
2531
2532 /* Set the ports into blocking mode */
2533 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2534 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2535 if (err)
2536 return err;
2537 }
2538
2539 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2540 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2541 if (err)
2542 return err;
2543 }
2544
2545 return mv88e6xxx_software_reset(chip);
2546}
2547
Vivien Didelotf81ec902016-05-09 13:22:58 -04002548static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002549{
Vivien Didelot04bed142016-08-31 18:06:13 -04002550 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002551 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002552 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002553 int i;
2554
Vivien Didelotfad09c72016-06-21 12:28:20 -04002555 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002556 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002557
Vivien Didelotfad09c72016-06-21 12:28:20 -04002558 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002559
Andrew Lunnea890982019-01-09 00:24:03 +01002560 if (chip->info->ops->setup_errata) {
2561 err = chip->info->ops->setup_errata(chip);
2562 if (err)
2563 goto unlock;
2564 }
2565
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002566 /* Cache the cmode of each port. */
2567 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2568 if (chip->info->ops->port_get_cmode) {
2569 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2570 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002571 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002572
2573 chip->ports[i].cmode = cmode;
2574 }
2575 }
2576
Vivien Didelot97299342016-07-18 20:45:30 -04002577 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002578 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002579 if (dsa_is_unused_port(ds, i))
2580 continue;
2581
Vivien Didelot97299342016-07-18 20:45:30 -04002582 err = mv88e6xxx_setup_port(chip, i);
2583 if (err)
2584 goto unlock;
2585 }
2586
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002587 err = mv88e6xxx_irl_setup(chip);
2588 if (err)
2589 goto unlock;
2590
Vivien Didelot04a69a12017-10-13 14:18:05 -04002591 err = mv88e6xxx_mac_setup(chip);
2592 if (err)
2593 goto unlock;
2594
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002595 err = mv88e6xxx_phy_setup(chip);
2596 if (err)
2597 goto unlock;
2598
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002599 err = mv88e6xxx_vtu_setup(chip);
2600 if (err)
2601 goto unlock;
2602
Vivien Didelot81228992017-03-30 17:37:08 -04002603 err = mv88e6xxx_pvt_setup(chip);
2604 if (err)
2605 goto unlock;
2606
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002607 err = mv88e6xxx_atu_setup(chip);
2608 if (err)
2609 goto unlock;
2610
Andrew Lunn87fa8862017-11-09 22:29:56 +01002611 err = mv88e6xxx_broadcast_setup(chip, 0);
2612 if (err)
2613 goto unlock;
2614
Vivien Didelot9e907d72017-07-17 13:03:43 -04002615 err = mv88e6xxx_pot_setup(chip);
2616 if (err)
2617 goto unlock;
2618
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002619 err = mv88e6xxx_rmu_setup(chip);
2620 if (err)
2621 goto unlock;
2622
Vivien Didelot51c901a2017-07-17 13:03:41 -04002623 err = mv88e6xxx_rsvd2cpu_setup(chip);
2624 if (err)
2625 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002626
Vivien Didelotb28f8722018-04-26 21:56:44 -04002627 err = mv88e6xxx_trunk_setup(chip);
2628 if (err)
2629 goto unlock;
2630
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002631 err = mv88e6xxx_devmap_setup(chip);
2632 if (err)
2633 goto unlock;
2634
Vivien Didelot93e18d62018-05-11 17:16:35 -04002635 err = mv88e6xxx_pri_setup(chip);
2636 if (err)
2637 goto unlock;
2638
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002639 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002640 if (chip->info->ptp_support) {
2641 err = mv88e6xxx_ptp_setup(chip);
2642 if (err)
2643 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002644
2645 err = mv88e6xxx_hwtstamp_setup(chip);
2646 if (err)
2647 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002648 }
2649
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002650 err = mv88e6xxx_stats_setup(chip);
2651 if (err)
2652 goto unlock;
2653
Vivien Didelot6b17e862015-08-13 12:52:18 -04002654unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002655 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002656
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002657 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002658}
2659
Vivien Didelote57e5e72016-08-15 17:19:00 -04002660static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002661{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002662 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2663 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002664 u16 val;
2665 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002666
Andrew Lunnee26a222017-01-24 14:53:48 +01002667 if (!chip->info->ops->phy_read)
2668 return -EOPNOTSUPP;
2669
Vivien Didelotfad09c72016-06-21 12:28:20 -04002670 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002671 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002672 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002673
Andrew Lunnda9f3302017-02-01 03:40:05 +01002674 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002675 /* Some internal PHYs don't have a model number. */
2676 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2677 /* Then there is the 6165 family. It gets is
2678 * PHYs correct. But it can also have two
2679 * SERDES interfaces in the PHY address
2680 * space. And these don't have a model
2681 * number. But they are not PHYs, so we don't
2682 * want to give them something a PHY driver
2683 * will recognise.
2684 *
2685 * Use the mv88e6390 family model number
2686 * instead, for anything which really could be
2687 * a PHY,
2688 */
2689 if (!(val & 0x3f0))
2690 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002691 }
2692
Vivien Didelote57e5e72016-08-15 17:19:00 -04002693 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002694}
2695
Vivien Didelote57e5e72016-08-15 17:19:00 -04002696static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002697{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002698 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2699 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002700 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002701
Andrew Lunnee26a222017-01-24 14:53:48 +01002702 if (!chip->info->ops->phy_write)
2703 return -EOPNOTSUPP;
2704
Vivien Didelotfad09c72016-06-21 12:28:20 -04002705 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002706 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002707 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002708
2709 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002710}
2711
Vivien Didelotfad09c72016-06-21 12:28:20 -04002712static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002713 struct device_node *np,
2714 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002715{
2716 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002717 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002718 struct mii_bus *bus;
2719 int err;
2720
Andrew Lunn2510bab2018-02-22 01:51:49 +01002721 if (external) {
2722 mutex_lock(&chip->reg_lock);
2723 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2724 mutex_unlock(&chip->reg_lock);
2725
2726 if (err)
2727 return err;
2728 }
2729
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002730 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002731 if (!bus)
2732 return -ENOMEM;
2733
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002734 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002735 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002736 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002737 INIT_LIST_HEAD(&mdio_bus->list);
2738 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002739
Andrew Lunnb516d452016-06-04 21:17:06 +02002740 if (np) {
2741 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002742 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002743 } else {
2744 bus->name = "mv88e6xxx SMI";
2745 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2746 }
2747
2748 bus->read = mv88e6xxx_mdio_read;
2749 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002750 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002751
Andrew Lunn6f882842018-03-17 20:32:05 +01002752 if (!external) {
2753 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2754 if (err)
2755 return err;
2756 }
2757
Florian Fainelli00e798c2018-05-15 16:56:19 -07002758 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002759 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002760 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002761 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002762 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002763 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002764
2765 if (external)
2766 list_add_tail(&mdio_bus->list, &chip->mdios);
2767 else
2768 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002769
2770 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002771}
2772
Andrew Lunna3c53be52017-01-24 14:53:50 +01002773static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2774 { .compatible = "marvell,mv88e6xxx-mdio-external",
2775 .data = (void *)true },
2776 { },
2777};
2778
Andrew Lunn3126aee2017-12-07 01:05:57 +01002779static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2780
2781{
2782 struct mv88e6xxx_mdio_bus *mdio_bus;
2783 struct mii_bus *bus;
2784
2785 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2786 bus = mdio_bus->bus;
2787
Andrew Lunn6f882842018-03-17 20:32:05 +01002788 if (!mdio_bus->external)
2789 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2790
Andrew Lunn3126aee2017-12-07 01:05:57 +01002791 mdiobus_unregister(bus);
2792 }
2793}
2794
Andrew Lunna3c53be52017-01-24 14:53:50 +01002795static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2796 struct device_node *np)
2797{
2798 const struct of_device_id *match;
2799 struct device_node *child;
2800 int err;
2801
2802 /* Always register one mdio bus for the internal/default mdio
2803 * bus. This maybe represented in the device tree, but is
2804 * optional.
2805 */
2806 child = of_get_child_by_name(np, "mdio");
2807 err = mv88e6xxx_mdio_register(chip, child, false);
2808 if (err)
2809 return err;
2810
2811 /* Walk the device tree, and see if there are any other nodes
2812 * which say they are compatible with the external mdio
2813 * bus.
2814 */
2815 for_each_available_child_of_node(np, child) {
2816 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2817 if (match) {
2818 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002819 if (err) {
2820 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002821 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002822 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002823 }
2824 }
2825
2826 return 0;
2827}
2828
Vivien Didelot855b1932016-07-20 18:18:35 -04002829static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2830{
Vivien Didelot04bed142016-08-31 18:06:13 -04002831 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002832
2833 return chip->eeprom_len;
2834}
2835
Vivien Didelot855b1932016-07-20 18:18:35 -04002836static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2837 struct ethtool_eeprom *eeprom, u8 *data)
2838{
Vivien Didelot04bed142016-08-31 18:06:13 -04002839 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002840 int err;
2841
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002842 if (!chip->info->ops->get_eeprom)
2843 return -EOPNOTSUPP;
2844
Vivien Didelot855b1932016-07-20 18:18:35 -04002845 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002846 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002847 mutex_unlock(&chip->reg_lock);
2848
2849 if (err)
2850 return err;
2851
2852 eeprom->magic = 0xc3ec4951;
2853
2854 return 0;
2855}
2856
Vivien Didelot855b1932016-07-20 18:18:35 -04002857static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2858 struct ethtool_eeprom *eeprom, u8 *data)
2859{
Vivien Didelot04bed142016-08-31 18:06:13 -04002860 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002861 int err;
2862
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002863 if (!chip->info->ops->set_eeprom)
2864 return -EOPNOTSUPP;
2865
Vivien Didelot855b1932016-07-20 18:18:35 -04002866 if (eeprom->magic != 0xc3ec4951)
2867 return -EINVAL;
2868
2869 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002870 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002871 mutex_unlock(&chip->reg_lock);
2872
2873 return err;
2874}
2875
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002876static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002877 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002878 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2879 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002880 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002881 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002882 .phy_read = mv88e6185_phy_ppu_read,
2883 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002884 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002885 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002886 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002887 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002888 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002889 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002890 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002891 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002892 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002893 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002894 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002895 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002896 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002897 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002898 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002899 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2900 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002901 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002902 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2903 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002904 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002905 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002906 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002907 .ppu_enable = mv88e6185_g1_ppu_enable,
2908 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002909 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002910 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002911 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002912 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002913 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002914};
2915
2916static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002917 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002918 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2919 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002920 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002921 .phy_read = mv88e6185_phy_ppu_read,
2922 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002923 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002924 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002925 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002926 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002927 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002928 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002929 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002930 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002931 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002932 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002933 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2934 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002935 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002936 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002937 .ppu_enable = mv88e6185_g1_ppu_enable,
2938 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002939 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002940 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002941 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002942 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002943};
2944
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002945static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002946 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002947 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2948 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002949 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002950 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2951 .phy_read = mv88e6xxx_g2_smi_phy_read,
2952 .phy_write = mv88e6xxx_g2_smi_phy_write,
2953 .port_set_link = mv88e6xxx_port_set_link,
2954 .port_set_duplex = mv88e6xxx_port_set_duplex,
2955 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002956 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002957 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002958 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002959 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002960 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002961 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002962 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002963 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002964 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002965 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002966 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002967 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002968 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002969 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2970 .stats_get_strings = mv88e6095_stats_get_strings,
2971 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002972 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2973 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002974 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002975 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002976 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002977 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002978 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002979 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002980 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002981 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002982};
2983
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002984static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002985 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002986 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2987 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002988 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002989 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002990 .phy_read = mv88e6xxx_g2_smi_phy_read,
2991 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002992 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002993 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002994 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002995 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002996 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002997 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002998 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002999 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003000 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003001 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003002 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003003 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3004 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003005 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003006 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3007 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003008 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003009 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003010 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003011 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003012 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003013 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003014 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003015};
3016
3017static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003018 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003019 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3020 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003021 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003022 .phy_read = mv88e6185_phy_ppu_read,
3023 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003024 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003025 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003026 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003027 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003028 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003029 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003030 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003031 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003032 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003033 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003034 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003035 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003036 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003037 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003038 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003039 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003040 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3041 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003042 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003043 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3044 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003045 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003046 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003047 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003048 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003049 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003050 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003051 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003052 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003053 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003054};
3055
Vivien Didelot990e27b2017-03-28 13:50:32 -04003056static const struct mv88e6xxx_ops mv88e6141_ops = {
3057 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003058 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3059 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003060 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003061 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3062 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3063 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3064 .phy_read = mv88e6xxx_g2_smi_phy_read,
3065 .phy_write = mv88e6xxx_g2_smi_phy_write,
3066 .port_set_link = mv88e6xxx_port_set_link,
3067 .port_set_duplex = mv88e6xxx_port_set_duplex,
3068 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003069 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003070 .port_tag_remap = mv88e6095_port_tag_remap,
3071 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3072 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3073 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003074 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003075 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003076 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003077 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3078 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003079 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003080 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003081 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003082 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003083 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3084 .stats_get_strings = mv88e6320_stats_get_strings,
3085 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003086 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3087 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003088 .watchdog_ops = &mv88e6390_watchdog_ops,
3089 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003090 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003091 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003092 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003093 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003094 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003095 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003096 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003097};
3098
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003099static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003100 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003101 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3102 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003103 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003104 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003105 .phy_read = mv88e6xxx_g2_smi_phy_read,
3106 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003107 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003108 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003109 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003110 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003111 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003112 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003113 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003114 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003115 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003116 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003117 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003118 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003119 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003120 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003121 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003122 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003123 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3124 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003125 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003126 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3127 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003128 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003129 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003130 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003131 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003132 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003133 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003134 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003135 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003136 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003137};
3138
3139static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003140 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003141 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3142 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003143 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003144 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003145 .phy_read = mv88e6165_phy_read,
3146 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003147 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003148 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003149 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003150 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003151 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003152 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003153 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003154 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003155 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003156 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3157 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003158 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003159 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3160 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003161 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003162 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003163 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003164 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003165 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003166 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003167 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003168 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003169 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003170};
3171
3172static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003173 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003174 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3175 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003176 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003177 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003178 .phy_read = mv88e6xxx_g2_smi_phy_read,
3179 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003180 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003181 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003182 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003183 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003184 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003185 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003186 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003187 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003188 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003189 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003190 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003191 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003192 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003193 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003194 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003195 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003196 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003197 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3198 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003199 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003200 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3201 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003202 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003203 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003204 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003205 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003206 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003207 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003208 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003209};
3210
3211static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003212 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003213 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3214 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003215 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003216 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3217 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003218 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003219 .phy_read = mv88e6xxx_g2_smi_phy_read,
3220 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003221 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003222 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003223 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003224 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003225 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003226 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003227 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003228 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003229 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003230 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003231 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003232 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003233 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003234 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003235 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003236 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003237 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003238 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3239 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003240 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003241 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3242 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003243 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003244 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003245 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003246 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003247 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003248 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003249 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003250 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003251 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003252 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003253};
3254
3255static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003256 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003257 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3258 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003259 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003260 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003261 .phy_read = mv88e6xxx_g2_smi_phy_read,
3262 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003263 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003264 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003265 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003266 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003267 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003268 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003269 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003270 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003271 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003272 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003273 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003274 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003275 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003276 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003277 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003278 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003279 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003280 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3281 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003282 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003283 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3284 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003285 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003286 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003287 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003288 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003289 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003290 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003291 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003292};
3293
3294static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003295 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003296 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3297 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003298 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003299 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3300 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003301 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003302 .phy_read = mv88e6xxx_g2_smi_phy_read,
3303 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003304 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003305 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003306 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003307 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003308 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003309 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003310 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003311 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003312 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003313 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003314 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003315 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003316 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003317 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003318 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003319 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003320 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003321 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3322 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003323 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003324 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3325 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003326 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003327 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003328 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003329 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003330 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003331 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003332 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003333 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003334 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3335 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003336 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003337 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003338};
3339
3340static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003341 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003342 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3343 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003344 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003345 .phy_read = mv88e6185_phy_ppu_read,
3346 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003347 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003348 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003349 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003350 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003351 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003352 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003353 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003354 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003355 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003356 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003357 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003358 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003359 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3360 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003361 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003362 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3363 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003364 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003365 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003366 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003367 .ppu_enable = mv88e6185_g1_ppu_enable,
3368 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003369 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003370 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003371 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003372 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003373};
3374
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003375static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003376 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003377 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003378 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003379 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3380 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003381 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3382 .phy_read = mv88e6xxx_g2_smi_phy_read,
3383 .phy_write = mv88e6xxx_g2_smi_phy_write,
3384 .port_set_link = mv88e6xxx_port_set_link,
3385 .port_set_duplex = mv88e6xxx_port_set_duplex,
3386 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3387 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003388 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003389 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003390 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003391 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003392 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003393 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003394 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003395 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003396 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003397 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003398 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003399 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003400 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3401 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003402 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003403 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3404 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003405 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003406 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003407 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003408 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003409 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003410 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3411 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003412 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003413 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3414 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003415 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003416 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003417};
3418
3419static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003420 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003421 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003422 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003423 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3424 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003425 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3426 .phy_read = mv88e6xxx_g2_smi_phy_read,
3427 .phy_write = mv88e6xxx_g2_smi_phy_write,
3428 .port_set_link = mv88e6xxx_port_set_link,
3429 .port_set_duplex = mv88e6xxx_port_set_duplex,
3430 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3431 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003432 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003433 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003434 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003435 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003436 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003437 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003438 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003439 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003440 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003441 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003442 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003443 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003444 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3445 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003446 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003447 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3448 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003449 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003450 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003451 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003452 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003453 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003454 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3455 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003456 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003457 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3458 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003459 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003460 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003461};
3462
3463static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003464 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003465 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003466 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003467 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3468 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003469 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3470 .phy_read = mv88e6xxx_g2_smi_phy_read,
3471 .phy_write = mv88e6xxx_g2_smi_phy_write,
3472 .port_set_link = mv88e6xxx_port_set_link,
3473 .port_set_duplex = mv88e6xxx_port_set_duplex,
3474 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3475 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003476 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003477 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003478 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003479 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003480 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003481 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003482 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003483 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003484 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003485 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003486 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003487 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003488 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3489 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003490 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003491 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3492 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003493 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003494 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003495 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003496 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003497 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003498 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3499 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003500 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003501 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3502 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003503 .avb_ops = &mv88e6390_avb_ops,
3504 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003505 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003506};
3507
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003508static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003509 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003510 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3511 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003512 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003513 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3514 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003515 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003516 .phy_read = mv88e6xxx_g2_smi_phy_read,
3517 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003518 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003519 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003520 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003521 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003522 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003523 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003524 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003525 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003526 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003527 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003528 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003529 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003530 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003531 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003532 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003533 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003534 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003535 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3536 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003537 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003538 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3539 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003540 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003541 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003542 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003543 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003544 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003545 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003546 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003547 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003548 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3549 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003550 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003551 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003552 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003553 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003554};
3555
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003556static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003557 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003558 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003559 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003560 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3561 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003562 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3563 .phy_read = mv88e6xxx_g2_smi_phy_read,
3564 .phy_write = mv88e6xxx_g2_smi_phy_write,
3565 .port_set_link = mv88e6xxx_port_set_link,
3566 .port_set_duplex = mv88e6xxx_port_set_duplex,
3567 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3568 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003569 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003570 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003571 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003572 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003573 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003574 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003575 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003576 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003577 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003578 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003579 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003580 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003581 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3582 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003583 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003584 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3585 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003586 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003587 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003588 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003589 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003590 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003591 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3592 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003593 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003594 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3595 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003596 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003597 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003598 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003599 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003600};
3601
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003602static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003603 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003604 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3605 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003606 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003607 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3608 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003609 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003610 .phy_read = mv88e6xxx_g2_smi_phy_read,
3611 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003612 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003613 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003614 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003615 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003616 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003617 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003618 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003619 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003620 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003621 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003622 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003623 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003624 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003625 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003626 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003627 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003628 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3629 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003630 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003631 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3632 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003633 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003634 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003635 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003636 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003637 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003638 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003639 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003640 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003641 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003642 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003643};
3644
3645static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003646 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003647 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3648 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003649 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003650 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3651 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003652 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003653 .phy_read = mv88e6xxx_g2_smi_phy_read,
3654 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003655 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003656 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003657 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003658 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003659 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003660 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003661 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003662 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003663 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003664 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003665 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003666 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003667 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003668 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003669 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003670 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003671 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3672 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003673 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003674 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3675 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003676 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003677 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003678 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003679 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003680 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003681 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003682 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003683 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003684};
3685
Vivien Didelot16e329a2017-03-28 13:50:33 -04003686static const struct mv88e6xxx_ops mv88e6341_ops = {
3687 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003688 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3689 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003690 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003691 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3692 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3693 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3694 .phy_read = mv88e6xxx_g2_smi_phy_read,
3695 .phy_write = mv88e6xxx_g2_smi_phy_write,
3696 .port_set_link = mv88e6xxx_port_set_link,
3697 .port_set_duplex = mv88e6xxx_port_set_duplex,
3698 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003699 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003700 .port_tag_remap = mv88e6095_port_tag_remap,
3701 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3702 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3703 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003704 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003705 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003706 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003707 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3708 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003709 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003710 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003711 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003712 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003713 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3714 .stats_get_strings = mv88e6320_stats_get_strings,
3715 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003716 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3717 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003718 .watchdog_ops = &mv88e6390_watchdog_ops,
3719 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003720 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003721 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003722 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003723 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003724 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003725 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003726 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003727 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003728 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003729};
3730
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003731static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003732 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003733 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3734 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003735 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003736 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003737 .phy_read = mv88e6xxx_g2_smi_phy_read,
3738 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003739 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003740 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003741 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003742 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003743 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003744 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003745 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003746 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003747 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003748 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003749 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003750 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003751 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003752 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003753 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003754 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003755 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003756 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3757 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003758 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003759 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3760 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003761 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003762 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003763 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003764 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003765 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003766 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003767 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003768};
3769
3770static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003771 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003772 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3773 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003774 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003775 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003776 .phy_read = mv88e6xxx_g2_smi_phy_read,
3777 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003778 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003779 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003780 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003781 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003782 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003783 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003784 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003785 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003786 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003787 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003788 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003789 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003790 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003791 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003792 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003793 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003794 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003795 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3796 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003797 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003798 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3799 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003800 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003801 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003802 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003803 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003804 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003805 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003806 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003807 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003808 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003809};
3810
3811static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003812 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003813 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3814 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003815 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003816 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3817 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003818 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003819 .phy_read = mv88e6xxx_g2_smi_phy_read,
3820 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003821 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003822 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003823 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003824 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003825 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003826 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003827 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003828 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003829 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003830 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003831 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003832 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003833 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003834 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003835 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003836 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003837 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003838 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3839 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003840 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003841 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3842 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003843 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003844 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003845 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003846 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003847 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003848 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003849 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003850 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003851 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3852 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003853 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003854 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003855 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003856 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3857 .serdes_get_strings = mv88e6352_serdes_get_strings,
3858 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003859 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003860};
3861
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003862static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003863 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003864 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003865 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003866 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3867 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003868 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3869 .phy_read = mv88e6xxx_g2_smi_phy_read,
3870 .phy_write = mv88e6xxx_g2_smi_phy_write,
3871 .port_set_link = mv88e6xxx_port_set_link,
3872 .port_set_duplex = mv88e6xxx_port_set_duplex,
3873 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3874 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003875 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003876 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003877 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003878 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003879 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003880 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003881 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003882 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003883 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003884 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003885 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003886 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003887 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003888 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003889 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3890 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003891 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003892 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3893 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003894 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003895 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003896 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003897 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003898 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003899 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3900 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003901 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003902 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3903 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003904 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003905 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003906 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003907 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003908};
3909
3910static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003911 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003912 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003913 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003914 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3915 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003916 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3917 .phy_read = mv88e6xxx_g2_smi_phy_read,
3918 .phy_write = mv88e6xxx_g2_smi_phy_write,
3919 .port_set_link = mv88e6xxx_port_set_link,
3920 .port_set_duplex = mv88e6xxx_port_set_duplex,
3921 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3922 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003923 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003924 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003925 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003926 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003927 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003928 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003929 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003930 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003931 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003932 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003933 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003934 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003935 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003936 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003937 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3938 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003939 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003940 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3941 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003942 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003943 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003944 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003945 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003946 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003947 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3948 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003949 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003950 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3951 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003952 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003953 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003954 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003955 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003956};
3957
Vivien Didelotf81ec902016-05-09 13:22:58 -04003958static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3959 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003960 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003961 .family = MV88E6XXX_FAMILY_6097,
3962 .name = "Marvell 88E6085",
3963 .num_databases = 4096,
3964 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003965 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003966 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003967 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003968 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003969 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003970 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003971 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003972 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003973 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003974 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003975 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003976 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003977 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003978 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003979 },
3980
3981 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003982 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003983 .family = MV88E6XXX_FAMILY_6095,
3984 .name = "Marvell 88E6095/88E6095F",
3985 .num_databases = 256,
3986 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003987 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003988 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003989 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003990 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003991 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003992 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003993 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003994 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003995 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003996 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003997 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003998 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003999 },
4000
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004001 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004002 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004003 .family = MV88E6XXX_FAMILY_6097,
4004 .name = "Marvell 88E6097/88E6097F",
4005 .num_databases = 4096,
4006 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004007 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004008 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004009 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004010 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004011 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004012 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004013 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004014 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004015 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004016 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004017 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004018 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004019 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004020 .ops = &mv88e6097_ops,
4021 },
4022
Vivien Didelotf81ec902016-05-09 13:22:58 -04004023 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004024 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004025 .family = MV88E6XXX_FAMILY_6165,
4026 .name = "Marvell 88E6123",
4027 .num_databases = 4096,
4028 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004029 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004030 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004031 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004032 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004033 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004034 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004035 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004036 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004037 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004038 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004039 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004040 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004041 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004042 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004043 },
4044
4045 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004046 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004047 .family = MV88E6XXX_FAMILY_6185,
4048 .name = "Marvell 88E6131",
4049 .num_databases = 256,
4050 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004051 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004052 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004053 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004054 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004055 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004056 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004057 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004058 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004059 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004060 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004061 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004062 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004063 },
4064
Vivien Didelot990e27b2017-03-28 13:50:32 -04004065 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004066 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004067 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004068 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004069 .num_databases = 4096,
4070 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004071 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004072 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004073 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004074 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004075 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004076 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004077 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004078 .age_time_coeff = 3750,
4079 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004080 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004081 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004082 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004083 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004084 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004085 .ops = &mv88e6141_ops,
4086 },
4087
Vivien Didelotf81ec902016-05-09 13:22:58 -04004088 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004089 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004090 .family = MV88E6XXX_FAMILY_6165,
4091 .name = "Marvell 88E6161",
4092 .num_databases = 4096,
4093 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004094 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004095 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004096 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004097 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004098 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004099 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004100 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004101 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004102 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004103 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004104 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004105 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004106 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004107 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004108 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004109 },
4110
4111 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004112 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004113 .family = MV88E6XXX_FAMILY_6165,
4114 .name = "Marvell 88E6165",
4115 .num_databases = 4096,
4116 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004117 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004118 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004119 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004120 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004121 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004122 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004123 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004124 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004125 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004126 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004127 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004128 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004129 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004130 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004131 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004132 },
4133
4134 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004135 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004136 .family = MV88E6XXX_FAMILY_6351,
4137 .name = "Marvell 88E6171",
4138 .num_databases = 4096,
4139 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004140 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004141 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004142 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004143 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004144 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004145 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004146 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004147 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004148 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004149 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004150 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004151 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004152 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004153 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004154 },
4155
4156 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004157 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004158 .family = MV88E6XXX_FAMILY_6352,
4159 .name = "Marvell 88E6172",
4160 .num_databases = 4096,
4161 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004162 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004163 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004164 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004165 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004166 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004167 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004168 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004169 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004170 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004171 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004172 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004173 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004174 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004175 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004176 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004177 },
4178
4179 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004180 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004181 .family = MV88E6XXX_FAMILY_6351,
4182 .name = "Marvell 88E6175",
4183 .num_databases = 4096,
4184 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004185 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004186 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004187 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004188 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004189 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004190 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004191 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004192 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004193 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004194 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004195 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004196 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004197 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004198 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004199 },
4200
4201 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004202 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004203 .family = MV88E6XXX_FAMILY_6352,
4204 .name = "Marvell 88E6176",
4205 .num_databases = 4096,
4206 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004207 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004208 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004209 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004210 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004211 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004212 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004213 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004214 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004215 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004216 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004217 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004218 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004219 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004220 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004221 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004222 },
4223
4224 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004225 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004226 .family = MV88E6XXX_FAMILY_6185,
4227 .name = "Marvell 88E6185",
4228 .num_databases = 256,
4229 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004230 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004231 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004232 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004233 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004234 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004235 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004236 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004237 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004238 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004239 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004240 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004241 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004242 },
4243
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004244 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004245 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004246 .family = MV88E6XXX_FAMILY_6390,
4247 .name = "Marvell 88E6190",
4248 .num_databases = 4096,
4249 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004250 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004251 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004252 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004253 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004254 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004255 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004256 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004257 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004258 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004259 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004260 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004261 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004262 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004263 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004264 .ops = &mv88e6190_ops,
4265 },
4266
4267 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004268 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004269 .family = MV88E6XXX_FAMILY_6390,
4270 .name = "Marvell 88E6190X",
4271 .num_databases = 4096,
4272 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004273 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004274 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004275 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004276 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004277 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004278 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004279 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004280 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004281 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004282 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004283 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004284 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004285 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004286 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004287 .ops = &mv88e6190x_ops,
4288 },
4289
4290 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004291 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004292 .family = MV88E6XXX_FAMILY_6390,
4293 .name = "Marvell 88E6191",
4294 .num_databases = 4096,
4295 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004296 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004297 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004298 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004299 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004300 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004301 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004302 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004303 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004304 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004305 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004306 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004307 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004308 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004309 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004310 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004311 },
4312
Vivien Didelotf81ec902016-05-09 13:22:58 -04004313 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004314 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004315 .family = MV88E6XXX_FAMILY_6352,
4316 .name = "Marvell 88E6240",
4317 .num_databases = 4096,
4318 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004319 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004320 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004321 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004322 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004323 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004324 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004325 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004326 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004327 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004328 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004329 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004330 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004331 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004332 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004333 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004334 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004335 },
4336
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004337 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004338 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004339 .family = MV88E6XXX_FAMILY_6390,
4340 .name = "Marvell 88E6290",
4341 .num_databases = 4096,
4342 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004343 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004344 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004345 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004346 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004347 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004348 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004349 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004350 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004351 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004352 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004353 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004354 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004355 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004356 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004357 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004358 .ops = &mv88e6290_ops,
4359 },
4360
Vivien Didelotf81ec902016-05-09 13:22:58 -04004361 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004362 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004363 .family = MV88E6XXX_FAMILY_6320,
4364 .name = "Marvell 88E6320",
4365 .num_databases = 4096,
4366 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004367 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004368 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004369 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004370 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004371 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004372 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004373 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004374 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004375 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004376 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004377 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004378 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004379 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004380 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004381 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004382 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004383 },
4384
4385 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004386 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004387 .family = MV88E6XXX_FAMILY_6320,
4388 .name = "Marvell 88E6321",
4389 .num_databases = 4096,
4390 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004391 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004392 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004393 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004394 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004395 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004396 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004397 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004398 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004399 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004400 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004401 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004402 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004403 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004404 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004405 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004406 },
4407
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004408 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004409 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004410 .family = MV88E6XXX_FAMILY_6341,
4411 .name = "Marvell 88E6341",
4412 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004413 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004414 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004415 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004416 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004417 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004418 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004419 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004420 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004421 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004422 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004423 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004424 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004425 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004426 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004427 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004428 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004429 .ops = &mv88e6341_ops,
4430 },
4431
Vivien Didelotf81ec902016-05-09 13:22:58 -04004432 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004433 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004434 .family = MV88E6XXX_FAMILY_6351,
4435 .name = "Marvell 88E6350",
4436 .num_databases = 4096,
4437 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004438 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004439 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004440 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004441 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004442 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004443 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004444 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004445 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004446 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004447 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004448 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004449 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004450 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004451 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004452 },
4453
4454 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004455 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004456 .family = MV88E6XXX_FAMILY_6351,
4457 .name = "Marvell 88E6351",
4458 .num_databases = 4096,
4459 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004460 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004461 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004462 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004463 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004464 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004465 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004466 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004467 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004468 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004469 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004470 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004471 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004472 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004473 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004474 },
4475
4476 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004477 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004478 .family = MV88E6XXX_FAMILY_6352,
4479 .name = "Marvell 88E6352",
4480 .num_databases = 4096,
4481 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004482 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004483 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004484 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004485 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004486 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004487 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004488 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004489 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004490 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004491 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004492 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004493 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004494 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004495 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004496 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004497 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004498 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004499 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004500 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004501 .family = MV88E6XXX_FAMILY_6390,
4502 .name = "Marvell 88E6390",
4503 .num_databases = 4096,
4504 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004505 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004506 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004507 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004508 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004509 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004510 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004511 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004512 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004513 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004514 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004515 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004516 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004517 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004518 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004519 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004520 .ops = &mv88e6390_ops,
4521 },
4522 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004523 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004524 .family = MV88E6XXX_FAMILY_6390,
4525 .name = "Marvell 88E6390X",
4526 .num_databases = 4096,
4527 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004528 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004529 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004530 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004531 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004532 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004533 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004534 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004535 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004536 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004537 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004538 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004539 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004540 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004541 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004542 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004543 .ops = &mv88e6390x_ops,
4544 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004545};
4546
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004547static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004548{
Vivien Didelota439c062016-04-17 13:23:58 -04004549 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004550
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004551 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4552 if (mv88e6xxx_table[i].prod_num == prod_num)
4553 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004554
Vivien Didelotb9b37712015-10-30 19:39:48 -04004555 return NULL;
4556}
4557
Vivien Didelotfad09c72016-06-21 12:28:20 -04004558static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004559{
4560 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004561 unsigned int prod_num, rev;
4562 u16 id;
4563 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004564
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004565 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004566 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004567 mutex_unlock(&chip->reg_lock);
4568 if (err)
4569 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004570
Vivien Didelot107fcc12017-06-12 12:37:36 -04004571 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4572 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004573
4574 info = mv88e6xxx_lookup_info(prod_num);
4575 if (!info)
4576 return -ENODEV;
4577
Vivien Didelotcaac8542016-06-20 13:14:09 -04004578 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004579 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004580
Vivien Didelotca070c12016-09-02 14:45:34 -04004581 err = mv88e6xxx_g2_require(chip);
4582 if (err)
4583 return err;
4584
Vivien Didelotfad09c72016-06-21 12:28:20 -04004585 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4586 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004587
4588 return 0;
4589}
4590
Vivien Didelotfad09c72016-06-21 12:28:20 -04004591static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004592{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004593 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004594
Vivien Didelotfad09c72016-06-21 12:28:20 -04004595 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4596 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004597 return NULL;
4598
Vivien Didelotfad09c72016-06-21 12:28:20 -04004599 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004600
Vivien Didelotfad09c72016-06-21 12:28:20 -04004601 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004602 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004603
Vivien Didelotfad09c72016-06-21 12:28:20 -04004604 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004605}
4606
Vivien Didelotfad09c72016-06-21 12:28:20 -04004607static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004608 struct mii_bus *bus, int sw_addr)
4609{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004610 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004611 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004612 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004613 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004614 else
4615 return -EINVAL;
4616
Vivien Didelotfad09c72016-06-21 12:28:20 -04004617 chip->bus = bus;
4618 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004619
4620 return 0;
4621}
4622
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004623static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4624 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004625{
Vivien Didelot04bed142016-08-31 18:06:13 -04004626 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004627
Andrew Lunn443d5a12016-12-03 04:35:18 +01004628 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004629}
4630
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004631#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004632static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4633 struct device *host_dev, int sw_addr,
4634 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004635{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004636 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004637 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004638 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004639
Vivien Didelota439c062016-04-17 13:23:58 -04004640 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004641 if (!bus)
4642 return NULL;
4643
Vivien Didelotfad09c72016-06-21 12:28:20 -04004644 chip = mv88e6xxx_alloc_chip(dsa_dev);
4645 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004646 return NULL;
4647
Vivien Didelotcaac8542016-06-20 13:14:09 -04004648 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004649 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004650
Vivien Didelotfad09c72016-06-21 12:28:20 -04004651 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004652 if (err)
4653 goto free;
4654
Vivien Didelotfad09c72016-06-21 12:28:20 -04004655 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004656 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004657 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004658
Andrew Lunndc30c352016-10-16 19:56:49 +02004659 mutex_lock(&chip->reg_lock);
4660 err = mv88e6xxx_switch_reset(chip);
4661 mutex_unlock(&chip->reg_lock);
4662 if (err)
4663 goto free;
4664
Vivien Didelote57e5e72016-08-15 17:19:00 -04004665 mv88e6xxx_phy_init(chip);
4666
Andrew Lunna3c53be52017-01-24 14:53:50 +01004667 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004668 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004669 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004670
Vivien Didelotfad09c72016-06-21 12:28:20 -04004671 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004672
Vivien Didelotfad09c72016-06-21 12:28:20 -04004673 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004674free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004675 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004676
4677 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004678}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004679#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004680
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004681static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004682 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004683{
4684 /* We don't need any dynamic resource from the kernel (yet),
4685 * so skip the prepare phase.
4686 */
4687
4688 return 0;
4689}
4690
4691static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004692 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004693{
Vivien Didelot04bed142016-08-31 18:06:13 -04004694 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004695
4696 mutex_lock(&chip->reg_lock);
4697 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004698 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004699 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4700 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004701 mutex_unlock(&chip->reg_lock);
4702}
4703
4704static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4705 const struct switchdev_obj_port_mdb *mdb)
4706{
Vivien Didelot04bed142016-08-31 18:06:13 -04004707 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004708 int err;
4709
4710 mutex_lock(&chip->reg_lock);
4711 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004712 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004713 mutex_unlock(&chip->reg_lock);
4714
4715 return err;
4716}
4717
Russell King4f859012019-02-20 15:35:05 -08004718static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4719 bool unicast, bool multicast)
4720{
4721 struct mv88e6xxx_chip *chip = ds->priv;
4722 int err = -EOPNOTSUPP;
4723
4724 mutex_lock(&chip->reg_lock);
4725 if (chip->info->ops->port_set_egress_floods)
4726 err = chip->info->ops->port_set_egress_floods(chip, port,
4727 unicast,
4728 multicast);
4729 mutex_unlock(&chip->reg_lock);
4730
4731 return err;
4732}
4733
Florian Fainellia82f67a2017-01-08 14:52:08 -08004734static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004735#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004736 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004737#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004738 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004739 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004740 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004741 .phylink_validate = mv88e6xxx_validate,
4742 .phylink_mac_link_state = mv88e6xxx_link_state,
4743 .phylink_mac_config = mv88e6xxx_mac_config,
4744 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4745 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004746 .get_strings = mv88e6xxx_get_strings,
4747 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4748 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004749 .port_enable = mv88e6xxx_port_enable,
4750 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004751 .get_mac_eee = mv88e6xxx_get_mac_eee,
4752 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004753 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004754 .get_eeprom = mv88e6xxx_get_eeprom,
4755 .set_eeprom = mv88e6xxx_set_eeprom,
4756 .get_regs_len = mv88e6xxx_get_regs_len,
4757 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004758 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004759 .port_bridge_join = mv88e6xxx_port_bridge_join,
4760 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004761 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004762 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004763 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004764 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4765 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4766 .port_vlan_add = mv88e6xxx_port_vlan_add,
4767 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004768 .port_fdb_add = mv88e6xxx_port_fdb_add,
4769 .port_fdb_del = mv88e6xxx_port_fdb_del,
4770 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004771 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4772 .port_mdb_add = mv88e6xxx_port_mdb_add,
4773 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004774 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4775 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004776 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4777 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4778 .port_txtstamp = mv88e6xxx_port_txtstamp,
4779 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4780 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004781};
4782
Florian Fainelliab3d4082017-01-08 14:52:07 -08004783static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4784 .ops = &mv88e6xxx_switch_ops,
4785};
4786
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004787static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004788{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004789 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004790 struct dsa_switch *ds;
4791
Vivien Didelot73b12042017-03-30 17:37:10 -04004792 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004793 if (!ds)
4794 return -ENOMEM;
4795
Vivien Didelotfad09c72016-06-21 12:28:20 -04004796 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004797 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004798 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004799 ds->ageing_time_min = chip->info->age_time_coeff;
4800 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004801
4802 dev_set_drvdata(dev, ds);
4803
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004804 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004805}
4806
Vivien Didelotfad09c72016-06-21 12:28:20 -04004807static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004808{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004809 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004810}
4811
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004812static const void *pdata_device_get_match_data(struct device *dev)
4813{
4814 const struct of_device_id *matches = dev->driver->of_match_table;
4815 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4816
4817 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4818 matches++) {
4819 if (!strcmp(pdata->compatible, matches->compatible))
4820 return matches->data;
4821 }
4822 return NULL;
4823}
4824
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004825/* There is no suspend to RAM support at DSA level yet, the switch configuration
4826 * would be lost after a power cycle so prevent it to be suspended.
4827 */
4828static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4829{
4830 return -EOPNOTSUPP;
4831}
4832
4833static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4834{
4835 return 0;
4836}
4837
4838static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4839
Vivien Didelot57d32312016-06-20 13:13:58 -04004840static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004841{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004842 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004843 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004844 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004845 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004846 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004847 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004848 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004849
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004850 if (!np && !pdata)
4851 return -EINVAL;
4852
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004853 if (np)
4854 compat_info = of_device_get_match_data(dev);
4855
4856 if (pdata) {
4857 compat_info = pdata_device_get_match_data(dev);
4858
4859 if (!pdata->netdev)
4860 return -EINVAL;
4861
4862 for (port = 0; port < DSA_MAX_PORTS; port++) {
4863 if (!(pdata->enabled_ports & (1 << port)))
4864 continue;
4865 if (strcmp(pdata->cd.port_names[port], "cpu"))
4866 continue;
4867 pdata->cd.netdev[port] = &pdata->netdev->dev;
4868 break;
4869 }
4870 }
4871
Vivien Didelotcaac8542016-06-20 13:14:09 -04004872 if (!compat_info)
4873 return -EINVAL;
4874
Vivien Didelotfad09c72016-06-21 12:28:20 -04004875 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004876 if (!chip) {
4877 err = -ENOMEM;
4878 goto out;
4879 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004880
Vivien Didelotfad09c72016-06-21 12:28:20 -04004881 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004882
Vivien Didelotfad09c72016-06-21 12:28:20 -04004883 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004884 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004885 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004886
Andrew Lunnb4308f02016-11-21 23:26:55 +01004887 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004888 if (IS_ERR(chip->reset)) {
4889 err = PTR_ERR(chip->reset);
4890 goto out;
4891 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004892
Vivien Didelotfad09c72016-06-21 12:28:20 -04004893 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004894 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004895 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004896
Vivien Didelote57e5e72016-08-15 17:19:00 -04004897 mv88e6xxx_phy_init(chip);
4898
Andrew Lunn00baabe2018-05-19 22:31:35 +02004899 if (chip->info->ops->get_eeprom) {
4900 if (np)
4901 of_property_read_u32(np, "eeprom-length",
4902 &chip->eeprom_len);
4903 else
4904 chip->eeprom_len = pdata->eeprom_len;
4905 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004906
Andrew Lunndc30c352016-10-16 19:56:49 +02004907 mutex_lock(&chip->reg_lock);
4908 err = mv88e6xxx_switch_reset(chip);
4909 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004910 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004911 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004912
Andrew Lunndc30c352016-10-16 19:56:49 +02004913 chip->irq = of_irq_get(np, 0);
4914 if (chip->irq == -EPROBE_DEFER) {
4915 err = chip->irq;
4916 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004917 }
4918
Andrew Lunn294d7112018-02-22 22:58:32 +01004919 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004920 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004921 * controllers
4922 */
4923 mutex_lock(&chip->reg_lock);
4924 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004925 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004926 else
4927 err = mv88e6xxx_irq_poll_setup(chip);
4928 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004929
Andrew Lunn294d7112018-02-22 22:58:32 +01004930 if (err)
4931 goto out;
4932
4933 if (chip->info->g2_irqs > 0) {
4934 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004935 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004936 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004937 }
4938
Andrew Lunn294d7112018-02-22 22:58:32 +01004939 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4940 if (err)
4941 goto out_g2_irq;
4942
4943 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4944 if (err)
4945 goto out_g1_atu_prob_irq;
4946
Andrew Lunna3c53be52017-01-24 14:53:50 +01004947 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004948 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004949 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004950
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004951 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004952 if (err)
4953 goto out_mdio;
4954
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004955 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004956
4957out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004958 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004959out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004960 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004961out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004962 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004963out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004964 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004965 mv88e6xxx_g2_irq_free(chip);
4966out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004967 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004968 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004969 else
4970 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004971out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004972 if (pdata)
4973 dev_put(pdata->netdev);
4974
Andrew Lunndc30c352016-10-16 19:56:49 +02004975 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004976}
4977
4978static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4979{
4980 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004981 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004982
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004983 if (chip->info->ptp_support) {
4984 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004985 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004986 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004987
Andrew Lunn930188c2016-08-22 16:01:03 +02004988 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004989 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004990 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004991
Andrew Lunn76f38f12018-03-17 20:21:09 +01004992 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4993 mv88e6xxx_g1_atu_prob_irq_free(chip);
4994
4995 if (chip->info->g2_irqs > 0)
4996 mv88e6xxx_g2_irq_free(chip);
4997
Andrew Lunn76f38f12018-03-17 20:21:09 +01004998 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004999 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005000 else
5001 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005002}
5003
5004static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005005 {
5006 .compatible = "marvell,mv88e6085",
5007 .data = &mv88e6xxx_table[MV88E6085],
5008 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005009 {
5010 .compatible = "marvell,mv88e6190",
5011 .data = &mv88e6xxx_table[MV88E6190],
5012 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005013 { /* sentinel */ },
5014};
5015
5016MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5017
5018static struct mdio_driver mv88e6xxx_driver = {
5019 .probe = mv88e6xxx_probe,
5020 .remove = mv88e6xxx_remove,
5021 .mdiodrv.driver = {
5022 .name = "mv88e6085",
5023 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005024 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005025 },
5026};
5027
Ben Hutchings98e67302011-11-25 14:36:19 +00005028static int __init mv88e6xxx_init(void)
5029{
Florian Fainelliab3d4082017-01-08 14:52:07 -08005030 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005031 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00005032}
5033module_init(mv88e6xxx_init);
5034
5035static void __exit mv88e6xxx_cleanup(void)
5036{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005037 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08005038 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00005039}
5040module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005041
5042MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5043MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5044MODULE_LICENSE("GPL");