blob: 12fd7ce3f1ffdb7cdd9875af49468ff729a82c7a [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{
445 int err;
446
447 err = mv88e6xxx_g1_irq_setup_common(chip);
448 if (err)
449 return err;
450
451 err = request_threaded_irq(chip->irq, NULL,
452 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200453 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100454 dev_name(chip->dev), chip);
455 if (err)
456 mv88e6xxx_g1_irq_free_common(chip);
457
458 return err;
459}
460
461static void mv88e6xxx_irq_poll(struct kthread_work *work)
462{
463 struct mv88e6xxx_chip *chip = container_of(work,
464 struct mv88e6xxx_chip,
465 irq_poll_work.work);
466 mv88e6xxx_g1_irq_thread_work(chip);
467
468 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
469 msecs_to_jiffies(100));
470}
471
472static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
473{
474 int err;
475
476 err = mv88e6xxx_g1_irq_setup_common(chip);
477 if (err)
478 return err;
479
480 kthread_init_delayed_work(&chip->irq_poll_work,
481 mv88e6xxx_irq_poll);
482
483 chip->kworker = kthread_create_worker(0, dev_name(chip->dev));
484 if (IS_ERR(chip->kworker))
485 return PTR_ERR(chip->kworker);
486
487 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
488 msecs_to_jiffies(100));
489
490 return 0;
491}
492
493static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
494{
495 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
496 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200497
498 mutex_lock(&chip->reg_lock);
499 mv88e6xxx_g1_irq_free_common(chip);
500 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100501}
502
Vivien Didelotec561272016-09-02 14:45:33 -0400503int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400504{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200505 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400506
Andrew Lunn6441e6692016-08-19 00:01:55 +0200507 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400508 u16 val;
509 int err;
510
511 err = mv88e6xxx_read(chip, addr, reg, &val);
512 if (err)
513 return err;
514
515 if (!(val & mask))
516 return 0;
517
518 usleep_range(1000, 2000);
519 }
520
Andrew Lunn30853552016-08-19 00:01:57 +0200521 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400522 return -ETIMEDOUT;
523}
524
Vivien Didelotf22ab642016-07-18 20:45:31 -0400525/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400526int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400527{
528 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200529 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400530
531 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200532 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
533 if (err)
534 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400535
536 /* Set the Update bit to trigger a write operation */
537 val = BIT(15) | update;
538
539 return mv88e6xxx_write(chip, addr, reg, val);
540}
541
Vivien Didelotd78343d2016-11-04 03:23:36 +0100542static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
Andrew Lunn54186b92018-08-09 15:38:37 +0200543 int link, int speed, int duplex, int pause,
Vivien Didelotd78343d2016-11-04 03:23:36 +0100544 phy_interface_t mode)
545{
546 int err;
547
548 if (!chip->info->ops->port_set_link)
549 return 0;
550
551 /* Port's MAC control must not be changed unless the link is down */
552 err = chip->info->ops->port_set_link(chip, port, 0);
553 if (err)
554 return err;
555
556 if (chip->info->ops->port_set_speed) {
557 err = chip->info->ops->port_set_speed(chip, port, speed);
558 if (err && err != -EOPNOTSUPP)
559 goto restore_link;
560 }
561
Andrew Lunn54186b92018-08-09 15:38:37 +0200562 if (chip->info->ops->port_set_pause) {
563 err = chip->info->ops->port_set_pause(chip, port, pause);
564 if (err)
565 goto restore_link;
566 }
567
Vivien Didelotd78343d2016-11-04 03:23:36 +0100568 if (chip->info->ops->port_set_duplex) {
569 err = chip->info->ops->port_set_duplex(chip, port, duplex);
570 if (err && err != -EOPNOTSUPP)
571 goto restore_link;
572 }
573
574 if (chip->info->ops->port_set_rgmii_delay) {
575 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
576 if (err && err != -EOPNOTSUPP)
577 goto restore_link;
578 }
579
Andrew Lunnf39908d2017-02-04 20:02:50 +0100580 if (chip->info->ops->port_set_cmode) {
581 err = chip->info->ops->port_set_cmode(chip, port, mode);
582 if (err && err != -EOPNOTSUPP)
583 goto restore_link;
584 }
585
Vivien Didelotd78343d2016-11-04 03:23:36 +0100586 err = 0;
587restore_link:
588 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400589 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100590
591 return err;
592}
593
Marek Vasutd700ec42018-09-12 00:15:24 +0200594static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
595{
596 struct mv88e6xxx_chip *chip = ds->priv;
597
598 return port < chip->info->num_internal_phys;
599}
600
Andrew Lunndea87022015-08-31 15:56:47 +0200601/* We expect the switch to perform auto negotiation if there is a real
602 * phy. However, in the case of a fixed link phy, we force the port
603 * settings from the fixed link settings.
604 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400605static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
606 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200607{
Vivien Didelot04bed142016-08-31 18:06:13 -0400608 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200609 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200610
Marek Vasutd700ec42018-09-12 00:15:24 +0200611 if (!phy_is_pseudo_fixed_link(phydev) &&
612 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200613 return;
614
Vivien Didelotfad09c72016-06-21 12:28:20 -0400615 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100616 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200617 phydev->duplex, phydev->pause,
618 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400619 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100620
621 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400622 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200623}
624
Russell King6c422e32018-08-09 15:38:39 +0200625static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
626 unsigned long *mask,
627 struct phylink_link_state *state)
628{
629 if (!phy_interface_mode_is_8023z(state->interface)) {
630 /* 10M and 100M are only supported in non-802.3z mode */
631 phylink_set(mask, 10baseT_Half);
632 phylink_set(mask, 10baseT_Full);
633 phylink_set(mask, 100baseT_Half);
634 phylink_set(mask, 100baseT_Full);
635 }
636}
637
638static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
639 unsigned long *mask,
640 struct phylink_link_state *state)
641{
642 /* FIXME: if the port is in 1000Base-X mode, then it only supports
643 * 1000M FD speeds. In this case, CMODE will indicate 5.
644 */
645 phylink_set(mask, 1000baseT_Full);
646 phylink_set(mask, 1000baseX_Full);
647
648 mv88e6065_phylink_validate(chip, port, mask, state);
649}
650
651static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
652 unsigned long *mask,
653 struct phylink_link_state *state)
654{
655 /* No ethtool bits for 200Mbps */
656 phylink_set(mask, 1000baseT_Full);
657 phylink_set(mask, 1000baseX_Full);
658
659 mv88e6065_phylink_validate(chip, port, mask, state);
660}
661
662static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
663 unsigned long *mask,
664 struct phylink_link_state *state)
665{
666 if (port >= 9)
667 phylink_set(mask, 2500baseX_Full);
668
669 /* No ethtool bits for 200Mbps */
670 phylink_set(mask, 1000baseT_Full);
671 phylink_set(mask, 1000baseX_Full);
672
673 mv88e6065_phylink_validate(chip, port, mask, state);
674}
675
676static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
677 unsigned long *mask,
678 struct phylink_link_state *state)
679{
680 if (port >= 9) {
681 phylink_set(mask, 10000baseT_Full);
682 phylink_set(mask, 10000baseKR_Full);
683 }
684
685 mv88e6390_phylink_validate(chip, port, mask, state);
686}
687
Russell Kingc9a23562018-05-10 13:17:35 -0700688static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
689 unsigned long *supported,
690 struct phylink_link_state *state)
691{
Russell King6c422e32018-08-09 15:38:39 +0200692 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
693 struct mv88e6xxx_chip *chip = ds->priv;
694
695 /* Allow all the expected bits */
696 phylink_set(mask, Autoneg);
697 phylink_set(mask, Pause);
698 phylink_set_port_modes(mask);
699
700 if (chip->info->ops->phylink_validate)
701 chip->info->ops->phylink_validate(chip, port, mask, state);
702
703 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
704 bitmap_and(state->advertising, state->advertising, mask,
705 __ETHTOOL_LINK_MODE_MASK_NBITS);
706
707 /* We can only operate at 2500BaseX or 1000BaseX. If requested
708 * to advertise both, only report advertising at 2500BaseX.
709 */
710 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700711}
712
713static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
714 struct phylink_link_state *state)
715{
716 struct mv88e6xxx_chip *chip = ds->priv;
717 int err;
718
719 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200720 if (chip->info->ops->port_link_state)
721 err = chip->info->ops->port_link_state(chip, port, state);
722 else
723 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700724 mutex_unlock(&chip->reg_lock);
725
726 return err;
727}
728
729static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
730 unsigned int mode,
731 const struct phylink_link_state *state)
732{
733 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200734 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700735
Marek Vasutd700ec42018-09-12 00:15:24 +0200736 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700737 return;
738
739 if (mode == MLO_AN_FIXED) {
740 link = LINK_FORCED_UP;
741 speed = state->speed;
742 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200743 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
744 link = state->link;
745 speed = state->speed;
746 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700747 } else {
748 speed = SPEED_UNFORCED;
749 duplex = DUPLEX_UNFORCED;
750 link = LINK_UNFORCED;
751 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200752 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700753
754 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200755 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700756 state->interface);
757 mutex_unlock(&chip->reg_lock);
758
759 if (err && err != -EOPNOTSUPP)
760 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
761}
762
763static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
764{
765 struct mv88e6xxx_chip *chip = ds->priv;
766 int err;
767
768 mutex_lock(&chip->reg_lock);
769 err = chip->info->ops->port_set_link(chip, port, link);
770 mutex_unlock(&chip->reg_lock);
771
772 if (err)
773 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
774}
775
776static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
777 unsigned int mode,
778 phy_interface_t interface)
779{
780 if (mode == MLO_AN_FIXED)
781 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
782}
783
784static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
785 unsigned int mode, phy_interface_t interface,
786 struct phy_device *phydev)
787{
788 if (mode == MLO_AN_FIXED)
789 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
790}
791
Andrew Lunna605a0f2016-11-21 23:26:58 +0100792static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000793{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100794 if (!chip->info->ops->stats_snapshot)
795 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000796
Andrew Lunna605a0f2016-11-21 23:26:58 +0100797 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000798}
799
Andrew Lunne413e7e2015-04-02 04:06:38 +0200800static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100801 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
802 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
803 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
804 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
805 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
806 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
807 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
808 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
809 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
810 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
811 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
812 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
813 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
814 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
815 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
816 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
817 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
818 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
819 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
820 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
821 { "single", 4, 0x14, STATS_TYPE_BANK0, },
822 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
823 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
824 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
825 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
826 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
827 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
828 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
829 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
830 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
831 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
832 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
833 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
834 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
835 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
836 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
837 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
838 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
839 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
840 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
841 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
842 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
843 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
844 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
845 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
846 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
847 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
848 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
849 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
850 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
851 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
852 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
853 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
854 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
855 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
856 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
857 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
858 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
859 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200860};
861
Vivien Didelotfad09c72016-06-21 12:28:20 -0400862static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100863 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100864 int port, u16 bank1_select,
865 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200866{
Andrew Lunn80c46272015-06-20 18:42:30 +0200867 u32 low;
868 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100869 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200870 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200871 u64 value;
872
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100873 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100874 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200875 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
876 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800877 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200878
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200879 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100880 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200881 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
882 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800883 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200884 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200885 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100886 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100887 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100888 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100889 /* fall through */
890 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100891 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100892 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100893 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100894 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500895 break;
896 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800897 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200898 }
899 value = (((u64)high) << 16) | low;
900 return value;
901}
902
Andrew Lunn436fe172018-03-01 02:02:29 +0100903static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
904 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100905{
906 struct mv88e6xxx_hw_stat *stat;
907 int i, j;
908
909 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
910 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100911 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100912 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
913 ETH_GSTRING_LEN);
914 j++;
915 }
916 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100917
918 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100919}
920
Andrew Lunn436fe172018-03-01 02:02:29 +0100921static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
922 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100923{
Andrew Lunn436fe172018-03-01 02:02:29 +0100924 return mv88e6xxx_stats_get_strings(chip, data,
925 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100926}
927
Andrew Lunn436fe172018-03-01 02:02:29 +0100928static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
929 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100930{
Andrew Lunn436fe172018-03-01 02:02:29 +0100931 return mv88e6xxx_stats_get_strings(chip, data,
932 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100933}
934
Andrew Lunn65f60e42018-03-28 23:50:28 +0200935static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
936 "atu_member_violation",
937 "atu_miss_violation",
938 "atu_full_violation",
939 "vtu_member_violation",
940 "vtu_miss_violation",
941};
942
943static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
944{
945 unsigned int i;
946
947 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
948 strlcpy(data + i * ETH_GSTRING_LEN,
949 mv88e6xxx_atu_vtu_stats_strings[i],
950 ETH_GSTRING_LEN);
951}
952
Andrew Lunndfafe442016-11-21 23:27:02 +0100953static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700954 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100955{
Vivien Didelot04bed142016-08-31 18:06:13 -0400956 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100957 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100958
Florian Fainelli89f09042018-04-25 12:12:50 -0700959 if (stringset != ETH_SS_STATS)
960 return;
961
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100962 mutex_lock(&chip->reg_lock);
963
Andrew Lunndfafe442016-11-21 23:27:02 +0100964 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100965 count = chip->info->ops->stats_get_strings(chip, data);
966
967 if (chip->info->ops->serdes_get_strings) {
968 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200969 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100970 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100971
Andrew Lunn65f60e42018-03-28 23:50:28 +0200972 data += count * ETH_GSTRING_LEN;
973 mv88e6xxx_atu_vtu_get_strings(data);
974
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100975 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100976}
977
978static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
979 int types)
980{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100981 struct mv88e6xxx_hw_stat *stat;
982 int i, j;
983
984 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
985 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100986 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100987 j++;
988 }
989 return j;
990}
991
Andrew Lunndfafe442016-11-21 23:27:02 +0100992static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
993{
994 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
995 STATS_TYPE_PORT);
996}
997
998static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
999{
1000 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1001 STATS_TYPE_BANK1);
1002}
1003
Florian Fainelli89f09042018-04-25 12:12:50 -07001004static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001005{
1006 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001007 int serdes_count = 0;
1008 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001009
Florian Fainelli89f09042018-04-25 12:12:50 -07001010 if (sset != ETH_SS_STATS)
1011 return 0;
1012
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001013 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001014 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001015 count = chip->info->ops->stats_get_sset_count(chip);
1016 if (count < 0)
1017 goto out;
1018
1019 if (chip->info->ops->serdes_get_sset_count)
1020 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1021 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001022 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001023 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001024 goto out;
1025 }
1026 count += serdes_count;
1027 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1028
Andrew Lunn436fe172018-03-01 02:02:29 +01001029out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001030 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001031
Andrew Lunn436fe172018-03-01 02:02:29 +01001032 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001033}
1034
Andrew Lunn436fe172018-03-01 02:02:29 +01001035static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1036 uint64_t *data, int types,
1037 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001038{
1039 struct mv88e6xxx_hw_stat *stat;
1040 int i, j;
1041
1042 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1043 stat = &mv88e6xxx_hw_stats[i];
1044 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001045 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001046 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1047 bank1_select,
1048 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001049 mutex_unlock(&chip->reg_lock);
1050
Andrew Lunn052f9472016-11-21 23:27:03 +01001051 j++;
1052 }
1053 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001054 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001055}
1056
Andrew Lunn436fe172018-03-01 02:02:29 +01001057static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1058 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001059{
1060 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001061 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001062 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001063}
1064
Andrew Lunn436fe172018-03-01 02:02:29 +01001065static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1066 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001067{
1068 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001069 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001070 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1071 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001072}
1073
Andrew Lunn436fe172018-03-01 02:02:29 +01001074static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1075 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001076{
1077 return mv88e6xxx_stats_get_stats(chip, port, data,
1078 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001079 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1080 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001081}
1082
Andrew Lunn65f60e42018-03-28 23:50:28 +02001083static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1084 uint64_t *data)
1085{
1086 *data++ = chip->ports[port].atu_member_violation;
1087 *data++ = chip->ports[port].atu_miss_violation;
1088 *data++ = chip->ports[port].atu_full_violation;
1089 *data++ = chip->ports[port].vtu_member_violation;
1090 *data++ = chip->ports[port].vtu_miss_violation;
1091}
1092
Andrew Lunn052f9472016-11-21 23:27:03 +01001093static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1094 uint64_t *data)
1095{
Andrew Lunn436fe172018-03-01 02:02:29 +01001096 int count = 0;
1097
Andrew Lunn052f9472016-11-21 23:27:03 +01001098 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001099 count = chip->info->ops->stats_get_stats(chip, port, data);
1100
Andrew Lunn65f60e42018-03-28 23:50:28 +02001101 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001102 if (chip->info->ops->serdes_get_stats) {
1103 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001104 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001105 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001106 data += count;
1107 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1108 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001109}
1110
Vivien Didelotf81ec902016-05-09 13:22:58 -04001111static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1112 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001113{
Vivien Didelot04bed142016-08-31 18:06:13 -04001114 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001115 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001116
Vivien Didelotfad09c72016-06-21 12:28:20 -04001117 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001118
Andrew Lunna605a0f2016-11-21 23:26:58 +01001119 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001120 mutex_unlock(&chip->reg_lock);
1121
1122 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001123 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001124
1125 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001126
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001127}
Ben Hutchings98e67302011-11-25 14:36:19 +00001128
Vivien Didelotf81ec902016-05-09 13:22:58 -04001129static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001130{
1131 return 32 * sizeof(u16);
1132}
1133
Vivien Didelotf81ec902016-05-09 13:22:58 -04001134static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1135 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001136{
Vivien Didelot04bed142016-08-31 18:06:13 -04001137 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001138 int err;
1139 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001140 u16 *p = _p;
1141 int i;
1142
Vivien Didelota5f39322018-12-17 16:05:21 -05001143 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001144
1145 memset(p, 0xff, 32 * sizeof(u16));
1146
Vivien Didelotfad09c72016-06-21 12:28:20 -04001147 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001148
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001149 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001150
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001151 err = mv88e6xxx_port_read(chip, port, i, &reg);
1152 if (!err)
1153 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001154 }
Vivien Didelot23062512016-05-09 13:22:45 -04001155
Vivien Didelotfad09c72016-06-21 12:28:20 -04001156 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001157}
1158
Vivien Didelot08f50062017-08-01 16:32:41 -04001159static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1160 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001161{
Vivien Didelot5480db62017-08-01 16:32:40 -04001162 /* Nothing to do on the port's MAC */
1163 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001164}
1165
Vivien Didelot08f50062017-08-01 16:32:41 -04001166static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1167 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001168{
Vivien Didelot5480db62017-08-01 16:32:40 -04001169 /* Nothing to do on the port's MAC */
1170 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001171}
1172
Vivien Didelote5887a22017-03-30 17:37:11 -04001173static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001174{
Vivien Didelote5887a22017-03-30 17:37:11 -04001175 struct dsa_switch *ds = NULL;
1176 struct net_device *br;
1177 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001178 int i;
1179
Vivien Didelote5887a22017-03-30 17:37:11 -04001180 if (dev < DSA_MAX_SWITCHES)
1181 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001182
Vivien Didelote5887a22017-03-30 17:37:11 -04001183 /* Prevent frames from unknown switch or port */
1184 if (!ds || port >= ds->num_ports)
1185 return 0;
1186
1187 /* Frames from DSA links and CPU ports can egress any local port */
1188 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1189 return mv88e6xxx_port_mask(chip);
1190
1191 br = ds->ports[port].bridge_dev;
1192 pvlan = 0;
1193
1194 /* Frames from user ports can egress any local DSA links and CPU ports,
1195 * as well as any local member of their bridge group.
1196 */
1197 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1198 if (dsa_is_cpu_port(chip->ds, i) ||
1199 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001200 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001201 pvlan |= BIT(i);
1202
1203 return pvlan;
1204}
1205
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001206static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001207{
1208 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001209
1210 /* prevent frames from going back out of the port they came in on */
1211 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001212
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001213 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001214}
1215
Vivien Didelotf81ec902016-05-09 13:22:58 -04001216static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1217 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001218{
Vivien Didelot04bed142016-08-31 18:06:13 -04001219 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001220 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001221
Vivien Didelotfad09c72016-06-21 12:28:20 -04001222 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001223 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001224 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001225
1226 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001227 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001228}
1229
Vivien Didelot93e18d62018-05-11 17:16:35 -04001230static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1231{
1232 int err;
1233
1234 if (chip->info->ops->ieee_pri_map) {
1235 err = chip->info->ops->ieee_pri_map(chip);
1236 if (err)
1237 return err;
1238 }
1239
1240 if (chip->info->ops->ip_pri_map) {
1241 err = chip->info->ops->ip_pri_map(chip);
1242 if (err)
1243 return err;
1244 }
1245
1246 return 0;
1247}
1248
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001249static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1250{
1251 int target, port;
1252 int err;
1253
1254 if (!chip->info->global2_addr)
1255 return 0;
1256
1257 /* Initialize the routing port to the 32 possible target devices */
1258 for (target = 0; target < 32; target++) {
1259 port = 0x1f;
1260 if (target < DSA_MAX_SWITCHES)
1261 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1262 port = chip->ds->rtable[target];
1263
1264 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1265 if (err)
1266 return err;
1267 }
1268
Vivien Didelot02317e62018-05-09 11:38:49 -04001269 if (chip->info->ops->set_cascade_port) {
1270 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1271 err = chip->info->ops->set_cascade_port(chip, port);
1272 if (err)
1273 return err;
1274 }
1275
Vivien Didelot23c98912018-05-09 11:38:50 -04001276 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1277 if (err)
1278 return err;
1279
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001280 return 0;
1281}
1282
Vivien Didelotb28f8722018-04-26 21:56:44 -04001283static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1284{
1285 /* Clear all trunk masks and mapping */
1286 if (chip->info->global2_addr)
1287 return mv88e6xxx_g2_trunk_clear(chip);
1288
1289 return 0;
1290}
1291
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001292static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1293{
1294 if (chip->info->ops->rmu_disable)
1295 return chip->info->ops->rmu_disable(chip);
1296
1297 return 0;
1298}
1299
Vivien Didelot9e907d72017-07-17 13:03:43 -04001300static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1301{
1302 if (chip->info->ops->pot_clear)
1303 return chip->info->ops->pot_clear(chip);
1304
1305 return 0;
1306}
1307
Vivien Didelot51c901a2017-07-17 13:03:41 -04001308static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1309{
1310 if (chip->info->ops->mgmt_rsvd2cpu)
1311 return chip->info->ops->mgmt_rsvd2cpu(chip);
1312
1313 return 0;
1314}
1315
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001316static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1317{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001318 int err;
1319
Vivien Didelotdaefc942017-03-11 16:12:54 -05001320 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1321 if (err)
1322 return err;
1323
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001324 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1325 if (err)
1326 return err;
1327
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001328 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1329}
1330
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001331static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1332{
1333 int port;
1334 int err;
1335
1336 if (!chip->info->ops->irl_init_all)
1337 return 0;
1338
1339 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1340 /* Disable ingress rate limiting by resetting all per port
1341 * ingress rate limit resources to their initial state.
1342 */
1343 err = chip->info->ops->irl_init_all(chip, port);
1344 if (err)
1345 return err;
1346 }
1347
1348 return 0;
1349}
1350
Vivien Didelot04a69a12017-10-13 14:18:05 -04001351static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1352{
1353 if (chip->info->ops->set_switch_mac) {
1354 u8 addr[ETH_ALEN];
1355
1356 eth_random_addr(addr);
1357
1358 return chip->info->ops->set_switch_mac(chip, addr);
1359 }
1360
1361 return 0;
1362}
1363
Vivien Didelot17a15942017-03-30 17:37:09 -04001364static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1365{
1366 u16 pvlan = 0;
1367
1368 if (!mv88e6xxx_has_pvt(chip))
1369 return -EOPNOTSUPP;
1370
1371 /* Skip the local source device, which uses in-chip port VLAN */
1372 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001373 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001374
1375 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1376}
1377
Vivien Didelot81228992017-03-30 17:37:08 -04001378static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1379{
Vivien Didelot17a15942017-03-30 17:37:09 -04001380 int dev, port;
1381 int err;
1382
Vivien Didelot81228992017-03-30 17:37:08 -04001383 if (!mv88e6xxx_has_pvt(chip))
1384 return 0;
1385
1386 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1387 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1388 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001389 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1390 if (err)
1391 return err;
1392
1393 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1394 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1395 err = mv88e6xxx_pvt_map(chip, dev, port);
1396 if (err)
1397 return err;
1398 }
1399 }
1400
1401 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001402}
1403
Vivien Didelot749efcb2016-09-22 16:49:24 -04001404static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1405{
1406 struct mv88e6xxx_chip *chip = ds->priv;
1407 int err;
1408
1409 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001410 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001411 mutex_unlock(&chip->reg_lock);
1412
1413 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001414 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001415}
1416
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001417static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1418{
1419 if (!chip->info->max_vid)
1420 return 0;
1421
1422 return mv88e6xxx_g1_vtu_flush(chip);
1423}
1424
Vivien Didelotf1394b782017-05-01 14:05:22 -04001425static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1426 struct mv88e6xxx_vtu_entry *entry)
1427{
1428 if (!chip->info->ops->vtu_getnext)
1429 return -EOPNOTSUPP;
1430
1431 return chip->info->ops->vtu_getnext(chip, entry);
1432}
1433
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001434static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1435 struct mv88e6xxx_vtu_entry *entry)
1436{
1437 if (!chip->info->ops->vtu_loadpurge)
1438 return -EOPNOTSUPP;
1439
1440 return chip->info->ops->vtu_loadpurge(chip, entry);
1441}
1442
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001443static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001444{
1445 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001446 struct mv88e6xxx_vtu_entry vlan = {
1447 .vid = chip->info->max_vid,
1448 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001449 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001450
1451 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1452
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001453 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001454 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001455 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001456 if (err)
1457 return err;
1458
1459 set_bit(*fid, fid_bitmap);
1460 }
1461
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001462 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001463 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001464 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001465 if (err)
1466 return err;
1467
1468 if (!vlan.valid)
1469 break;
1470
1471 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001472 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001473
1474 /* The reset value 0x000 is used to indicate that multiple address
1475 * databases are not needed. Return the next positive available.
1476 */
1477 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001478 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001479 return -ENOSPC;
1480
1481 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001482 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001483}
1484
Vivien Didelot567aa592017-05-01 14:05:25 -04001485static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1486 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001487{
1488 int err;
1489
1490 if (!vid)
1491 return -EINVAL;
1492
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001493 entry->vid = vid - 1;
1494 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001495
Vivien Didelotf1394b782017-05-01 14:05:22 -04001496 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001497 if (err)
1498 return err;
1499
Vivien Didelot567aa592017-05-01 14:05:25 -04001500 if (entry->vid == vid && entry->valid)
1501 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001502
Vivien Didelot567aa592017-05-01 14:05:25 -04001503 if (new) {
1504 int i;
1505
1506 /* Initialize a fresh VLAN entry */
1507 memset(entry, 0, sizeof(*entry));
1508 entry->valid = true;
1509 entry->vid = vid;
1510
Vivien Didelot553a7682017-06-07 18:12:16 -04001511 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001512 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001513 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001514 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001515
1516 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001517 }
1518
Vivien Didelot567aa592017-05-01 14:05:25 -04001519 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1520 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001521}
1522
Vivien Didelotda9c3592016-02-12 12:09:40 -05001523static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1524 u16 vid_begin, u16 vid_end)
1525{
Vivien Didelot04bed142016-08-31 18:06:13 -04001526 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001527 struct mv88e6xxx_vtu_entry vlan = {
1528 .vid = vid_begin - 1,
1529 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001530 int i, err;
1531
Andrew Lunndb06ae412017-09-25 23:32:20 +02001532 /* DSA and CPU ports have to be members of multiple vlans */
1533 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1534 return 0;
1535
Vivien Didelotda9c3592016-02-12 12:09:40 -05001536 if (!vid_begin)
1537 return -EOPNOTSUPP;
1538
Vivien Didelotfad09c72016-06-21 12:28:20 -04001539 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001540
Vivien Didelotda9c3592016-02-12 12:09:40 -05001541 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001542 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001543 if (err)
1544 goto unlock;
1545
1546 if (!vlan.valid)
1547 break;
1548
1549 if (vlan.vid > vid_end)
1550 break;
1551
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001552 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001553 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1554 continue;
1555
Andrew Lunncd886462017-11-09 22:29:53 +01001556 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001557 continue;
1558
Vivien Didelotbd00e052017-05-01 14:05:11 -04001559 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001560 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001561 continue;
1562
Vivien Didelotc8652c82017-10-16 11:12:19 -04001563 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001564 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001565 break; /* same bridge, check next VLAN */
1566
Vivien Didelotc8652c82017-10-16 11:12:19 -04001567 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001568 continue;
1569
Andrew Lunn743fcc22017-11-09 22:29:54 +01001570 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1571 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001572 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001573 err = -EOPNOTSUPP;
1574 goto unlock;
1575 }
1576 } while (vlan.vid < vid_end);
1577
1578unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001579 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001580
1581 return err;
1582}
1583
Vivien Didelotf81ec902016-05-09 13:22:58 -04001584static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1585 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001586{
Vivien Didelot04bed142016-08-31 18:06:13 -04001587 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001588 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1589 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001590 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001591
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001592 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001593 return -EOPNOTSUPP;
1594
Vivien Didelotfad09c72016-06-21 12:28:20 -04001595 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001596 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001597 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001598
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001599 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001600}
1601
Vivien Didelot57d32312016-06-20 13:13:58 -04001602static int
1603mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001604 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001605{
Vivien Didelot04bed142016-08-31 18:06:13 -04001606 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001607 int err;
1608
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001609 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001610 return -EOPNOTSUPP;
1611
Vivien Didelotda9c3592016-02-12 12:09:40 -05001612 /* If the requested port doesn't belong to the same bridge as the VLAN
1613 * members, do not support it (yet) and fallback to software VLAN.
1614 */
1615 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1616 vlan->vid_end);
1617 if (err)
1618 return err;
1619
Vivien Didelot76e398a2015-11-01 12:33:55 -05001620 /* We don't need any dynamic resource from the kernel (yet),
1621 * so skip the prepare phase.
1622 */
1623 return 0;
1624}
1625
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001626static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1627 const unsigned char *addr, u16 vid,
1628 u8 state)
1629{
1630 struct mv88e6xxx_vtu_entry vlan;
1631 struct mv88e6xxx_atu_entry entry;
1632 int err;
1633
1634 /* Null VLAN ID corresponds to the port private database */
1635 if (vid == 0)
1636 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1637 else
1638 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1639 if (err)
1640 return err;
1641
1642 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1643 ether_addr_copy(entry.mac, addr);
1644 eth_addr_dec(entry.mac);
1645
1646 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1647 if (err)
1648 return err;
1649
1650 /* Initialize a fresh ATU entry if it isn't found */
1651 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1652 !ether_addr_equal(entry.mac, addr)) {
1653 memset(&entry, 0, sizeof(entry));
1654 ether_addr_copy(entry.mac, addr);
1655 }
1656
1657 /* Purge the ATU entry only if no port is using it anymore */
1658 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1659 entry.portvec &= ~BIT(port);
1660 if (!entry.portvec)
1661 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1662 } else {
1663 entry.portvec |= BIT(port);
1664 entry.state = state;
1665 }
1666
1667 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1668}
1669
Andrew Lunn87fa8862017-11-09 22:29:56 +01001670static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1671 u16 vid)
1672{
1673 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1674 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1675
1676 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1677}
1678
1679static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1680{
1681 int port;
1682 int err;
1683
1684 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1685 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1686 if (err)
1687 return err;
1688 }
1689
1690 return 0;
1691}
1692
Vivien Didelotfad09c72016-06-21 12:28:20 -04001693static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001694 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001695{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001696 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001697 int err;
1698
Vivien Didelot567aa592017-05-01 14:05:25 -04001699 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001700 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001701 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001702
Vivien Didelotc91498e2017-06-07 18:12:13 -04001703 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001704
Andrew Lunn87fa8862017-11-09 22:29:56 +01001705 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1706 if (err)
1707 return err;
1708
1709 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001710}
1711
Vivien Didelotf81ec902016-05-09 13:22:58 -04001712static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001713 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001714{
Vivien Didelot04bed142016-08-31 18:06:13 -04001715 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001716 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1717 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001718 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001719 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001720
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001721 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001722 return;
1723
Vivien Didelotc91498e2017-06-07 18:12:13 -04001724 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001725 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001726 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001727 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001728 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001729 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001730
Vivien Didelotfad09c72016-06-21 12:28:20 -04001731 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001732
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001733 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001734 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001735 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1736 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001737
Vivien Didelot77064f32016-11-04 03:23:30 +01001738 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001739 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1740 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001741
Vivien Didelotfad09c72016-06-21 12:28:20 -04001742 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001743}
1744
Vivien Didelotfad09c72016-06-21 12:28:20 -04001745static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001746 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001747{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001748 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001749 int i, err;
1750
Vivien Didelot567aa592017-05-01 14:05:25 -04001751 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001752 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001753 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001754
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001755 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001756 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001757 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001758
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001759 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001760
1761 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001762 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001763 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001764 if (vlan.member[i] !=
1765 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001766 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001767 break;
1768 }
1769 }
1770
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001771 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001772 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001773 return err;
1774
Vivien Didelote606ca32017-03-11 16:12:55 -05001775 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001776}
1777
Vivien Didelotf81ec902016-05-09 13:22:58 -04001778static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1779 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001780{
Vivien Didelot04bed142016-08-31 18:06:13 -04001781 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001782 u16 pvid, vid;
1783 int err = 0;
1784
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001785 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001786 return -EOPNOTSUPP;
1787
Vivien Didelotfad09c72016-06-21 12:28:20 -04001788 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001789
Vivien Didelot77064f32016-11-04 03:23:30 +01001790 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001791 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001792 goto unlock;
1793
Vivien Didelot76e398a2015-11-01 12:33:55 -05001794 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001795 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001796 if (err)
1797 goto unlock;
1798
1799 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001800 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001801 if (err)
1802 goto unlock;
1803 }
1804 }
1805
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001806unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001807 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001808
1809 return err;
1810}
1811
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001812static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1813 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001814{
Vivien Didelot04bed142016-08-31 18:06:13 -04001815 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001816 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001817
Vivien Didelotfad09c72016-06-21 12:28:20 -04001818 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001819 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1820 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001821 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001822
1823 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001824}
1825
Vivien Didelotf81ec902016-05-09 13:22:58 -04001826static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001827 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001828{
Vivien Didelot04bed142016-08-31 18:06:13 -04001829 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001830 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001831
Vivien Didelotfad09c72016-06-21 12:28:20 -04001832 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001833 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001834 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001835 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001836
Vivien Didelot83dabd12016-08-31 11:50:04 -04001837 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001838}
1839
Vivien Didelot83dabd12016-08-31 11:50:04 -04001840static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1841 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001842 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001843{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001844 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001845 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001846 int err;
1847
Vivien Didelot27c0e602017-06-15 12:14:01 -04001848 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001849 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001850
1851 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001852 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001853 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001854 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001855 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001856 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001857
Vivien Didelot27c0e602017-06-15 12:14:01 -04001858 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001859 break;
1860
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001861 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001862 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001863
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001864 if (!is_unicast_ether_addr(addr.mac))
1865 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001866
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001867 is_static = (addr.state ==
1868 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1869 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001870 if (err)
1871 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001872 } while (!is_broadcast_ether_addr(addr.mac));
1873
1874 return err;
1875}
1876
Vivien Didelot83dabd12016-08-31 11:50:04 -04001877static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001878 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001879{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001880 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001881 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001882 };
1883 u16 fid;
1884 int err;
1885
1886 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001887 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001888 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001889 mutex_unlock(&chip->reg_lock);
1890
Vivien Didelot83dabd12016-08-31 11:50:04 -04001891 if (err)
1892 return err;
1893
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001894 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001895 if (err)
1896 return err;
1897
1898 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001899 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001900 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001901 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001902 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001903 if (err)
1904 return err;
1905
1906 if (!vlan.valid)
1907 break;
1908
1909 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001910 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001911 if (err)
1912 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001913 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001914
1915 return err;
1916}
1917
Vivien Didelotf81ec902016-05-09 13:22:58 -04001918static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001919 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001920{
Vivien Didelot04bed142016-08-31 18:06:13 -04001921 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001922
Andrew Lunna61e5402018-02-15 14:38:35 +01001923 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001924}
1925
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001926static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1927 struct net_device *br)
1928{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001929 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001930 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001931 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001932 int err;
1933
1934 /* Remap the Port VLAN of each local bridge group member */
1935 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1936 if (chip->ds->ports[port].bridge_dev == br) {
1937 err = mv88e6xxx_port_vlan_map(chip, port);
1938 if (err)
1939 return err;
1940 }
1941 }
1942
Vivien Didelote96a6e02017-03-30 17:37:13 -04001943 if (!mv88e6xxx_has_pvt(chip))
1944 return 0;
1945
1946 /* Remap the Port VLAN of each cross-chip bridge group member */
1947 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1948 ds = chip->ds->dst->ds[dev];
1949 if (!ds)
1950 break;
1951
1952 for (port = 0; port < ds->num_ports; ++port) {
1953 if (ds->ports[port].bridge_dev == br) {
1954 err = mv88e6xxx_pvt_map(chip, dev, port);
1955 if (err)
1956 return err;
1957 }
1958 }
1959 }
1960
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001961 return 0;
1962}
1963
Vivien Didelotf81ec902016-05-09 13:22:58 -04001964static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001965 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001966{
Vivien Didelot04bed142016-08-31 18:06:13 -04001967 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001968 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001969
Vivien Didelotfad09c72016-06-21 12:28:20 -04001970 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001971 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001972 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001973
Vivien Didelot466dfa02016-02-26 13:16:05 -05001974 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001975}
1976
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001977static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1978 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001979{
Vivien Didelot04bed142016-08-31 18:06:13 -04001980 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001981
Vivien Didelotfad09c72016-06-21 12:28:20 -04001982 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001983 if (mv88e6xxx_bridge_map(chip, br) ||
1984 mv88e6xxx_port_vlan_map(chip, port))
1985 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001986 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001987}
1988
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001989static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1990 int port, struct net_device *br)
1991{
1992 struct mv88e6xxx_chip *chip = ds->priv;
1993 int err;
1994
1995 if (!mv88e6xxx_has_pvt(chip))
1996 return 0;
1997
1998 mutex_lock(&chip->reg_lock);
1999 err = mv88e6xxx_pvt_map(chip, dev, port);
2000 mutex_unlock(&chip->reg_lock);
2001
2002 return err;
2003}
2004
2005static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2006 int port, struct net_device *br)
2007{
2008 struct mv88e6xxx_chip *chip = ds->priv;
2009
2010 if (!mv88e6xxx_has_pvt(chip))
2011 return;
2012
2013 mutex_lock(&chip->reg_lock);
2014 if (mv88e6xxx_pvt_map(chip, dev, port))
2015 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2016 mutex_unlock(&chip->reg_lock);
2017}
2018
Vivien Didelot17e708b2016-12-05 17:30:27 -05002019static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2020{
2021 if (chip->info->ops->reset)
2022 return chip->info->ops->reset(chip);
2023
2024 return 0;
2025}
2026
Vivien Didelot309eca62016-12-05 17:30:26 -05002027static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2028{
2029 struct gpio_desc *gpiod = chip->reset;
2030
2031 /* If there is a GPIO connected to the reset pin, toggle it */
2032 if (gpiod) {
2033 gpiod_set_value_cansleep(gpiod, 1);
2034 usleep_range(10000, 20000);
2035 gpiod_set_value_cansleep(gpiod, 0);
2036 usleep_range(10000, 20000);
2037 }
2038}
2039
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002040static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2041{
2042 int i, err;
2043
2044 /* Set all ports to the Disabled state */
2045 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002046 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002047 if (err)
2048 return err;
2049 }
2050
2051 /* Wait for transmit queues to drain,
2052 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2053 */
2054 usleep_range(2000, 4000);
2055
2056 return 0;
2057}
2058
Vivien Didelotfad09c72016-06-21 12:28:20 -04002059static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002060{
Vivien Didelota935c052016-09-29 12:21:53 -04002061 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002062
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002063 err = mv88e6xxx_disable_ports(chip);
2064 if (err)
2065 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002066
Vivien Didelot309eca62016-12-05 17:30:26 -05002067 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002068
Vivien Didelot17e708b2016-12-05 17:30:27 -05002069 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002070}
2071
Vivien Didelot43145572017-03-11 16:12:59 -05002072static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002073 enum mv88e6xxx_frame_mode frame,
2074 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002075{
2076 int err;
2077
Vivien Didelot43145572017-03-11 16:12:59 -05002078 if (!chip->info->ops->port_set_frame_mode)
2079 return -EOPNOTSUPP;
2080
2081 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002082 if (err)
2083 return err;
2084
Vivien Didelot43145572017-03-11 16:12:59 -05002085 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2086 if (err)
2087 return err;
2088
2089 if (chip->info->ops->port_set_ether_type)
2090 return chip->info->ops->port_set_ether_type(chip, port, etype);
2091
2092 return 0;
2093}
2094
2095static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2096{
2097 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002098 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002099 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002100}
2101
2102static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2103{
2104 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002105 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002106 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002107}
2108
2109static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2110{
2111 return mv88e6xxx_set_port_mode(chip, port,
2112 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002113 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2114 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002115}
2116
2117static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2118{
2119 if (dsa_is_dsa_port(chip->ds, port))
2120 return mv88e6xxx_set_port_mode_dsa(chip, port);
2121
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002122 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002123 return mv88e6xxx_set_port_mode_normal(chip, port);
2124
2125 /* Setup CPU port mode depending on its supported tag format */
2126 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2127 return mv88e6xxx_set_port_mode_dsa(chip, port);
2128
2129 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2130 return mv88e6xxx_set_port_mode_edsa(chip, port);
2131
2132 return -EINVAL;
2133}
2134
Vivien Didelotea698f42017-03-11 16:12:50 -05002135static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2136{
2137 bool message = dsa_is_dsa_port(chip->ds, port);
2138
2139 return mv88e6xxx_port_set_message_port(chip, port, message);
2140}
2141
Vivien Didelot601aeed2017-03-11 16:13:00 -05002142static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2143{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002144 struct dsa_switch *ds = chip->ds;
2145 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002146
2147 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002148 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002149 if (chip->info->ops->port_set_egress_floods)
2150 return chip->info->ops->port_set_egress_floods(chip, port,
2151 flood, flood);
2152
2153 return 0;
2154}
2155
Andrew Lunn6d917822017-05-26 01:03:21 +02002156static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2157 bool on)
2158{
Vivien Didelot523a8902017-05-26 18:02:42 -04002159 if (chip->info->ops->serdes_power)
2160 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002161
Vivien Didelot523a8902017-05-26 18:02:42 -04002162 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002163}
2164
Vivien Didelotfa371c82017-12-05 15:34:10 -05002165static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2166{
2167 struct dsa_switch *ds = chip->ds;
2168 int upstream_port;
2169 int err;
2170
Vivien Didelot07073c72017-12-05 15:34:13 -05002171 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002172 if (chip->info->ops->port_set_upstream_port) {
2173 err = chip->info->ops->port_set_upstream_port(chip, port,
2174 upstream_port);
2175 if (err)
2176 return err;
2177 }
2178
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002179 if (port == upstream_port) {
2180 if (chip->info->ops->set_cpu_port) {
2181 err = chip->info->ops->set_cpu_port(chip,
2182 upstream_port);
2183 if (err)
2184 return err;
2185 }
2186
2187 if (chip->info->ops->set_egress_port) {
2188 err = chip->info->ops->set_egress_port(chip,
2189 upstream_port);
2190 if (err)
2191 return err;
2192 }
2193 }
2194
Vivien Didelotfa371c82017-12-05 15:34:10 -05002195 return 0;
2196}
2197
Vivien Didelotfad09c72016-06-21 12:28:20 -04002198static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002199{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002200 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002201 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002202 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002203
Andrew Lunn7b898462018-08-09 15:38:47 +02002204 chip->ports[port].chip = chip;
2205 chip->ports[port].port = port;
2206
Vivien Didelotd78343d2016-11-04 03:23:36 +01002207 /* MAC Forcing register: don't force link, speed, duplex or flow control
2208 * state to any particular values on physical ports, but force the CPU
2209 * port and all DSA ports to their maximum bandwidth and full duplex.
2210 */
2211 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2212 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2213 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002214 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002215 PHY_INTERFACE_MODE_NA);
2216 else
2217 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2218 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002219 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002220 PHY_INTERFACE_MODE_NA);
2221 if (err)
2222 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002223
2224 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2225 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2226 * tunneling, determine priority by looking at 802.1p and IP
2227 * priority fields (IP prio has precedence), and set STP state
2228 * to Forwarding.
2229 *
2230 * If this is the CPU link, use DSA or EDSA tagging depending
2231 * on which tagging mode was configured.
2232 *
2233 * If this is a link to another switch, use DSA tagging mode.
2234 *
2235 * If this is the upstream port for this switch, enable
2236 * forwarding of unknown unicasts and multicasts.
2237 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002238 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2239 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2240 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2241 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002242 if (err)
2243 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002244
Vivien Didelot601aeed2017-03-11 16:13:00 -05002245 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002246 if (err)
2247 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002248
Vivien Didelot601aeed2017-03-11 16:13:00 -05002249 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002250 if (err)
2251 return err;
2252
Andrew Lunn04aca992017-05-26 01:03:24 +02002253 /* Enable the SERDES interface for DSA and CPU ports. Normal
2254 * ports SERDES are enabled when the port is enabled, thus
2255 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002256 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002257 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2258 err = mv88e6xxx_serdes_power(chip, port, true);
2259 if (err)
2260 return err;
2261 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002262
Vivien Didelot8efdda42015-08-13 12:52:23 -04002263 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002264 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002265 * untagged frames on this port, do a destination address lookup on all
2266 * received packets as usual, disable ARP mirroring and don't send a
2267 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002268 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002269 err = mv88e6xxx_port_set_map_da(chip, port);
2270 if (err)
2271 return err;
2272
Vivien Didelotfa371c82017-12-05 15:34:10 -05002273 err = mv88e6xxx_setup_upstream_port(chip, port);
2274 if (err)
2275 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002276
Andrew Lunna23b2962017-02-04 20:15:28 +01002277 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002278 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002279 if (err)
2280 return err;
2281
Vivien Didelotcd782652017-06-08 18:34:13 -04002282 if (chip->info->ops->port_set_jumbo_size) {
2283 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002284 if (err)
2285 return err;
2286 }
2287
Andrew Lunn54d792f2015-05-06 01:09:47 +02002288 /* Port Association Vector: when learning source addresses
2289 * of packets, add the address to the address database using
2290 * a port bitmap that has only the bit for this port set and
2291 * the other bits clear.
2292 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002293 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002294 /* Disable learning for CPU port */
2295 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002296 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002297
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002298 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2299 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002300 if (err)
2301 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002302
2303 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002304 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2305 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002306 if (err)
2307 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002308
Vivien Didelot08984322017-06-08 18:34:12 -04002309 if (chip->info->ops->port_pause_limit) {
2310 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002311 if (err)
2312 return err;
2313 }
2314
Vivien Didelotc8c94892017-03-11 16:13:01 -05002315 if (chip->info->ops->port_disable_learn_limit) {
2316 err = chip->info->ops->port_disable_learn_limit(chip, port);
2317 if (err)
2318 return err;
2319 }
2320
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002321 if (chip->info->ops->port_disable_pri_override) {
2322 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002323 if (err)
2324 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002325 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002326
Andrew Lunnef0a7312016-12-03 04:35:16 +01002327 if (chip->info->ops->port_tag_remap) {
2328 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002329 if (err)
2330 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002331 }
2332
Andrew Lunnef70b112016-12-03 04:45:18 +01002333 if (chip->info->ops->port_egress_rate_limiting) {
2334 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002335 if (err)
2336 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002337 }
2338
Vivien Didelotea698f42017-03-11 16:12:50 -05002339 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002340 if (err)
2341 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002342
Vivien Didelot207afda2016-04-14 14:42:09 -04002343 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002344 * database, and allow bidirectional communication between the
2345 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002346 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002347 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002348 if (err)
2349 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002350
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002351 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002352 if (err)
2353 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002354
2355 /* Default VLAN ID and priority: don't set a default VLAN
2356 * ID, and set the default packet priority to zero.
2357 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002358 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002359}
2360
Andrew Lunn04aca992017-05-26 01:03:24 +02002361static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2362 struct phy_device *phydev)
2363{
2364 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002365 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002366
2367 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002368
Vivien Didelot523a8902017-05-26 18:02:42 -04002369 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002370
2371 if (!err && chip->info->ops->serdes_irq_setup)
2372 err = chip->info->ops->serdes_irq_setup(chip, port);
2373
Andrew Lunn04aca992017-05-26 01:03:24 +02002374 mutex_unlock(&chip->reg_lock);
2375
2376 return err;
2377}
2378
2379static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2380 struct phy_device *phydev)
2381{
2382 struct mv88e6xxx_chip *chip = ds->priv;
2383
2384 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002385
2386 if (chip->info->ops->serdes_irq_free)
2387 chip->info->ops->serdes_irq_free(chip, port);
2388
Vivien Didelot523a8902017-05-26 18:02:42 -04002389 if (mv88e6xxx_serdes_power(chip, port, false))
2390 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002391
Andrew Lunn04aca992017-05-26 01:03:24 +02002392 mutex_unlock(&chip->reg_lock);
2393}
2394
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002395static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2396 unsigned int ageing_time)
2397{
Vivien Didelot04bed142016-08-31 18:06:13 -04002398 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002399 int err;
2400
2401 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002402 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002403 mutex_unlock(&chip->reg_lock);
2404
2405 return err;
2406}
2407
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002408static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002409{
2410 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002411
Andrew Lunnde2273872016-11-21 23:27:01 +01002412 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002413 if (chip->info->ops->stats_set_histogram) {
2414 err = chip->info->ops->stats_set_histogram(chip);
2415 if (err)
2416 return err;
2417 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002418
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002419 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002420}
2421
Andrew Lunnea890982019-01-09 00:24:03 +01002422/* The mv88e6390 has some hidden registers used for debug and
2423 * development. The errata also makes use of them.
2424 */
2425static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2426 int reg, u16 val)
2427{
2428 u16 ctrl;
2429 int err;
2430
2431 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2432 PORT_RESERVED_1A, val);
2433 if (err)
2434 return err;
2435
2436 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2437 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2438 reg;
2439
2440 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2441 PORT_RESERVED_1A, ctrl);
2442}
2443
2444static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2445{
2446 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2447 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2448}
2449
2450
2451static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2452 int reg, u16 *val)
2453{
2454 u16 ctrl;
2455 int err;
2456
2457 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2458 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2459 reg;
2460
2461 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2462 PORT_RESERVED_1A, ctrl);
2463 if (err)
2464 return err;
2465
2466 err = mv88e6390_hidden_wait(chip);
2467 if (err)
2468 return err;
2469
2470 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2471 PORT_RESERVED_1A, val);
2472}
2473
2474/* Check if the errata has already been applied. */
2475static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2476{
2477 int port;
2478 int err;
2479 u16 val;
2480
2481 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2482 err = mv88e6390_hidden_read(chip, port, 0, &val);
2483 if (err) {
2484 dev_err(chip->dev,
2485 "Error reading hidden register: %d\n", err);
2486 return false;
2487 }
2488 if (val != 0x01c0)
2489 return false;
2490 }
2491
2492 return true;
2493}
2494
2495/* The 6390 copper ports have an errata which require poking magic
2496 * values into undocumented hidden registers and then performing a
2497 * software reset.
2498 */
2499static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2500{
2501 int port;
2502 int err;
2503
2504 if (mv88e6390_setup_errata_applied(chip))
2505 return 0;
2506
2507 /* Set the ports into blocking mode */
2508 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2509 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2510 if (err)
2511 return err;
2512 }
2513
2514 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2515 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2516 if (err)
2517 return err;
2518 }
2519
2520 return mv88e6xxx_software_reset(chip);
2521}
2522
Vivien Didelotf81ec902016-05-09 13:22:58 -04002523static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002524{
Vivien Didelot04bed142016-08-31 18:06:13 -04002525 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002526 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002527 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002528 int i;
2529
Vivien Didelotfad09c72016-06-21 12:28:20 -04002530 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002531 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002532
Vivien Didelotfad09c72016-06-21 12:28:20 -04002533 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002534
Andrew Lunnea890982019-01-09 00:24:03 +01002535 if (chip->info->ops->setup_errata) {
2536 err = chip->info->ops->setup_errata(chip);
2537 if (err)
2538 goto unlock;
2539 }
2540
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002541 /* Cache the cmode of each port. */
2542 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2543 if (chip->info->ops->port_get_cmode) {
2544 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2545 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002546 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002547
2548 chip->ports[i].cmode = cmode;
2549 }
2550 }
2551
Vivien Didelot97299342016-07-18 20:45:30 -04002552 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002553 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002554 if (dsa_is_unused_port(ds, i))
2555 continue;
2556
Vivien Didelot97299342016-07-18 20:45:30 -04002557 err = mv88e6xxx_setup_port(chip, i);
2558 if (err)
2559 goto unlock;
2560 }
2561
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002562 err = mv88e6xxx_irl_setup(chip);
2563 if (err)
2564 goto unlock;
2565
Vivien Didelot04a69a12017-10-13 14:18:05 -04002566 err = mv88e6xxx_mac_setup(chip);
2567 if (err)
2568 goto unlock;
2569
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002570 err = mv88e6xxx_phy_setup(chip);
2571 if (err)
2572 goto unlock;
2573
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002574 err = mv88e6xxx_vtu_setup(chip);
2575 if (err)
2576 goto unlock;
2577
Vivien Didelot81228992017-03-30 17:37:08 -04002578 err = mv88e6xxx_pvt_setup(chip);
2579 if (err)
2580 goto unlock;
2581
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002582 err = mv88e6xxx_atu_setup(chip);
2583 if (err)
2584 goto unlock;
2585
Andrew Lunn87fa8862017-11-09 22:29:56 +01002586 err = mv88e6xxx_broadcast_setup(chip, 0);
2587 if (err)
2588 goto unlock;
2589
Vivien Didelot9e907d72017-07-17 13:03:43 -04002590 err = mv88e6xxx_pot_setup(chip);
2591 if (err)
2592 goto unlock;
2593
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002594 err = mv88e6xxx_rmu_setup(chip);
2595 if (err)
2596 goto unlock;
2597
Vivien Didelot51c901a2017-07-17 13:03:41 -04002598 err = mv88e6xxx_rsvd2cpu_setup(chip);
2599 if (err)
2600 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002601
Vivien Didelotb28f8722018-04-26 21:56:44 -04002602 err = mv88e6xxx_trunk_setup(chip);
2603 if (err)
2604 goto unlock;
2605
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002606 err = mv88e6xxx_devmap_setup(chip);
2607 if (err)
2608 goto unlock;
2609
Vivien Didelot93e18d62018-05-11 17:16:35 -04002610 err = mv88e6xxx_pri_setup(chip);
2611 if (err)
2612 goto unlock;
2613
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002614 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002615 if (chip->info->ptp_support) {
2616 err = mv88e6xxx_ptp_setup(chip);
2617 if (err)
2618 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002619
2620 err = mv88e6xxx_hwtstamp_setup(chip);
2621 if (err)
2622 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002623 }
2624
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002625 err = mv88e6xxx_stats_setup(chip);
2626 if (err)
2627 goto unlock;
2628
Vivien Didelot6b17e862015-08-13 12:52:18 -04002629unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002630 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002631
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002632 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002633}
2634
Vivien Didelote57e5e72016-08-15 17:19:00 -04002635static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002636{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002637 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2638 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002639 u16 val;
2640 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002641
Andrew Lunnee26a222017-01-24 14:53:48 +01002642 if (!chip->info->ops->phy_read)
2643 return -EOPNOTSUPP;
2644
Vivien Didelotfad09c72016-06-21 12:28:20 -04002645 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002646 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002647 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002648
Andrew Lunnda9f3302017-02-01 03:40:05 +01002649 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002650 /* Some internal PHYs don't have a model number. */
2651 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2652 /* Then there is the 6165 family. It gets is
2653 * PHYs correct. But it can also have two
2654 * SERDES interfaces in the PHY address
2655 * space. And these don't have a model
2656 * number. But they are not PHYs, so we don't
2657 * want to give them something a PHY driver
2658 * will recognise.
2659 *
2660 * Use the mv88e6390 family model number
2661 * instead, for anything which really could be
2662 * a PHY,
2663 */
2664 if (!(val & 0x3f0))
2665 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002666 }
2667
Vivien Didelote57e5e72016-08-15 17:19:00 -04002668 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002669}
2670
Vivien Didelote57e5e72016-08-15 17:19:00 -04002671static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002672{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002673 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2674 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002675 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002676
Andrew Lunnee26a222017-01-24 14:53:48 +01002677 if (!chip->info->ops->phy_write)
2678 return -EOPNOTSUPP;
2679
Vivien Didelotfad09c72016-06-21 12:28:20 -04002680 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002681 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002682 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002683
2684 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002685}
2686
Vivien Didelotfad09c72016-06-21 12:28:20 -04002687static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002688 struct device_node *np,
2689 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002690{
2691 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002692 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002693 struct mii_bus *bus;
2694 int err;
2695
Andrew Lunn2510bab2018-02-22 01:51:49 +01002696 if (external) {
2697 mutex_lock(&chip->reg_lock);
2698 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2699 mutex_unlock(&chip->reg_lock);
2700
2701 if (err)
2702 return err;
2703 }
2704
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002705 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002706 if (!bus)
2707 return -ENOMEM;
2708
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002709 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002710 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002711 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002712 INIT_LIST_HEAD(&mdio_bus->list);
2713 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002714
Andrew Lunnb516d452016-06-04 21:17:06 +02002715 if (np) {
2716 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002717 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002718 } else {
2719 bus->name = "mv88e6xxx SMI";
2720 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2721 }
2722
2723 bus->read = mv88e6xxx_mdio_read;
2724 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002725 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002726
Andrew Lunn6f882842018-03-17 20:32:05 +01002727 if (!external) {
2728 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2729 if (err)
2730 return err;
2731 }
2732
Florian Fainelli00e798c2018-05-15 16:56:19 -07002733 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002734 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002735 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002736 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002737 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002738 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002739
2740 if (external)
2741 list_add_tail(&mdio_bus->list, &chip->mdios);
2742 else
2743 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002744
2745 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002746}
2747
Andrew Lunna3c53be52017-01-24 14:53:50 +01002748static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2749 { .compatible = "marvell,mv88e6xxx-mdio-external",
2750 .data = (void *)true },
2751 { },
2752};
2753
Andrew Lunn3126aee2017-12-07 01:05:57 +01002754static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2755
2756{
2757 struct mv88e6xxx_mdio_bus *mdio_bus;
2758 struct mii_bus *bus;
2759
2760 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2761 bus = mdio_bus->bus;
2762
Andrew Lunn6f882842018-03-17 20:32:05 +01002763 if (!mdio_bus->external)
2764 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2765
Andrew Lunn3126aee2017-12-07 01:05:57 +01002766 mdiobus_unregister(bus);
2767 }
2768}
2769
Andrew Lunna3c53be52017-01-24 14:53:50 +01002770static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2771 struct device_node *np)
2772{
2773 const struct of_device_id *match;
2774 struct device_node *child;
2775 int err;
2776
2777 /* Always register one mdio bus for the internal/default mdio
2778 * bus. This maybe represented in the device tree, but is
2779 * optional.
2780 */
2781 child = of_get_child_by_name(np, "mdio");
2782 err = mv88e6xxx_mdio_register(chip, child, false);
2783 if (err)
2784 return err;
2785
2786 /* Walk the device tree, and see if there are any other nodes
2787 * which say they are compatible with the external mdio
2788 * bus.
2789 */
2790 for_each_available_child_of_node(np, child) {
2791 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2792 if (match) {
2793 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002794 if (err) {
2795 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002796 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002797 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002798 }
2799 }
2800
2801 return 0;
2802}
2803
Vivien Didelot855b1932016-07-20 18:18:35 -04002804static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2805{
Vivien Didelot04bed142016-08-31 18:06:13 -04002806 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002807
2808 return chip->eeprom_len;
2809}
2810
Vivien Didelot855b1932016-07-20 18:18:35 -04002811static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2812 struct ethtool_eeprom *eeprom, u8 *data)
2813{
Vivien Didelot04bed142016-08-31 18:06:13 -04002814 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002815 int err;
2816
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002817 if (!chip->info->ops->get_eeprom)
2818 return -EOPNOTSUPP;
2819
Vivien Didelot855b1932016-07-20 18:18:35 -04002820 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002821 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002822 mutex_unlock(&chip->reg_lock);
2823
2824 if (err)
2825 return err;
2826
2827 eeprom->magic = 0xc3ec4951;
2828
2829 return 0;
2830}
2831
Vivien Didelot855b1932016-07-20 18:18:35 -04002832static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2833 struct ethtool_eeprom *eeprom, u8 *data)
2834{
Vivien Didelot04bed142016-08-31 18:06:13 -04002835 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002836 int err;
2837
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002838 if (!chip->info->ops->set_eeprom)
2839 return -EOPNOTSUPP;
2840
Vivien Didelot855b1932016-07-20 18:18:35 -04002841 if (eeprom->magic != 0xc3ec4951)
2842 return -EINVAL;
2843
2844 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002845 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002846 mutex_unlock(&chip->reg_lock);
2847
2848 return err;
2849}
2850
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002851static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002852 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002853 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2854 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002855 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002856 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002857 .phy_read = mv88e6185_phy_ppu_read,
2858 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002859 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002860 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002861 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002862 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002863 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002864 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002865 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002866 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002867 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002868 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002869 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002870 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002871 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002872 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002873 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002874 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2875 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002876 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002877 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2878 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002879 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002880 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002881 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002882 .ppu_enable = mv88e6185_g1_ppu_enable,
2883 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002884 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002885 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002886 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002887 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002888 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002889};
2890
2891static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002892 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002893 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2894 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002895 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002896 .phy_read = mv88e6185_phy_ppu_read,
2897 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002898 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002899 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002900 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002901 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002902 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002903 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002904 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002905 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002906 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002907 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002908 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2909 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002910 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002911 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002912 .ppu_enable = mv88e6185_g1_ppu_enable,
2913 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002914 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002915 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002916 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002917 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002918};
2919
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002920static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002921 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002922 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2923 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002924 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002925 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2926 .phy_read = mv88e6xxx_g2_smi_phy_read,
2927 .phy_write = mv88e6xxx_g2_smi_phy_write,
2928 .port_set_link = mv88e6xxx_port_set_link,
2929 .port_set_duplex = mv88e6xxx_port_set_duplex,
2930 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002931 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002932 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002933 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002934 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002935 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002936 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002937 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002938 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002939 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002940 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002941 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002942 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002943 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002944 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2945 .stats_get_strings = mv88e6095_stats_get_strings,
2946 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002947 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2948 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002949 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002950 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002951 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002952 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002953 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002954 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002955 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002956 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002957};
2958
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002959static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002960 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002961 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2962 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002963 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002964 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002965 .phy_read = mv88e6xxx_g2_smi_phy_read,
2966 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002967 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002968 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002969 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002970 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002971 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002972 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002973 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002974 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002975 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002976 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002977 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002978 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2979 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002980 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002981 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2982 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002983 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002984 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002985 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002986 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002987 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002988 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002989 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002990};
2991
2992static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002993 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002994 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2995 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002996 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002997 .phy_read = mv88e6185_phy_ppu_read,
2998 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002999 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003000 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003001 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003002 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003003 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003004 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003005 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003006 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003007 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003008 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003009 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003010 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003011 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003012 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003013 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003014 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003015 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3016 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003017 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003018 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3019 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003020 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003021 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003022 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003023 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003024 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003025 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003026 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003027 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003028 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003029};
3030
Vivien Didelot990e27b2017-03-28 13:50:32 -04003031static const struct mv88e6xxx_ops mv88e6141_ops = {
3032 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003033 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3034 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003035 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003036 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3037 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3038 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3039 .phy_read = mv88e6xxx_g2_smi_phy_read,
3040 .phy_write = mv88e6xxx_g2_smi_phy_write,
3041 .port_set_link = mv88e6xxx_port_set_link,
3042 .port_set_duplex = mv88e6xxx_port_set_duplex,
3043 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003044 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003045 .port_tag_remap = mv88e6095_port_tag_remap,
3046 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3047 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3048 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003049 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003050 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003051 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003052 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3053 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003054 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003055 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003056 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003057 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003058 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3059 .stats_get_strings = mv88e6320_stats_get_strings,
3060 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003061 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3062 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003063 .watchdog_ops = &mv88e6390_watchdog_ops,
3064 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003065 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003066 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003067 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003068 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003069 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003070 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003071 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003072};
3073
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003074static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003075 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003076 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3077 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003078 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003079 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003080 .phy_read = mv88e6xxx_g2_smi_phy_read,
3081 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003082 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003083 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003084 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003085 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003086 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003087 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003088 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003089 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003090 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003091 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003092 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003093 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003094 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003095 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003096 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003097 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003098 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3099 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003100 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003101 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3102 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003103 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003104 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003105 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003106 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003107 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003108 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003109 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003110 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003111 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003112};
3113
3114static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003115 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003116 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3117 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003118 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003119 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003120 .phy_read = mv88e6165_phy_read,
3121 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003122 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003123 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003124 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003125 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003126 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003127 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003128 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003129 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003130 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003131 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3132 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003133 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003134 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3135 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003136 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003137 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003138 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003139 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003140 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003141 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003142 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003143 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003144 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003145};
3146
3147static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003148 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003149 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3150 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003151 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003152 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003153 .phy_read = mv88e6xxx_g2_smi_phy_read,
3154 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003155 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003156 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003157 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003158 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003159 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003160 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003161 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003162 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003163 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003164 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003165 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003166 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003167 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003168 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003169 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003170 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003171 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003172 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3173 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003174 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003175 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3176 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003177 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003178 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003179 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003180 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003181 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003182 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003183 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003184};
3185
3186static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003187 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003188 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3189 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003190 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003191 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3192 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003193 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003194 .phy_read = mv88e6xxx_g2_smi_phy_read,
3195 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003196 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003197 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003198 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003199 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003200 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003201 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003202 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003203 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003204 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003205 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003206 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003207 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003208 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003209 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003210 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003211 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003212 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003213 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3214 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003215 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003216 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3217 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003218 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003219 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003220 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003221 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003222 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003223 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003224 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003225 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003226 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003227 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003228};
3229
3230static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003231 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003232 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3233 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003234 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003235 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003236 .phy_read = mv88e6xxx_g2_smi_phy_read,
3237 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003238 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003239 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003240 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003241 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003242 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003243 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003244 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003245 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003246 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003247 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003248 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003249 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003250 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003251 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003252 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003253 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003254 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003255 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3256 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003257 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003258 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3259 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003260 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003261 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003262 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003263 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003264 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003265 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003266 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003267};
3268
3269static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003270 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003271 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3272 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003273 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003274 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3275 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003276 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003277 .phy_read = mv88e6xxx_g2_smi_phy_read,
3278 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003279 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003280 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003281 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003282 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003283 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003284 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003285 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003286 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003287 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003288 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003289 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003290 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003291 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003292 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003293 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003294 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003295 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003296 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3297 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003298 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003299 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3300 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003301 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003302 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003303 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003304 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003305 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003306 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003307 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003308 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003309 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3310 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003311 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003312 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003313};
3314
3315static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003316 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003317 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3318 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003319 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003320 .phy_read = mv88e6185_phy_ppu_read,
3321 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003322 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003323 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003324 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003325 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003326 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003327 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003328 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003329 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003330 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003331 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003332 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003333 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003334 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3335 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003336 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003337 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3338 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003339 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003340 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003341 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003342 .ppu_enable = mv88e6185_g1_ppu_enable,
3343 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003344 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003345 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003346 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003347 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003348};
3349
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003350static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003351 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003352 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003353 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003354 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3355 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003356 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3357 .phy_read = mv88e6xxx_g2_smi_phy_read,
3358 .phy_write = mv88e6xxx_g2_smi_phy_write,
3359 .port_set_link = mv88e6xxx_port_set_link,
3360 .port_set_duplex = mv88e6xxx_port_set_duplex,
3361 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3362 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003363 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003364 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003365 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003366 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003367 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003368 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003369 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003370 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003371 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003372 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003373 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003374 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003375 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3376 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003377 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003378 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3379 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003380 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003381 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003382 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003383 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003384 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003385 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3386 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003387 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003388 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3389 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003390 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003391 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003392};
3393
3394static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003395 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003396 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003397 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003398 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3399 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003400 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3401 .phy_read = mv88e6xxx_g2_smi_phy_read,
3402 .phy_write = mv88e6xxx_g2_smi_phy_write,
3403 .port_set_link = mv88e6xxx_port_set_link,
3404 .port_set_duplex = mv88e6xxx_port_set_duplex,
3405 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3406 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003407 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003408 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003409 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003410 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003411 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003412 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003413 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003414 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003415 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003416 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003417 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003418 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003419 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3420 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003421 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003422 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3423 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003424 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003425 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003426 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003427 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003428 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003429 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3430 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003431 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003432 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3433 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003434 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003435 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003436};
3437
3438static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003439 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003440 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003441 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003442 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3443 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003444 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3445 .phy_read = mv88e6xxx_g2_smi_phy_read,
3446 .phy_write = mv88e6xxx_g2_smi_phy_write,
3447 .port_set_link = mv88e6xxx_port_set_link,
3448 .port_set_duplex = mv88e6xxx_port_set_duplex,
3449 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3450 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003451 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003452 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003453 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003454 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003455 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003456 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003457 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003458 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003459 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003460 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003461 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003462 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003463 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3464 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003465 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003466 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3467 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003468 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003469 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003470 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003471 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003472 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003473 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3474 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003475 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003476 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3477 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003478 .avb_ops = &mv88e6390_avb_ops,
3479 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003480 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003481};
3482
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003483static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003484 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003485 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3486 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003487 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003488 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3489 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003490 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003491 .phy_read = mv88e6xxx_g2_smi_phy_read,
3492 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003493 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003494 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003495 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003496 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003497 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003498 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003499 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003500 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003501 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003502 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003503 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003504 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003505 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003506 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003507 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003508 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003509 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003510 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3511 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003512 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003513 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3514 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003515 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003516 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003517 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003518 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003519 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003520 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003521 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003522 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003523 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3524 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003525 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003526 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003527 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003528 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003529};
3530
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003531static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003532 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003533 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003534 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003535 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3536 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003537 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3538 .phy_read = mv88e6xxx_g2_smi_phy_read,
3539 .phy_write = mv88e6xxx_g2_smi_phy_write,
3540 .port_set_link = mv88e6xxx_port_set_link,
3541 .port_set_duplex = mv88e6xxx_port_set_duplex,
3542 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3543 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003544 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003545 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003546 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003547 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003548 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003549 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003550 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003551 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003552 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003553 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003554 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003555 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003556 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3557 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003558 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003559 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3560 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003561 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003562 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003563 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003564 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003565 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003566 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3567 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003568 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003569 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3570 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003571 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003572 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003573 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003574 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003575};
3576
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003577static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003578 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003579 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3580 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003581 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003582 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3583 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003584 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003585 .phy_read = mv88e6xxx_g2_smi_phy_read,
3586 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003587 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003588 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003589 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003590 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003591 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003592 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003593 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003594 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003595 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003596 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003597 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003598 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003599 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003600 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003601 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003602 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003603 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3604 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003605 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003606 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3607 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003608 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003609 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003610 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003611 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003612 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003613 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003614 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003615 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003616 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003617 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003618};
3619
3620static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003621 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003622 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3623 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003624 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003625 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3626 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003627 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003628 .phy_read = mv88e6xxx_g2_smi_phy_read,
3629 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003630 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003631 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003632 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003633 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003634 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003635 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003636 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003637 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003638 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003639 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003640 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003641 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003642 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003643 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003644 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003645 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003646 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3647 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003648 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003649 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3650 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003651 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003652 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003653 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003654 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003655 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003656 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003657 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003658 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003659};
3660
Vivien Didelot16e329a2017-03-28 13:50:33 -04003661static const struct mv88e6xxx_ops mv88e6341_ops = {
3662 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003663 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3664 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003665 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003666 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3667 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3668 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3669 .phy_read = mv88e6xxx_g2_smi_phy_read,
3670 .phy_write = mv88e6xxx_g2_smi_phy_write,
3671 .port_set_link = mv88e6xxx_port_set_link,
3672 .port_set_duplex = mv88e6xxx_port_set_duplex,
3673 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003674 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003675 .port_tag_remap = mv88e6095_port_tag_remap,
3676 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3677 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3678 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003679 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003680 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003681 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003682 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3683 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003684 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003685 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003686 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003687 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003688 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3689 .stats_get_strings = mv88e6320_stats_get_strings,
3690 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003691 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3692 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003693 .watchdog_ops = &mv88e6390_watchdog_ops,
3694 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003695 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003696 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003697 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003698 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003699 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003700 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003701 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003702 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003703 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003704};
3705
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003706static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003707 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003708 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3709 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003710 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003711 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003712 .phy_read = mv88e6xxx_g2_smi_phy_read,
3713 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003714 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003715 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003716 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003717 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003718 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003719 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003720 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003721 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003722 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003723 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003724 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003725 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003726 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003727 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003728 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003729 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003730 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003731 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3732 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003733 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003734 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3735 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003736 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003737 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003738 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003739 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003740 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003741 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003742 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003743};
3744
3745static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003746 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003747 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3748 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003749 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003750 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003751 .phy_read = mv88e6xxx_g2_smi_phy_read,
3752 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003753 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003754 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003755 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003756 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003757 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003758 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003759 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003760 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003761 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003762 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003763 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003764 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003765 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003766 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003767 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003768 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003769 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003770 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3771 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003772 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003773 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3774 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003775 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003776 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003777 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003778 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003779 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003780 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003781 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003782 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003783 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003784};
3785
3786static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003787 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003788 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3789 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003790 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003791 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3792 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003793 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003794 .phy_read = mv88e6xxx_g2_smi_phy_read,
3795 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003796 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003797 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003798 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003799 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003800 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003801 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003802 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003803 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003804 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003805 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003806 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003807 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003808 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003809 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003810 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003811 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003812 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003813 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3814 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003815 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003816 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3817 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003818 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003819 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003820 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003821 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003822 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003823 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003824 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003825 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003826 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3827 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003828 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003829 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003830 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003831 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3832 .serdes_get_strings = mv88e6352_serdes_get_strings,
3833 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003834 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003835};
3836
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003837static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003838 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003839 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003840 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003841 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3842 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003843 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3844 .phy_read = mv88e6xxx_g2_smi_phy_read,
3845 .phy_write = mv88e6xxx_g2_smi_phy_write,
3846 .port_set_link = mv88e6xxx_port_set_link,
3847 .port_set_duplex = mv88e6xxx_port_set_duplex,
3848 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3849 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003850 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003851 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003852 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003853 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003854 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003855 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003856 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003857 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003858 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003859 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003860 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003861 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003862 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003863 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003864 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3865 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003866 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003867 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3868 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003869 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003870 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003871 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003872 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003873 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003874 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3875 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003876 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003877 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3878 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003879 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003880 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003881 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003882 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003883};
3884
3885static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003886 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003887 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003888 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003889 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3890 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003891 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3892 .phy_read = mv88e6xxx_g2_smi_phy_read,
3893 .phy_write = mv88e6xxx_g2_smi_phy_write,
3894 .port_set_link = mv88e6xxx_port_set_link,
3895 .port_set_duplex = mv88e6xxx_port_set_duplex,
3896 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3897 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003898 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003899 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003900 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003901 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003902 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003903 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003904 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003905 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003906 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003907 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003908 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003909 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003910 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003911 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003912 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3913 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003914 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003915 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3916 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003917 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003918 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003919 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003920 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003921 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003922 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3923 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003924 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003925 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3926 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003927 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003928 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003929 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003930 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003931};
3932
Vivien Didelotf81ec902016-05-09 13:22:58 -04003933static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3934 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003935 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003936 .family = MV88E6XXX_FAMILY_6097,
3937 .name = "Marvell 88E6085",
3938 .num_databases = 4096,
3939 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003940 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003941 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003942 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003943 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003944 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003945 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003946 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003947 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003948 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003949 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003950 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003951 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003952 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003953 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003954 },
3955
3956 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003957 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003958 .family = MV88E6XXX_FAMILY_6095,
3959 .name = "Marvell 88E6095/88E6095F",
3960 .num_databases = 256,
3961 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003962 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003963 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003964 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003965 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003966 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003967 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003968 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003969 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003970 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003971 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003972 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003973 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003974 },
3975
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003976 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003977 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003978 .family = MV88E6XXX_FAMILY_6097,
3979 .name = "Marvell 88E6097/88E6097F",
3980 .num_databases = 4096,
3981 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003982 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003983 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003984 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003985 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003986 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003987 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003988 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003989 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003990 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003991 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003992 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003993 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003994 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003995 .ops = &mv88e6097_ops,
3996 },
3997
Vivien Didelotf81ec902016-05-09 13:22:58 -04003998 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003999 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004000 .family = MV88E6XXX_FAMILY_6165,
4001 .name = "Marvell 88E6123",
4002 .num_databases = 4096,
4003 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004004 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004005 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004006 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004007 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004008 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004009 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004010 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004011 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004012 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004013 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004014 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004015 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004016 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004017 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004018 },
4019
4020 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004021 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004022 .family = MV88E6XXX_FAMILY_6185,
4023 .name = "Marvell 88E6131",
4024 .num_databases = 256,
4025 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004026 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004027 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004028 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004029 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004030 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004031 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004032 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004033 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004034 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004035 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004036 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004037 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004038 },
4039
Vivien Didelot990e27b2017-03-28 13:50:32 -04004040 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004041 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004042 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004043 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004044 .num_databases = 4096,
4045 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004046 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004047 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004048 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004049 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004050 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004051 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004052 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004053 .age_time_coeff = 3750,
4054 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004055 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004056 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004057 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004058 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004059 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004060 .ops = &mv88e6141_ops,
4061 },
4062
Vivien Didelotf81ec902016-05-09 13:22:58 -04004063 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004064 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004065 .family = MV88E6XXX_FAMILY_6165,
4066 .name = "Marvell 88E6161",
4067 .num_databases = 4096,
4068 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004069 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004070 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004071 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004072 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004073 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004074 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004075 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004076 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004077 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004078 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004079 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004080 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004081 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004082 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004083 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004084 },
4085
4086 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004087 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004088 .family = MV88E6XXX_FAMILY_6165,
4089 .name = "Marvell 88E6165",
4090 .num_databases = 4096,
4091 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004092 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004093 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004094 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004095 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004096 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004097 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004098 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004099 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004100 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004101 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004102 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004103 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004104 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004105 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004106 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004107 },
4108
4109 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004110 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004111 .family = MV88E6XXX_FAMILY_6351,
4112 .name = "Marvell 88E6171",
4113 .num_databases = 4096,
4114 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004115 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004116 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004117 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004118 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004119 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004120 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004121 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004122 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004123 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004124 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004125 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004126 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004127 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004128 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004129 },
4130
4131 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004132 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004133 .family = MV88E6XXX_FAMILY_6352,
4134 .name = "Marvell 88E6172",
4135 .num_databases = 4096,
4136 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004137 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004138 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004139 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004140 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004141 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004142 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004143 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004144 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004145 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004146 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004147 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004148 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004149 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004150 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004151 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004152 },
4153
4154 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004155 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004156 .family = MV88E6XXX_FAMILY_6351,
4157 .name = "Marvell 88E6175",
4158 .num_databases = 4096,
4159 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004160 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004161 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004162 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004163 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004164 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004165 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004166 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004167 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004168 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004169 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004170 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004171 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004172 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004173 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004174 },
4175
4176 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004177 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004178 .family = MV88E6XXX_FAMILY_6352,
4179 .name = "Marvell 88E6176",
4180 .num_databases = 4096,
4181 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004182 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004183 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004184 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004185 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004186 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004187 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004188 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004189 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004190 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004191 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004192 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004193 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004194 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004195 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004196 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004197 },
4198
4199 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004200 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004201 .family = MV88E6XXX_FAMILY_6185,
4202 .name = "Marvell 88E6185",
4203 .num_databases = 256,
4204 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004205 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004206 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004207 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004208 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004209 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004210 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004211 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004212 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004213 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004214 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004215 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004216 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004217 },
4218
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004219 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004220 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004221 .family = MV88E6XXX_FAMILY_6390,
4222 .name = "Marvell 88E6190",
4223 .num_databases = 4096,
4224 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004225 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004226 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004227 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004228 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004229 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004230 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004231 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004232 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004233 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004234 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004235 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004236 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004237 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004238 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004239 .ops = &mv88e6190_ops,
4240 },
4241
4242 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004243 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004244 .family = MV88E6XXX_FAMILY_6390,
4245 .name = "Marvell 88E6190X",
4246 .num_databases = 4096,
4247 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004248 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004249 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004250 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004251 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004252 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004253 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004254 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004255 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004256 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004257 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004258 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004259 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004260 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004261 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004262 .ops = &mv88e6190x_ops,
4263 },
4264
4265 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004266 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004267 .family = MV88E6XXX_FAMILY_6390,
4268 .name = "Marvell 88E6191",
4269 .num_databases = 4096,
4270 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004271 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004272 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004273 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004274 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004275 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004276 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004277 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004278 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004279 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004280 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004281 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004282 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004283 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004284 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004285 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004286 },
4287
Vivien Didelotf81ec902016-05-09 13:22:58 -04004288 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004289 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004290 .family = MV88E6XXX_FAMILY_6352,
4291 .name = "Marvell 88E6240",
4292 .num_databases = 4096,
4293 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004294 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004295 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004296 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004297 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004298 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004299 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004300 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004301 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004302 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004303 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004304 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004305 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004306 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004307 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004308 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004309 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004310 },
4311
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004312 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004313 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004314 .family = MV88E6XXX_FAMILY_6390,
4315 .name = "Marvell 88E6290",
4316 .num_databases = 4096,
4317 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004318 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004319 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004320 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004321 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004322 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004323 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004324 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004325 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004326 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004327 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004328 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004329 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004330 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004331 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004332 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004333 .ops = &mv88e6290_ops,
4334 },
4335
Vivien Didelotf81ec902016-05-09 13:22:58 -04004336 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004337 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004338 .family = MV88E6XXX_FAMILY_6320,
4339 .name = "Marvell 88E6320",
4340 .num_databases = 4096,
4341 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004342 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004343 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004344 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004345 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004346 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004347 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004348 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004349 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004350 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004351 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004352 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004353 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004354 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004355 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004356 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004357 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004358 },
4359
4360 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004361 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004362 .family = MV88E6XXX_FAMILY_6320,
4363 .name = "Marvell 88E6321",
4364 .num_databases = 4096,
4365 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004366 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004367 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004368 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004369 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004370 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004371 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004372 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004373 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004374 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004375 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004376 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004377 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004378 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004379 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004380 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004381 },
4382
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004383 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004384 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004385 .family = MV88E6XXX_FAMILY_6341,
4386 .name = "Marvell 88E6341",
4387 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004388 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004389 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004390 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004391 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004392 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004393 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004394 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004395 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004396 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004397 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004398 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004399 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004400 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004401 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004402 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004403 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004404 .ops = &mv88e6341_ops,
4405 },
4406
Vivien Didelotf81ec902016-05-09 13:22:58 -04004407 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004408 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004409 .family = MV88E6XXX_FAMILY_6351,
4410 .name = "Marvell 88E6350",
4411 .num_databases = 4096,
4412 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004413 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004414 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004415 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004416 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004417 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004418 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004419 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004420 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004421 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004422 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004423 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004424 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004425 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004426 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004427 },
4428
4429 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004430 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004431 .family = MV88E6XXX_FAMILY_6351,
4432 .name = "Marvell 88E6351",
4433 .num_databases = 4096,
4434 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004435 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004436 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004437 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004438 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004439 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004440 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004441 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004442 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004443 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004444 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004445 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004446 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004447 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004448 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004449 },
4450
4451 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004452 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004453 .family = MV88E6XXX_FAMILY_6352,
4454 .name = "Marvell 88E6352",
4455 .num_databases = 4096,
4456 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004457 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004458 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004459 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004460 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004461 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004462 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004463 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004464 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004465 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004466 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004467 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004468 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004469 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004470 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004471 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004472 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004473 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004474 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004475 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004476 .family = MV88E6XXX_FAMILY_6390,
4477 .name = "Marvell 88E6390",
4478 .num_databases = 4096,
4479 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004480 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004481 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004482 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004483 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004484 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004485 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004486 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004487 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004488 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004489 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004490 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004491 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004492 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004493 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004494 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004495 .ops = &mv88e6390_ops,
4496 },
4497 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004498 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004499 .family = MV88E6XXX_FAMILY_6390,
4500 .name = "Marvell 88E6390X",
4501 .num_databases = 4096,
4502 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004503 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004504 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004505 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004506 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004507 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004508 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004509 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004510 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004511 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004512 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004513 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004514 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004515 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004516 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004517 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004518 .ops = &mv88e6390x_ops,
4519 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004520};
4521
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004522static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004523{
Vivien Didelota439c062016-04-17 13:23:58 -04004524 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004525
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004526 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4527 if (mv88e6xxx_table[i].prod_num == prod_num)
4528 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004529
Vivien Didelotb9b37712015-10-30 19:39:48 -04004530 return NULL;
4531}
4532
Vivien Didelotfad09c72016-06-21 12:28:20 -04004533static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004534{
4535 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004536 unsigned int prod_num, rev;
4537 u16 id;
4538 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004539
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004540 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004541 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004542 mutex_unlock(&chip->reg_lock);
4543 if (err)
4544 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004545
Vivien Didelot107fcc12017-06-12 12:37:36 -04004546 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4547 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004548
4549 info = mv88e6xxx_lookup_info(prod_num);
4550 if (!info)
4551 return -ENODEV;
4552
Vivien Didelotcaac8542016-06-20 13:14:09 -04004553 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004554 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004555
Vivien Didelotca070c12016-09-02 14:45:34 -04004556 err = mv88e6xxx_g2_require(chip);
4557 if (err)
4558 return err;
4559
Vivien Didelotfad09c72016-06-21 12:28:20 -04004560 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4561 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004562
4563 return 0;
4564}
4565
Vivien Didelotfad09c72016-06-21 12:28:20 -04004566static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004567{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004568 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004569
Vivien Didelotfad09c72016-06-21 12:28:20 -04004570 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4571 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004572 return NULL;
4573
Vivien Didelotfad09c72016-06-21 12:28:20 -04004574 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004575
Vivien Didelotfad09c72016-06-21 12:28:20 -04004576 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004577 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004578
Vivien Didelotfad09c72016-06-21 12:28:20 -04004579 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004580}
4581
Vivien Didelotfad09c72016-06-21 12:28:20 -04004582static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004583 struct mii_bus *bus, int sw_addr)
4584{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004585 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004586 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004587 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004588 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004589 else
4590 return -EINVAL;
4591
Vivien Didelotfad09c72016-06-21 12:28:20 -04004592 chip->bus = bus;
4593 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004594
4595 return 0;
4596}
4597
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004598static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4599 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004600{
Vivien Didelot04bed142016-08-31 18:06:13 -04004601 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004602
Andrew Lunn443d5a12016-12-03 04:35:18 +01004603 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004604}
4605
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004606#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004607static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4608 struct device *host_dev, int sw_addr,
4609 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004610{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004611 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004612 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004613 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004614
Vivien Didelota439c062016-04-17 13:23:58 -04004615 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004616 if (!bus)
4617 return NULL;
4618
Vivien Didelotfad09c72016-06-21 12:28:20 -04004619 chip = mv88e6xxx_alloc_chip(dsa_dev);
4620 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004621 return NULL;
4622
Vivien Didelotcaac8542016-06-20 13:14:09 -04004623 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004624 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004625
Vivien Didelotfad09c72016-06-21 12:28:20 -04004626 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004627 if (err)
4628 goto free;
4629
Vivien Didelotfad09c72016-06-21 12:28:20 -04004630 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004631 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004632 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004633
Andrew Lunndc30c352016-10-16 19:56:49 +02004634 mutex_lock(&chip->reg_lock);
4635 err = mv88e6xxx_switch_reset(chip);
4636 mutex_unlock(&chip->reg_lock);
4637 if (err)
4638 goto free;
4639
Vivien Didelote57e5e72016-08-15 17:19:00 -04004640 mv88e6xxx_phy_init(chip);
4641
Andrew Lunna3c53be52017-01-24 14:53:50 +01004642 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004643 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004644 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004645
Vivien Didelotfad09c72016-06-21 12:28:20 -04004646 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004647
Vivien Didelotfad09c72016-06-21 12:28:20 -04004648 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004649free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004650 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004651
4652 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004653}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004654#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004655
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004656static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004657 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004658{
4659 /* We don't need any dynamic resource from the kernel (yet),
4660 * so skip the prepare phase.
4661 */
4662
4663 return 0;
4664}
4665
4666static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004667 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004668{
Vivien Didelot04bed142016-08-31 18:06:13 -04004669 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004670
4671 mutex_lock(&chip->reg_lock);
4672 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004673 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004674 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4675 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004676 mutex_unlock(&chip->reg_lock);
4677}
4678
4679static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4680 const struct switchdev_obj_port_mdb *mdb)
4681{
Vivien Didelot04bed142016-08-31 18:06:13 -04004682 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004683 int err;
4684
4685 mutex_lock(&chip->reg_lock);
4686 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004687 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004688 mutex_unlock(&chip->reg_lock);
4689
4690 return err;
4691}
4692
Florian Fainellia82f67a2017-01-08 14:52:08 -08004693static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004694#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004695 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004696#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004697 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004698 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004699 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004700 .phylink_validate = mv88e6xxx_validate,
4701 .phylink_mac_link_state = mv88e6xxx_link_state,
4702 .phylink_mac_config = mv88e6xxx_mac_config,
4703 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4704 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004705 .get_strings = mv88e6xxx_get_strings,
4706 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4707 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004708 .port_enable = mv88e6xxx_port_enable,
4709 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004710 .get_mac_eee = mv88e6xxx_get_mac_eee,
4711 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004712 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004713 .get_eeprom = mv88e6xxx_get_eeprom,
4714 .set_eeprom = mv88e6xxx_set_eeprom,
4715 .get_regs_len = mv88e6xxx_get_regs_len,
4716 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004717 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004718 .port_bridge_join = mv88e6xxx_port_bridge_join,
4719 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4720 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004721 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004722 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4723 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4724 .port_vlan_add = mv88e6xxx_port_vlan_add,
4725 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004726 .port_fdb_add = mv88e6xxx_port_fdb_add,
4727 .port_fdb_del = mv88e6xxx_port_fdb_del,
4728 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004729 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4730 .port_mdb_add = mv88e6xxx_port_mdb_add,
4731 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004732 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4733 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004734 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4735 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4736 .port_txtstamp = mv88e6xxx_port_txtstamp,
4737 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4738 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004739};
4740
Florian Fainelliab3d4082017-01-08 14:52:07 -08004741static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4742 .ops = &mv88e6xxx_switch_ops,
4743};
4744
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004745static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004746{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004747 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004748 struct dsa_switch *ds;
4749
Vivien Didelot73b12042017-03-30 17:37:10 -04004750 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004751 if (!ds)
4752 return -ENOMEM;
4753
Vivien Didelotfad09c72016-06-21 12:28:20 -04004754 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004755 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004756 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004757 ds->ageing_time_min = chip->info->age_time_coeff;
4758 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004759
4760 dev_set_drvdata(dev, ds);
4761
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004762 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004763}
4764
Vivien Didelotfad09c72016-06-21 12:28:20 -04004765static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004766{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004767 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004768}
4769
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004770static const void *pdata_device_get_match_data(struct device *dev)
4771{
4772 const struct of_device_id *matches = dev->driver->of_match_table;
4773 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4774
4775 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4776 matches++) {
4777 if (!strcmp(pdata->compatible, matches->compatible))
4778 return matches->data;
4779 }
4780 return NULL;
4781}
4782
Vivien Didelot57d32312016-06-20 13:13:58 -04004783static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004784{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004785 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004786 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004787 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004788 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004789 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004790 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004791 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004792
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004793 if (!np && !pdata)
4794 return -EINVAL;
4795
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004796 if (np)
4797 compat_info = of_device_get_match_data(dev);
4798
4799 if (pdata) {
4800 compat_info = pdata_device_get_match_data(dev);
4801
4802 if (!pdata->netdev)
4803 return -EINVAL;
4804
4805 for (port = 0; port < DSA_MAX_PORTS; port++) {
4806 if (!(pdata->enabled_ports & (1 << port)))
4807 continue;
4808 if (strcmp(pdata->cd.port_names[port], "cpu"))
4809 continue;
4810 pdata->cd.netdev[port] = &pdata->netdev->dev;
4811 break;
4812 }
4813 }
4814
Vivien Didelotcaac8542016-06-20 13:14:09 -04004815 if (!compat_info)
4816 return -EINVAL;
4817
Vivien Didelotfad09c72016-06-21 12:28:20 -04004818 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004819 if (!chip) {
4820 err = -ENOMEM;
4821 goto out;
4822 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004823
Vivien Didelotfad09c72016-06-21 12:28:20 -04004824 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004825
Vivien Didelotfad09c72016-06-21 12:28:20 -04004826 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004827 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004828 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004829
Andrew Lunnb4308f02016-11-21 23:26:55 +01004830 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004831 if (IS_ERR(chip->reset)) {
4832 err = PTR_ERR(chip->reset);
4833 goto out;
4834 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004835
Vivien Didelotfad09c72016-06-21 12:28:20 -04004836 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004837 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004838 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004839
Vivien Didelote57e5e72016-08-15 17:19:00 -04004840 mv88e6xxx_phy_init(chip);
4841
Andrew Lunn00baabe2018-05-19 22:31:35 +02004842 if (chip->info->ops->get_eeprom) {
4843 if (np)
4844 of_property_read_u32(np, "eeprom-length",
4845 &chip->eeprom_len);
4846 else
4847 chip->eeprom_len = pdata->eeprom_len;
4848 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004849
Andrew Lunndc30c352016-10-16 19:56:49 +02004850 mutex_lock(&chip->reg_lock);
4851 err = mv88e6xxx_switch_reset(chip);
4852 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004853 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004854 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004855
Andrew Lunndc30c352016-10-16 19:56:49 +02004856 chip->irq = of_irq_get(np, 0);
4857 if (chip->irq == -EPROBE_DEFER) {
4858 err = chip->irq;
4859 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004860 }
4861
Andrew Lunn294d7112018-02-22 22:58:32 +01004862 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004863 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004864 * controllers
4865 */
4866 mutex_lock(&chip->reg_lock);
4867 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004868 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004869 else
4870 err = mv88e6xxx_irq_poll_setup(chip);
4871 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004872
Andrew Lunn294d7112018-02-22 22:58:32 +01004873 if (err)
4874 goto out;
4875
4876 if (chip->info->g2_irqs > 0) {
4877 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004878 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004879 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004880 }
4881
Andrew Lunn294d7112018-02-22 22:58:32 +01004882 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4883 if (err)
4884 goto out_g2_irq;
4885
4886 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4887 if (err)
4888 goto out_g1_atu_prob_irq;
4889
Andrew Lunna3c53be52017-01-24 14:53:50 +01004890 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004891 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004892 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004893
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004894 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004895 if (err)
4896 goto out_mdio;
4897
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004898 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004899
4900out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004901 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004902out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004903 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004904out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004905 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004906out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004907 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004908 mv88e6xxx_g2_irq_free(chip);
4909out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004910 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004911 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004912 else
4913 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004914out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004915 if (pdata)
4916 dev_put(pdata->netdev);
4917
Andrew Lunndc30c352016-10-16 19:56:49 +02004918 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004919}
4920
4921static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4922{
4923 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004924 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004925
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004926 if (chip->info->ptp_support) {
4927 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004928 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004929 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004930
Andrew Lunn930188c2016-08-22 16:01:03 +02004931 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004932 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004933 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004934
Andrew Lunn76f38f12018-03-17 20:21:09 +01004935 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4936 mv88e6xxx_g1_atu_prob_irq_free(chip);
4937
4938 if (chip->info->g2_irqs > 0)
4939 mv88e6xxx_g2_irq_free(chip);
4940
Andrew Lunn76f38f12018-03-17 20:21:09 +01004941 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004942 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004943 else
4944 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004945}
4946
4947static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004948 {
4949 .compatible = "marvell,mv88e6085",
4950 .data = &mv88e6xxx_table[MV88E6085],
4951 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004952 {
4953 .compatible = "marvell,mv88e6190",
4954 .data = &mv88e6xxx_table[MV88E6190],
4955 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004956 { /* sentinel */ },
4957};
4958
4959MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4960
4961static struct mdio_driver mv88e6xxx_driver = {
4962 .probe = mv88e6xxx_probe,
4963 .remove = mv88e6xxx_remove,
4964 .mdiodrv.driver = {
4965 .name = "mv88e6085",
4966 .of_match_table = mv88e6xxx_of_match,
4967 },
4968};
4969
Ben Hutchings98e67302011-11-25 14:36:19 +00004970static int __init mv88e6xxx_init(void)
4971{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004972 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004973 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004974}
4975module_init(mv88e6xxx_init);
4976
4977static void __exit mv88e6xxx_cleanup(void)
4978{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004979 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004980 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004981}
4982module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004983
4984MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4985MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4986MODULE_LICENSE("GPL");