blob: 3f9a3fc52a0e7179510d9bd7c07a82b2e55f592f [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
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800483 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100484 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{
Andrew Lunnec260162019-02-08 22:25:44 +0100666 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200667 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100668 phylink_set(mask, 2500baseT_Full);
669 }
Russell King6c422e32018-08-09 15:38:39 +0200670
671 /* No ethtool bits for 200Mbps */
672 phylink_set(mask, 1000baseT_Full);
673 phylink_set(mask, 1000baseX_Full);
674
675 mv88e6065_phylink_validate(chip, port, mask, state);
676}
677
678static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
679 unsigned long *mask,
680 struct phylink_link_state *state)
681{
682 if (port >= 9) {
683 phylink_set(mask, 10000baseT_Full);
684 phylink_set(mask, 10000baseKR_Full);
685 }
686
687 mv88e6390_phylink_validate(chip, port, mask, state);
688}
689
Russell Kingc9a23562018-05-10 13:17:35 -0700690static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
691 unsigned long *supported,
692 struct phylink_link_state *state)
693{
Russell King6c422e32018-08-09 15:38:39 +0200694 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
695 struct mv88e6xxx_chip *chip = ds->priv;
696
697 /* Allow all the expected bits */
698 phylink_set(mask, Autoneg);
699 phylink_set(mask, Pause);
700 phylink_set_port_modes(mask);
701
702 if (chip->info->ops->phylink_validate)
703 chip->info->ops->phylink_validate(chip, port, mask, state);
704
705 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
706 bitmap_and(state->advertising, state->advertising, mask,
707 __ETHTOOL_LINK_MODE_MASK_NBITS);
708
709 /* We can only operate at 2500BaseX or 1000BaseX. If requested
710 * to advertise both, only report advertising at 2500BaseX.
711 */
712 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700713}
714
715static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
716 struct phylink_link_state *state)
717{
718 struct mv88e6xxx_chip *chip = ds->priv;
719 int err;
720
721 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200722 if (chip->info->ops->port_link_state)
723 err = chip->info->ops->port_link_state(chip, port, state);
724 else
725 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700726 mutex_unlock(&chip->reg_lock);
727
728 return err;
729}
730
731static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
732 unsigned int mode,
733 const struct phylink_link_state *state)
734{
735 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200736 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700737
Marek Vasutd700ec42018-09-12 00:15:24 +0200738 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700739 return;
740
741 if (mode == MLO_AN_FIXED) {
742 link = LINK_FORCED_UP;
743 speed = state->speed;
744 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200745 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
746 link = state->link;
747 speed = state->speed;
748 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700749 } else {
750 speed = SPEED_UNFORCED;
751 duplex = DUPLEX_UNFORCED;
752 link = LINK_UNFORCED;
753 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200754 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700755
756 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200757 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700758 state->interface);
759 mutex_unlock(&chip->reg_lock);
760
761 if (err && err != -EOPNOTSUPP)
762 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
763}
764
765static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
766{
767 struct mv88e6xxx_chip *chip = ds->priv;
768 int err;
769
770 mutex_lock(&chip->reg_lock);
771 err = chip->info->ops->port_set_link(chip, port, link);
772 mutex_unlock(&chip->reg_lock);
773
774 if (err)
775 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
776}
777
778static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
779 unsigned int mode,
780 phy_interface_t interface)
781{
782 if (mode == MLO_AN_FIXED)
783 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
784}
785
786static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
787 unsigned int mode, phy_interface_t interface,
788 struct phy_device *phydev)
789{
790 if (mode == MLO_AN_FIXED)
791 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
792}
793
Andrew Lunna605a0f2016-11-21 23:26:58 +0100794static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000795{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100796 if (!chip->info->ops->stats_snapshot)
797 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000798
Andrew Lunna605a0f2016-11-21 23:26:58 +0100799 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000800}
801
Andrew Lunne413e7e2015-04-02 04:06:38 +0200802static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100803 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
804 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
805 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
806 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
807 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
808 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
809 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
810 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
811 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
812 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
813 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
814 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
815 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
816 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
817 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
818 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
819 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
820 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
821 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
822 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
823 { "single", 4, 0x14, STATS_TYPE_BANK0, },
824 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
825 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
826 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
827 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
828 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
829 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
830 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
831 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
832 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
833 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
834 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
835 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
836 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
837 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
838 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
839 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
840 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
841 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
842 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
843 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
844 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
845 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
846 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
847 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
848 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
849 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
850 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
851 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
852 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
853 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
854 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
855 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
856 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
857 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
858 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
859 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
860 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
861 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200862};
863
Vivien Didelotfad09c72016-06-21 12:28:20 -0400864static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100865 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100866 int port, u16 bank1_select,
867 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200868{
Andrew Lunn80c46272015-06-20 18:42:30 +0200869 u32 low;
870 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100871 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200872 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200873 u64 value;
874
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100875 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100876 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200877 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
878 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800879 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200880
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200881 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100882 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200883 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
884 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800885 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200886 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200887 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100888 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100889 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100890 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100891 /* fall through */
892 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100893 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100894 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100895 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100896 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500897 break;
898 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800899 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200900 }
901 value = (((u64)high) << 16) | low;
902 return value;
903}
904
Andrew Lunn436fe172018-03-01 02:02:29 +0100905static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
906 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100907{
908 struct mv88e6xxx_hw_stat *stat;
909 int i, j;
910
911 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
912 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100913 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100914 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
915 ETH_GSTRING_LEN);
916 j++;
917 }
918 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100919
920 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100921}
922
Andrew Lunn436fe172018-03-01 02:02:29 +0100923static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
924 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100925{
Andrew Lunn436fe172018-03-01 02:02:29 +0100926 return mv88e6xxx_stats_get_strings(chip, data,
927 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100928}
929
Andrew Lunn436fe172018-03-01 02:02:29 +0100930static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
931 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100932{
Andrew Lunn436fe172018-03-01 02:02:29 +0100933 return mv88e6xxx_stats_get_strings(chip, data,
934 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100935}
936
Andrew Lunn65f60e42018-03-28 23:50:28 +0200937static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
938 "atu_member_violation",
939 "atu_miss_violation",
940 "atu_full_violation",
941 "vtu_member_violation",
942 "vtu_miss_violation",
943};
944
945static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
946{
947 unsigned int i;
948
949 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
950 strlcpy(data + i * ETH_GSTRING_LEN,
951 mv88e6xxx_atu_vtu_stats_strings[i],
952 ETH_GSTRING_LEN);
953}
954
Andrew Lunndfafe442016-11-21 23:27:02 +0100955static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700956 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100957{
Vivien Didelot04bed142016-08-31 18:06:13 -0400958 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100959 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100960
Florian Fainelli89f09042018-04-25 12:12:50 -0700961 if (stringset != ETH_SS_STATS)
962 return;
963
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100964 mutex_lock(&chip->reg_lock);
965
Andrew Lunndfafe442016-11-21 23:27:02 +0100966 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100967 count = chip->info->ops->stats_get_strings(chip, data);
968
969 if (chip->info->ops->serdes_get_strings) {
970 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200971 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100972 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100973
Andrew Lunn65f60e42018-03-28 23:50:28 +0200974 data += count * ETH_GSTRING_LEN;
975 mv88e6xxx_atu_vtu_get_strings(data);
976
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100977 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100978}
979
980static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
981 int types)
982{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100983 struct mv88e6xxx_hw_stat *stat;
984 int i, j;
985
986 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
987 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100988 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100989 j++;
990 }
991 return j;
992}
993
Andrew Lunndfafe442016-11-21 23:27:02 +0100994static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
995{
996 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
997 STATS_TYPE_PORT);
998}
999
1000static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1001{
1002 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1003 STATS_TYPE_BANK1);
1004}
1005
Florian Fainelli89f09042018-04-25 12:12:50 -07001006static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001007{
1008 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001009 int serdes_count = 0;
1010 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001011
Florian Fainelli89f09042018-04-25 12:12:50 -07001012 if (sset != ETH_SS_STATS)
1013 return 0;
1014
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001015 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001016 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001017 count = chip->info->ops->stats_get_sset_count(chip);
1018 if (count < 0)
1019 goto out;
1020
1021 if (chip->info->ops->serdes_get_sset_count)
1022 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1023 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001024 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001025 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001026 goto out;
1027 }
1028 count += serdes_count;
1029 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1030
Andrew Lunn436fe172018-03-01 02:02:29 +01001031out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001032 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001033
Andrew Lunn436fe172018-03-01 02:02:29 +01001034 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001035}
1036
Andrew Lunn436fe172018-03-01 02:02:29 +01001037static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1038 uint64_t *data, int types,
1039 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001040{
1041 struct mv88e6xxx_hw_stat *stat;
1042 int i, j;
1043
1044 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1045 stat = &mv88e6xxx_hw_stats[i];
1046 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001047 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001048 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1049 bank1_select,
1050 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001051 mutex_unlock(&chip->reg_lock);
1052
Andrew Lunn052f9472016-11-21 23:27:03 +01001053 j++;
1054 }
1055 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001056 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001057}
1058
Andrew Lunn436fe172018-03-01 02:02:29 +01001059static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1060 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001061{
1062 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001063 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001064 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001065}
1066
Andrew Lunn436fe172018-03-01 02:02:29 +01001067static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1068 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001069{
1070 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001071 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001072 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1073 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001074}
1075
Andrew Lunn436fe172018-03-01 02:02:29 +01001076static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1077 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001078{
1079 return mv88e6xxx_stats_get_stats(chip, port, data,
1080 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001081 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1082 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001083}
1084
Andrew Lunn65f60e42018-03-28 23:50:28 +02001085static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1086 uint64_t *data)
1087{
1088 *data++ = chip->ports[port].atu_member_violation;
1089 *data++ = chip->ports[port].atu_miss_violation;
1090 *data++ = chip->ports[port].atu_full_violation;
1091 *data++ = chip->ports[port].vtu_member_violation;
1092 *data++ = chip->ports[port].vtu_miss_violation;
1093}
1094
Andrew Lunn052f9472016-11-21 23:27:03 +01001095static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1096 uint64_t *data)
1097{
Andrew Lunn436fe172018-03-01 02:02:29 +01001098 int count = 0;
1099
Andrew Lunn052f9472016-11-21 23:27:03 +01001100 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001101 count = chip->info->ops->stats_get_stats(chip, port, data);
1102
Andrew Lunn65f60e42018-03-28 23:50:28 +02001103 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001104 if (chip->info->ops->serdes_get_stats) {
1105 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001106 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001107 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001108 data += count;
1109 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1110 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001111}
1112
Vivien Didelotf81ec902016-05-09 13:22:58 -04001113static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1114 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001115{
Vivien Didelot04bed142016-08-31 18:06:13 -04001116 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001117 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001118
Vivien Didelotfad09c72016-06-21 12:28:20 -04001119 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001120
Andrew Lunna605a0f2016-11-21 23:26:58 +01001121 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001122 mutex_unlock(&chip->reg_lock);
1123
1124 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001125 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001126
1127 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001128
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001129}
Ben Hutchings98e67302011-11-25 14:36:19 +00001130
Vivien Didelotf81ec902016-05-09 13:22:58 -04001131static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001132{
1133 return 32 * sizeof(u16);
1134}
1135
Vivien Didelotf81ec902016-05-09 13:22:58 -04001136static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1137 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138{
Vivien Didelot04bed142016-08-31 18:06:13 -04001139 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001140 int err;
1141 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001142 u16 *p = _p;
1143 int i;
1144
Vivien Didelota5f39322018-12-17 16:05:21 -05001145 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001146
1147 memset(p, 0xff, 32 * sizeof(u16));
1148
Vivien Didelotfad09c72016-06-21 12:28:20 -04001149 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001150
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001151 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001152
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001153 err = mv88e6xxx_port_read(chip, port, i, &reg);
1154 if (!err)
1155 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001156 }
Vivien Didelot23062512016-05-09 13:22:45 -04001157
Vivien Didelotfad09c72016-06-21 12:28:20 -04001158 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001159}
1160
Vivien Didelot08f50062017-08-01 16:32:41 -04001161static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1162 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001163{
Vivien Didelot5480db62017-08-01 16:32:40 -04001164 /* Nothing to do on the port's MAC */
1165 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001166}
1167
Vivien Didelot08f50062017-08-01 16:32:41 -04001168static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1169 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001170{
Vivien Didelot5480db62017-08-01 16:32:40 -04001171 /* Nothing to do on the port's MAC */
1172 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001173}
1174
Vivien Didelote5887a22017-03-30 17:37:11 -04001175static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001176{
Vivien Didelote5887a22017-03-30 17:37:11 -04001177 struct dsa_switch *ds = NULL;
1178 struct net_device *br;
1179 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001180 int i;
1181
Vivien Didelote5887a22017-03-30 17:37:11 -04001182 if (dev < DSA_MAX_SWITCHES)
1183 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001184
Vivien Didelote5887a22017-03-30 17:37:11 -04001185 /* Prevent frames from unknown switch or port */
1186 if (!ds || port >= ds->num_ports)
1187 return 0;
1188
1189 /* Frames from DSA links and CPU ports can egress any local port */
1190 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1191 return mv88e6xxx_port_mask(chip);
1192
1193 br = ds->ports[port].bridge_dev;
1194 pvlan = 0;
1195
1196 /* Frames from user ports can egress any local DSA links and CPU ports,
1197 * as well as any local member of their bridge group.
1198 */
1199 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1200 if (dsa_is_cpu_port(chip->ds, i) ||
1201 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001202 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001203 pvlan |= BIT(i);
1204
1205 return pvlan;
1206}
1207
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001208static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001209{
1210 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001211
1212 /* prevent frames from going back out of the port they came in on */
1213 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001214
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001215 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001216}
1217
Vivien Didelotf81ec902016-05-09 13:22:58 -04001218static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1219 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001220{
Vivien Didelot04bed142016-08-31 18:06:13 -04001221 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001222 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001223
Vivien Didelotfad09c72016-06-21 12:28:20 -04001224 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001225 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001226 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001227
1228 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001229 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001230}
1231
Vivien Didelot93e18d62018-05-11 17:16:35 -04001232static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1233{
1234 int err;
1235
1236 if (chip->info->ops->ieee_pri_map) {
1237 err = chip->info->ops->ieee_pri_map(chip);
1238 if (err)
1239 return err;
1240 }
1241
1242 if (chip->info->ops->ip_pri_map) {
1243 err = chip->info->ops->ip_pri_map(chip);
1244 if (err)
1245 return err;
1246 }
1247
1248 return 0;
1249}
1250
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001251static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1252{
1253 int target, port;
1254 int err;
1255
1256 if (!chip->info->global2_addr)
1257 return 0;
1258
1259 /* Initialize the routing port to the 32 possible target devices */
1260 for (target = 0; target < 32; target++) {
1261 port = 0x1f;
1262 if (target < DSA_MAX_SWITCHES)
1263 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1264 port = chip->ds->rtable[target];
1265
1266 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1267 if (err)
1268 return err;
1269 }
1270
Vivien Didelot02317e62018-05-09 11:38:49 -04001271 if (chip->info->ops->set_cascade_port) {
1272 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1273 err = chip->info->ops->set_cascade_port(chip, port);
1274 if (err)
1275 return err;
1276 }
1277
Vivien Didelot23c98912018-05-09 11:38:50 -04001278 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1279 if (err)
1280 return err;
1281
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001282 return 0;
1283}
1284
Vivien Didelotb28f8722018-04-26 21:56:44 -04001285static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1286{
1287 /* Clear all trunk masks and mapping */
1288 if (chip->info->global2_addr)
1289 return mv88e6xxx_g2_trunk_clear(chip);
1290
1291 return 0;
1292}
1293
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001294static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1295{
1296 if (chip->info->ops->rmu_disable)
1297 return chip->info->ops->rmu_disable(chip);
1298
1299 return 0;
1300}
1301
Vivien Didelot9e907d72017-07-17 13:03:43 -04001302static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1303{
1304 if (chip->info->ops->pot_clear)
1305 return chip->info->ops->pot_clear(chip);
1306
1307 return 0;
1308}
1309
Vivien Didelot51c901a2017-07-17 13:03:41 -04001310static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1311{
1312 if (chip->info->ops->mgmt_rsvd2cpu)
1313 return chip->info->ops->mgmt_rsvd2cpu(chip);
1314
1315 return 0;
1316}
1317
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001318static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1319{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001320 int err;
1321
Vivien Didelotdaefc942017-03-11 16:12:54 -05001322 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1323 if (err)
1324 return err;
1325
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001326 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1327 if (err)
1328 return err;
1329
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001330 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1331}
1332
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001333static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1334{
1335 int port;
1336 int err;
1337
1338 if (!chip->info->ops->irl_init_all)
1339 return 0;
1340
1341 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1342 /* Disable ingress rate limiting by resetting all per port
1343 * ingress rate limit resources to their initial state.
1344 */
1345 err = chip->info->ops->irl_init_all(chip, port);
1346 if (err)
1347 return err;
1348 }
1349
1350 return 0;
1351}
1352
Vivien Didelot04a69a12017-10-13 14:18:05 -04001353static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1354{
1355 if (chip->info->ops->set_switch_mac) {
1356 u8 addr[ETH_ALEN];
1357
1358 eth_random_addr(addr);
1359
1360 return chip->info->ops->set_switch_mac(chip, addr);
1361 }
1362
1363 return 0;
1364}
1365
Vivien Didelot17a15942017-03-30 17:37:09 -04001366static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1367{
1368 u16 pvlan = 0;
1369
1370 if (!mv88e6xxx_has_pvt(chip))
1371 return -EOPNOTSUPP;
1372
1373 /* Skip the local source device, which uses in-chip port VLAN */
1374 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001375 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001376
1377 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1378}
1379
Vivien Didelot81228992017-03-30 17:37:08 -04001380static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1381{
Vivien Didelot17a15942017-03-30 17:37:09 -04001382 int dev, port;
1383 int err;
1384
Vivien Didelot81228992017-03-30 17:37:08 -04001385 if (!mv88e6xxx_has_pvt(chip))
1386 return 0;
1387
1388 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1389 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1390 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001391 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1392 if (err)
1393 return err;
1394
1395 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1396 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1397 err = mv88e6xxx_pvt_map(chip, dev, port);
1398 if (err)
1399 return err;
1400 }
1401 }
1402
1403 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001404}
1405
Vivien Didelot749efcb2016-09-22 16:49:24 -04001406static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1407{
1408 struct mv88e6xxx_chip *chip = ds->priv;
1409 int err;
1410
1411 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001412 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001413 mutex_unlock(&chip->reg_lock);
1414
1415 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001416 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001417}
1418
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001419static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1420{
1421 if (!chip->info->max_vid)
1422 return 0;
1423
1424 return mv88e6xxx_g1_vtu_flush(chip);
1425}
1426
Vivien Didelotf1394b782017-05-01 14:05:22 -04001427static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1428 struct mv88e6xxx_vtu_entry *entry)
1429{
1430 if (!chip->info->ops->vtu_getnext)
1431 return -EOPNOTSUPP;
1432
1433 return chip->info->ops->vtu_getnext(chip, entry);
1434}
1435
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001436static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1437 struct mv88e6xxx_vtu_entry *entry)
1438{
1439 if (!chip->info->ops->vtu_loadpurge)
1440 return -EOPNOTSUPP;
1441
1442 return chip->info->ops->vtu_loadpurge(chip, entry);
1443}
1444
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001445static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001446{
1447 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001448 struct mv88e6xxx_vtu_entry vlan = {
1449 .vid = chip->info->max_vid,
1450 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001451 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001452
1453 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1454
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001455 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001456 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001457 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001458 if (err)
1459 return err;
1460
1461 set_bit(*fid, fid_bitmap);
1462 }
1463
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001464 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001465 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001466 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001467 if (err)
1468 return err;
1469
1470 if (!vlan.valid)
1471 break;
1472
1473 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001474 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001475
1476 /* The reset value 0x000 is used to indicate that multiple address
1477 * databases are not needed. Return the next positive available.
1478 */
1479 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001480 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001481 return -ENOSPC;
1482
1483 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001484 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001485}
1486
Vivien Didelot567aa592017-05-01 14:05:25 -04001487static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1488 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001489{
1490 int err;
1491
1492 if (!vid)
1493 return -EINVAL;
1494
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001495 entry->vid = vid - 1;
1496 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001497
Vivien Didelotf1394b782017-05-01 14:05:22 -04001498 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001499 if (err)
1500 return err;
1501
Vivien Didelot567aa592017-05-01 14:05:25 -04001502 if (entry->vid == vid && entry->valid)
1503 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001504
Vivien Didelot567aa592017-05-01 14:05:25 -04001505 if (new) {
1506 int i;
1507
1508 /* Initialize a fresh VLAN entry */
1509 memset(entry, 0, sizeof(*entry));
1510 entry->valid = true;
1511 entry->vid = vid;
1512
Vivien Didelot553a7682017-06-07 18:12:16 -04001513 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001514 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001515 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001516 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001517
1518 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001519 }
1520
Vivien Didelot567aa592017-05-01 14:05:25 -04001521 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1522 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001523}
1524
Vivien Didelotda9c3592016-02-12 12:09:40 -05001525static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1526 u16 vid_begin, u16 vid_end)
1527{
Vivien Didelot04bed142016-08-31 18:06:13 -04001528 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001529 struct mv88e6xxx_vtu_entry vlan = {
1530 .vid = vid_begin - 1,
1531 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001532 int i, err;
1533
Andrew Lunndb06ae412017-09-25 23:32:20 +02001534 /* DSA and CPU ports have to be members of multiple vlans */
1535 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1536 return 0;
1537
Vivien Didelotda9c3592016-02-12 12:09:40 -05001538 if (!vid_begin)
1539 return -EOPNOTSUPP;
1540
Vivien Didelotfad09c72016-06-21 12:28:20 -04001541 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001542
Vivien Didelotda9c3592016-02-12 12:09:40 -05001543 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001544 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545 if (err)
1546 goto unlock;
1547
1548 if (!vlan.valid)
1549 break;
1550
1551 if (vlan.vid > vid_end)
1552 break;
1553
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001554 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001555 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1556 continue;
1557
Andrew Lunncd886462017-11-09 22:29:53 +01001558 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001559 continue;
1560
Vivien Didelotbd00e052017-05-01 14:05:11 -04001561 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001562 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001563 continue;
1564
Vivien Didelotc8652c82017-10-16 11:12:19 -04001565 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001566 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001567 break; /* same bridge, check next VLAN */
1568
Vivien Didelotc8652c82017-10-16 11:12:19 -04001569 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001570 continue;
1571
Andrew Lunn743fcc22017-11-09 22:29:54 +01001572 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1573 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001574 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001575 err = -EOPNOTSUPP;
1576 goto unlock;
1577 }
1578 } while (vlan.vid < vid_end);
1579
1580unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001581 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001582
1583 return err;
1584}
1585
Vivien Didelotf81ec902016-05-09 13:22:58 -04001586static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1587 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001588{
Vivien Didelot04bed142016-08-31 18:06:13 -04001589 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001590 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1591 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001592 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001593
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001594 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001595 return -EOPNOTSUPP;
1596
Vivien Didelotfad09c72016-06-21 12:28:20 -04001597 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001598 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001599 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001600
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001601 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001602}
1603
Vivien Didelot57d32312016-06-20 13:13:58 -04001604static int
1605mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001606 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001607{
Vivien Didelot04bed142016-08-31 18:06:13 -04001608 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001609 int err;
1610
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001611 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001612 return -EOPNOTSUPP;
1613
Vivien Didelotda9c3592016-02-12 12:09:40 -05001614 /* If the requested port doesn't belong to the same bridge as the VLAN
1615 * members, do not support it (yet) and fallback to software VLAN.
1616 */
1617 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1618 vlan->vid_end);
1619 if (err)
1620 return err;
1621
Vivien Didelot76e398a2015-11-01 12:33:55 -05001622 /* We don't need any dynamic resource from the kernel (yet),
1623 * so skip the prepare phase.
1624 */
1625 return 0;
1626}
1627
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001628static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1629 const unsigned char *addr, u16 vid,
1630 u8 state)
1631{
1632 struct mv88e6xxx_vtu_entry vlan;
1633 struct mv88e6xxx_atu_entry entry;
1634 int err;
1635
1636 /* Null VLAN ID corresponds to the port private database */
1637 if (vid == 0)
1638 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1639 else
1640 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1641 if (err)
1642 return err;
1643
1644 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1645 ether_addr_copy(entry.mac, addr);
1646 eth_addr_dec(entry.mac);
1647
1648 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1649 if (err)
1650 return err;
1651
1652 /* Initialize a fresh ATU entry if it isn't found */
1653 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1654 !ether_addr_equal(entry.mac, addr)) {
1655 memset(&entry, 0, sizeof(entry));
1656 ether_addr_copy(entry.mac, addr);
1657 }
1658
1659 /* Purge the ATU entry only if no port is using it anymore */
1660 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1661 entry.portvec &= ~BIT(port);
1662 if (!entry.portvec)
1663 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1664 } else {
1665 entry.portvec |= BIT(port);
1666 entry.state = state;
1667 }
1668
1669 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1670}
1671
Andrew Lunn87fa8862017-11-09 22:29:56 +01001672static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1673 u16 vid)
1674{
1675 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1676 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1677
1678 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1679}
1680
1681static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1682{
1683 int port;
1684 int err;
1685
1686 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1687 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1688 if (err)
1689 return err;
1690 }
1691
1692 return 0;
1693}
1694
Vivien Didelotfad09c72016-06-21 12:28:20 -04001695static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001696 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001697{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001698 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001699 int err;
1700
Vivien Didelot567aa592017-05-01 14:05:25 -04001701 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001702 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001703 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001704
Vivien Didelotc91498e2017-06-07 18:12:13 -04001705 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001706
Andrew Lunn87fa8862017-11-09 22:29:56 +01001707 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1708 if (err)
1709 return err;
1710
1711 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001712}
1713
Vivien Didelotf81ec902016-05-09 13:22:58 -04001714static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001715 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001716{
Vivien Didelot04bed142016-08-31 18:06:13 -04001717 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001718 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1719 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001720 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001721 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001722
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001723 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001724 return;
1725
Vivien Didelotc91498e2017-06-07 18:12:13 -04001726 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001727 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001728 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001729 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001730 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001731 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001732
Vivien Didelotfad09c72016-06-21 12:28:20 -04001733 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001734
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001735 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001736 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001737 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1738 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001739
Vivien Didelot77064f32016-11-04 03:23:30 +01001740 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001741 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1742 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001743
Vivien Didelotfad09c72016-06-21 12:28:20 -04001744 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001745}
1746
Vivien Didelotfad09c72016-06-21 12:28:20 -04001747static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001748 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001749{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001750 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001751 int i, err;
1752
Vivien Didelot567aa592017-05-01 14:05:25 -04001753 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001754 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001755 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001756
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001757 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001758 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001759 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001760
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001761 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001762
1763 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001764 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001765 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001766 if (vlan.member[i] !=
1767 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001768 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001769 break;
1770 }
1771 }
1772
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001773 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001774 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001775 return err;
1776
Vivien Didelote606ca32017-03-11 16:12:55 -05001777 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001778}
1779
Vivien Didelotf81ec902016-05-09 13:22:58 -04001780static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1781 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001782{
Vivien Didelot04bed142016-08-31 18:06:13 -04001783 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001784 u16 pvid, vid;
1785 int err = 0;
1786
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001787 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001788 return -EOPNOTSUPP;
1789
Vivien Didelotfad09c72016-06-21 12:28:20 -04001790 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001791
Vivien Didelot77064f32016-11-04 03:23:30 +01001792 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001793 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001794 goto unlock;
1795
Vivien Didelot76e398a2015-11-01 12:33:55 -05001796 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001797 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001798 if (err)
1799 goto unlock;
1800
1801 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001802 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001803 if (err)
1804 goto unlock;
1805 }
1806 }
1807
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001808unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001809 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001810
1811 return err;
1812}
1813
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001814static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1815 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001816{
Vivien Didelot04bed142016-08-31 18:06:13 -04001817 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001818 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001819
Vivien Didelotfad09c72016-06-21 12:28:20 -04001820 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001821 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1822 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001823 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001824
1825 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001826}
1827
Vivien Didelotf81ec902016-05-09 13:22:58 -04001828static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001829 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001830{
Vivien Didelot04bed142016-08-31 18:06:13 -04001831 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001832 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001833
Vivien Didelotfad09c72016-06-21 12:28:20 -04001834 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001835 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001836 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001837 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001838
Vivien Didelot83dabd12016-08-31 11:50:04 -04001839 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001840}
1841
Vivien Didelot83dabd12016-08-31 11:50:04 -04001842static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1843 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001844 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001845{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001846 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001847 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001848 int err;
1849
Vivien Didelot27c0e602017-06-15 12:14:01 -04001850 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001851 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001852
1853 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001854 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001855 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001856 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001857 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001858 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001859
Vivien Didelot27c0e602017-06-15 12:14:01 -04001860 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001861 break;
1862
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001863 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001864 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001865
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001866 if (!is_unicast_ether_addr(addr.mac))
1867 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001868
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001869 is_static = (addr.state ==
1870 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1871 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001872 if (err)
1873 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001874 } while (!is_broadcast_ether_addr(addr.mac));
1875
1876 return err;
1877}
1878
Vivien Didelot83dabd12016-08-31 11:50:04 -04001879static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001880 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001881{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001882 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001883 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001884 };
1885 u16 fid;
1886 int err;
1887
1888 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001889 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001890 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001891 mutex_unlock(&chip->reg_lock);
1892
Vivien Didelot83dabd12016-08-31 11:50:04 -04001893 if (err)
1894 return err;
1895
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001896 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001897 if (err)
1898 return err;
1899
1900 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001901 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001902 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001903 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001904 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001905 if (err)
1906 return err;
1907
1908 if (!vlan.valid)
1909 break;
1910
1911 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001912 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001913 if (err)
1914 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001915 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001916
1917 return err;
1918}
1919
Vivien Didelotf81ec902016-05-09 13:22:58 -04001920static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001921 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001922{
Vivien Didelot04bed142016-08-31 18:06:13 -04001923 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001924
Andrew Lunna61e5402018-02-15 14:38:35 +01001925 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001926}
1927
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001928static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1929 struct net_device *br)
1930{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001931 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001932 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001933 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001934 int err;
1935
1936 /* Remap the Port VLAN of each local bridge group member */
1937 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1938 if (chip->ds->ports[port].bridge_dev == br) {
1939 err = mv88e6xxx_port_vlan_map(chip, port);
1940 if (err)
1941 return err;
1942 }
1943 }
1944
Vivien Didelote96a6e02017-03-30 17:37:13 -04001945 if (!mv88e6xxx_has_pvt(chip))
1946 return 0;
1947
1948 /* Remap the Port VLAN of each cross-chip bridge group member */
1949 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1950 ds = chip->ds->dst->ds[dev];
1951 if (!ds)
1952 break;
1953
1954 for (port = 0; port < ds->num_ports; ++port) {
1955 if (ds->ports[port].bridge_dev == br) {
1956 err = mv88e6xxx_pvt_map(chip, dev, port);
1957 if (err)
1958 return err;
1959 }
1960 }
1961 }
1962
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001963 return 0;
1964}
1965
Vivien Didelotf81ec902016-05-09 13:22:58 -04001966static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001967 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001968{
Vivien Didelot04bed142016-08-31 18:06:13 -04001969 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001970 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001971
Vivien Didelotfad09c72016-06-21 12:28:20 -04001972 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001973 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001974 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001975
Vivien Didelot466dfa02016-02-26 13:16:05 -05001976 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001977}
1978
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001979static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1980 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001981{
Vivien Didelot04bed142016-08-31 18:06:13 -04001982 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001983
Vivien Didelotfad09c72016-06-21 12:28:20 -04001984 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001985 if (mv88e6xxx_bridge_map(chip, br) ||
1986 mv88e6xxx_port_vlan_map(chip, port))
1987 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001988 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001989}
1990
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001991static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1992 int port, struct net_device *br)
1993{
1994 struct mv88e6xxx_chip *chip = ds->priv;
1995 int err;
1996
1997 if (!mv88e6xxx_has_pvt(chip))
1998 return 0;
1999
2000 mutex_lock(&chip->reg_lock);
2001 err = mv88e6xxx_pvt_map(chip, dev, port);
2002 mutex_unlock(&chip->reg_lock);
2003
2004 return err;
2005}
2006
2007static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2008 int port, struct net_device *br)
2009{
2010 struct mv88e6xxx_chip *chip = ds->priv;
2011
2012 if (!mv88e6xxx_has_pvt(chip))
2013 return;
2014
2015 mutex_lock(&chip->reg_lock);
2016 if (mv88e6xxx_pvt_map(chip, dev, port))
2017 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2018 mutex_unlock(&chip->reg_lock);
2019}
2020
Vivien Didelot17e708b2016-12-05 17:30:27 -05002021static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2022{
2023 if (chip->info->ops->reset)
2024 return chip->info->ops->reset(chip);
2025
2026 return 0;
2027}
2028
Vivien Didelot309eca62016-12-05 17:30:26 -05002029static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2030{
2031 struct gpio_desc *gpiod = chip->reset;
2032
2033 /* If there is a GPIO connected to the reset pin, toggle it */
2034 if (gpiod) {
2035 gpiod_set_value_cansleep(gpiod, 1);
2036 usleep_range(10000, 20000);
2037 gpiod_set_value_cansleep(gpiod, 0);
2038 usleep_range(10000, 20000);
2039 }
2040}
2041
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002042static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2043{
2044 int i, err;
2045
2046 /* Set all ports to the Disabled state */
2047 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002048 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002049 if (err)
2050 return err;
2051 }
2052
2053 /* Wait for transmit queues to drain,
2054 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2055 */
2056 usleep_range(2000, 4000);
2057
2058 return 0;
2059}
2060
Vivien Didelotfad09c72016-06-21 12:28:20 -04002061static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002062{
Vivien Didelota935c052016-09-29 12:21:53 -04002063 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002064
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002065 err = mv88e6xxx_disable_ports(chip);
2066 if (err)
2067 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002068
Vivien Didelot309eca62016-12-05 17:30:26 -05002069 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002070
Vivien Didelot17e708b2016-12-05 17:30:27 -05002071 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002072}
2073
Vivien Didelot43145572017-03-11 16:12:59 -05002074static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002075 enum mv88e6xxx_frame_mode frame,
2076 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002077{
2078 int err;
2079
Vivien Didelot43145572017-03-11 16:12:59 -05002080 if (!chip->info->ops->port_set_frame_mode)
2081 return -EOPNOTSUPP;
2082
2083 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002084 if (err)
2085 return err;
2086
Vivien Didelot43145572017-03-11 16:12:59 -05002087 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2088 if (err)
2089 return err;
2090
2091 if (chip->info->ops->port_set_ether_type)
2092 return chip->info->ops->port_set_ether_type(chip, port, etype);
2093
2094 return 0;
2095}
2096
2097static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2098{
2099 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002100 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002101 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002102}
2103
2104static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2105{
2106 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002107 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002108 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002109}
2110
2111static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2112{
2113 return mv88e6xxx_set_port_mode(chip, port,
2114 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002115 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2116 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002117}
2118
2119static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2120{
2121 if (dsa_is_dsa_port(chip->ds, port))
2122 return mv88e6xxx_set_port_mode_dsa(chip, port);
2123
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002124 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002125 return mv88e6xxx_set_port_mode_normal(chip, port);
2126
2127 /* Setup CPU port mode depending on its supported tag format */
2128 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2129 return mv88e6xxx_set_port_mode_dsa(chip, port);
2130
2131 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2132 return mv88e6xxx_set_port_mode_edsa(chip, port);
2133
2134 return -EINVAL;
2135}
2136
Vivien Didelotea698f42017-03-11 16:12:50 -05002137static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2138{
2139 bool message = dsa_is_dsa_port(chip->ds, port);
2140
2141 return mv88e6xxx_port_set_message_port(chip, port, message);
2142}
2143
Vivien Didelot601aeed2017-03-11 16:13:00 -05002144static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2145{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002146 struct dsa_switch *ds = chip->ds;
2147 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002148
2149 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002150 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002151 if (chip->info->ops->port_set_egress_floods)
2152 return chip->info->ops->port_set_egress_floods(chip, port,
2153 flood, flood);
2154
2155 return 0;
2156}
2157
Andrew Lunn6d917822017-05-26 01:03:21 +02002158static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2159 bool on)
2160{
Vivien Didelot523a8902017-05-26 18:02:42 -04002161 if (chip->info->ops->serdes_power)
2162 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002163
Vivien Didelot523a8902017-05-26 18:02:42 -04002164 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002165}
2166
Vivien Didelotfa371c82017-12-05 15:34:10 -05002167static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2168{
2169 struct dsa_switch *ds = chip->ds;
2170 int upstream_port;
2171 int err;
2172
Vivien Didelot07073c72017-12-05 15:34:13 -05002173 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002174 if (chip->info->ops->port_set_upstream_port) {
2175 err = chip->info->ops->port_set_upstream_port(chip, port,
2176 upstream_port);
2177 if (err)
2178 return err;
2179 }
2180
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002181 if (port == upstream_port) {
2182 if (chip->info->ops->set_cpu_port) {
2183 err = chip->info->ops->set_cpu_port(chip,
2184 upstream_port);
2185 if (err)
2186 return err;
2187 }
2188
2189 if (chip->info->ops->set_egress_port) {
2190 err = chip->info->ops->set_egress_port(chip,
2191 upstream_port);
2192 if (err)
2193 return err;
2194 }
2195 }
2196
Vivien Didelotfa371c82017-12-05 15:34:10 -05002197 return 0;
2198}
2199
Vivien Didelotfad09c72016-06-21 12:28:20 -04002200static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002201{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002202 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002203 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002204 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002205
Andrew Lunn7b898462018-08-09 15:38:47 +02002206 chip->ports[port].chip = chip;
2207 chip->ports[port].port = port;
2208
Vivien Didelotd78343d2016-11-04 03:23:36 +01002209 /* MAC Forcing register: don't force link, speed, duplex or flow control
2210 * state to any particular values on physical ports, but force the CPU
2211 * port and all DSA ports to their maximum bandwidth and full duplex.
2212 */
2213 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2214 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2215 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002216 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002217 PHY_INTERFACE_MODE_NA);
2218 else
2219 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2220 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002221 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002222 PHY_INTERFACE_MODE_NA);
2223 if (err)
2224 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002225
2226 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2227 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2228 * tunneling, determine priority by looking at 802.1p and IP
2229 * priority fields (IP prio has precedence), and set STP state
2230 * to Forwarding.
2231 *
2232 * If this is the CPU link, use DSA or EDSA tagging depending
2233 * on which tagging mode was configured.
2234 *
2235 * If this is a link to another switch, use DSA tagging mode.
2236 *
2237 * If this is the upstream port for this switch, enable
2238 * forwarding of unknown unicasts and multicasts.
2239 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002240 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2241 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2242 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2243 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002244 if (err)
2245 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002246
Vivien Didelot601aeed2017-03-11 16:13:00 -05002247 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002248 if (err)
2249 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002250
Vivien Didelot601aeed2017-03-11 16:13:00 -05002251 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002252 if (err)
2253 return err;
2254
Andrew Lunn04aca992017-05-26 01:03:24 +02002255 /* Enable the SERDES interface for DSA and CPU ports. Normal
2256 * ports SERDES are enabled when the port is enabled, thus
2257 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002258 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002259 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2260 err = mv88e6xxx_serdes_power(chip, port, true);
2261 if (err)
2262 return err;
2263 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002264
Vivien Didelot8efdda42015-08-13 12:52:23 -04002265 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002266 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002267 * untagged frames on this port, do a destination address lookup on all
2268 * received packets as usual, disable ARP mirroring and don't send a
2269 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002270 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002271 err = mv88e6xxx_port_set_map_da(chip, port);
2272 if (err)
2273 return err;
2274
Vivien Didelotfa371c82017-12-05 15:34:10 -05002275 err = mv88e6xxx_setup_upstream_port(chip, port);
2276 if (err)
2277 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002278
Andrew Lunna23b2962017-02-04 20:15:28 +01002279 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002280 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002281 if (err)
2282 return err;
2283
Vivien Didelotcd782652017-06-08 18:34:13 -04002284 if (chip->info->ops->port_set_jumbo_size) {
2285 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002286 if (err)
2287 return err;
2288 }
2289
Andrew Lunn54d792f2015-05-06 01:09:47 +02002290 /* Port Association Vector: when learning source addresses
2291 * of packets, add the address to the address database using
2292 * a port bitmap that has only the bit for this port set and
2293 * the other bits clear.
2294 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002295 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002296 /* Disable learning for CPU port */
2297 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002298 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002299
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002300 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2301 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002302 if (err)
2303 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002304
2305 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002306 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2307 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002308 if (err)
2309 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002310
Vivien Didelot08984322017-06-08 18:34:12 -04002311 if (chip->info->ops->port_pause_limit) {
2312 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002313 if (err)
2314 return err;
2315 }
2316
Vivien Didelotc8c94892017-03-11 16:13:01 -05002317 if (chip->info->ops->port_disable_learn_limit) {
2318 err = chip->info->ops->port_disable_learn_limit(chip, port);
2319 if (err)
2320 return err;
2321 }
2322
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002323 if (chip->info->ops->port_disable_pri_override) {
2324 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002325 if (err)
2326 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002327 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002328
Andrew Lunnef0a7312016-12-03 04:35:16 +01002329 if (chip->info->ops->port_tag_remap) {
2330 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002331 if (err)
2332 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002333 }
2334
Andrew Lunnef70b112016-12-03 04:45:18 +01002335 if (chip->info->ops->port_egress_rate_limiting) {
2336 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002337 if (err)
2338 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002339 }
2340
Vivien Didelotea698f42017-03-11 16:12:50 -05002341 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002342 if (err)
2343 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002344
Vivien Didelot207afda2016-04-14 14:42:09 -04002345 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002346 * database, and allow bidirectional communication between the
2347 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002348 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002349 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002350 if (err)
2351 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002352
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002353 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002354 if (err)
2355 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002356
2357 /* Default VLAN ID and priority: don't set a default VLAN
2358 * ID, and set the default packet priority to zero.
2359 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002360 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002361}
2362
Andrew Lunn04aca992017-05-26 01:03:24 +02002363static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2364 struct phy_device *phydev)
2365{
2366 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002367 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002368
2369 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002370
Vivien Didelot523a8902017-05-26 18:02:42 -04002371 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002372
2373 if (!err && chip->info->ops->serdes_irq_setup)
2374 err = chip->info->ops->serdes_irq_setup(chip, port);
2375
Andrew Lunn04aca992017-05-26 01:03:24 +02002376 mutex_unlock(&chip->reg_lock);
2377
2378 return err;
2379}
2380
2381static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2382 struct phy_device *phydev)
2383{
2384 struct mv88e6xxx_chip *chip = ds->priv;
2385
2386 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002387
2388 if (chip->info->ops->serdes_irq_free)
2389 chip->info->ops->serdes_irq_free(chip, port);
2390
Vivien Didelot523a8902017-05-26 18:02:42 -04002391 if (mv88e6xxx_serdes_power(chip, port, false))
2392 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002393
Andrew Lunn04aca992017-05-26 01:03:24 +02002394 mutex_unlock(&chip->reg_lock);
2395}
2396
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002397static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2398 unsigned int ageing_time)
2399{
Vivien Didelot04bed142016-08-31 18:06:13 -04002400 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002401 int err;
2402
2403 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002404 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002405 mutex_unlock(&chip->reg_lock);
2406
2407 return err;
2408}
2409
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002410static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002411{
2412 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002413
Andrew Lunnde2273872016-11-21 23:27:01 +01002414 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002415 if (chip->info->ops->stats_set_histogram) {
2416 err = chip->info->ops->stats_set_histogram(chip);
2417 if (err)
2418 return err;
2419 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002420
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002421 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002422}
2423
Andrew Lunnea890982019-01-09 00:24:03 +01002424/* The mv88e6390 has some hidden registers used for debug and
2425 * development. The errata also makes use of them.
2426 */
2427static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2428 int reg, u16 val)
2429{
2430 u16 ctrl;
2431 int err;
2432
2433 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2434 PORT_RESERVED_1A, val);
2435 if (err)
2436 return err;
2437
2438 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2439 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2440 reg;
2441
2442 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2443 PORT_RESERVED_1A, ctrl);
2444}
2445
2446static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2447{
2448 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2449 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2450}
2451
2452
2453static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2454 int reg, u16 *val)
2455{
2456 u16 ctrl;
2457 int err;
2458
2459 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2460 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2461 reg;
2462
2463 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2464 PORT_RESERVED_1A, ctrl);
2465 if (err)
2466 return err;
2467
2468 err = mv88e6390_hidden_wait(chip);
2469 if (err)
2470 return err;
2471
2472 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2473 PORT_RESERVED_1A, val);
2474}
2475
2476/* Check if the errata has already been applied. */
2477static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2478{
2479 int port;
2480 int err;
2481 u16 val;
2482
2483 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2484 err = mv88e6390_hidden_read(chip, port, 0, &val);
2485 if (err) {
2486 dev_err(chip->dev,
2487 "Error reading hidden register: %d\n", err);
2488 return false;
2489 }
2490 if (val != 0x01c0)
2491 return false;
2492 }
2493
2494 return true;
2495}
2496
2497/* The 6390 copper ports have an errata which require poking magic
2498 * values into undocumented hidden registers and then performing a
2499 * software reset.
2500 */
2501static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2502{
2503 int port;
2504 int err;
2505
2506 if (mv88e6390_setup_errata_applied(chip))
2507 return 0;
2508
2509 /* Set the ports into blocking mode */
2510 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2511 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2512 if (err)
2513 return err;
2514 }
2515
2516 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2517 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2518 if (err)
2519 return err;
2520 }
2521
2522 return mv88e6xxx_software_reset(chip);
2523}
2524
Vivien Didelotf81ec902016-05-09 13:22:58 -04002525static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002526{
Vivien Didelot04bed142016-08-31 18:06:13 -04002527 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002528 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002529 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002530 int i;
2531
Vivien Didelotfad09c72016-06-21 12:28:20 -04002532 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002533 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002534
Vivien Didelotfad09c72016-06-21 12:28:20 -04002535 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002536
Andrew Lunnea890982019-01-09 00:24:03 +01002537 if (chip->info->ops->setup_errata) {
2538 err = chip->info->ops->setup_errata(chip);
2539 if (err)
2540 goto unlock;
2541 }
2542
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002543 /* Cache the cmode of each port. */
2544 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2545 if (chip->info->ops->port_get_cmode) {
2546 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2547 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002548 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002549
2550 chip->ports[i].cmode = cmode;
2551 }
2552 }
2553
Vivien Didelot97299342016-07-18 20:45:30 -04002554 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002555 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002556 if (dsa_is_unused_port(ds, i))
2557 continue;
2558
Vivien Didelot97299342016-07-18 20:45:30 -04002559 err = mv88e6xxx_setup_port(chip, i);
2560 if (err)
2561 goto unlock;
2562 }
2563
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002564 err = mv88e6xxx_irl_setup(chip);
2565 if (err)
2566 goto unlock;
2567
Vivien Didelot04a69a12017-10-13 14:18:05 -04002568 err = mv88e6xxx_mac_setup(chip);
2569 if (err)
2570 goto unlock;
2571
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002572 err = mv88e6xxx_phy_setup(chip);
2573 if (err)
2574 goto unlock;
2575
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002576 err = mv88e6xxx_vtu_setup(chip);
2577 if (err)
2578 goto unlock;
2579
Vivien Didelot81228992017-03-30 17:37:08 -04002580 err = mv88e6xxx_pvt_setup(chip);
2581 if (err)
2582 goto unlock;
2583
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002584 err = mv88e6xxx_atu_setup(chip);
2585 if (err)
2586 goto unlock;
2587
Andrew Lunn87fa8862017-11-09 22:29:56 +01002588 err = mv88e6xxx_broadcast_setup(chip, 0);
2589 if (err)
2590 goto unlock;
2591
Vivien Didelot9e907d72017-07-17 13:03:43 -04002592 err = mv88e6xxx_pot_setup(chip);
2593 if (err)
2594 goto unlock;
2595
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002596 err = mv88e6xxx_rmu_setup(chip);
2597 if (err)
2598 goto unlock;
2599
Vivien Didelot51c901a2017-07-17 13:03:41 -04002600 err = mv88e6xxx_rsvd2cpu_setup(chip);
2601 if (err)
2602 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002603
Vivien Didelotb28f8722018-04-26 21:56:44 -04002604 err = mv88e6xxx_trunk_setup(chip);
2605 if (err)
2606 goto unlock;
2607
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002608 err = mv88e6xxx_devmap_setup(chip);
2609 if (err)
2610 goto unlock;
2611
Vivien Didelot93e18d62018-05-11 17:16:35 -04002612 err = mv88e6xxx_pri_setup(chip);
2613 if (err)
2614 goto unlock;
2615
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002616 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002617 if (chip->info->ptp_support) {
2618 err = mv88e6xxx_ptp_setup(chip);
2619 if (err)
2620 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002621
2622 err = mv88e6xxx_hwtstamp_setup(chip);
2623 if (err)
2624 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002625 }
2626
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002627 err = mv88e6xxx_stats_setup(chip);
2628 if (err)
2629 goto unlock;
2630
Vivien Didelot6b17e862015-08-13 12:52:18 -04002631unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002632 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002633
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002634 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002635}
2636
Vivien Didelote57e5e72016-08-15 17:19:00 -04002637static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002638{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002639 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2640 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002641 u16 val;
2642 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002643
Andrew Lunnee26a222017-01-24 14:53:48 +01002644 if (!chip->info->ops->phy_read)
2645 return -EOPNOTSUPP;
2646
Vivien Didelotfad09c72016-06-21 12:28:20 -04002647 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002648 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002649 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002650
Andrew Lunnda9f3302017-02-01 03:40:05 +01002651 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002652 /* Some internal PHYs don't have a model number. */
2653 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2654 /* Then there is the 6165 family. It gets is
2655 * PHYs correct. But it can also have two
2656 * SERDES interfaces in the PHY address
2657 * space. And these don't have a model
2658 * number. But they are not PHYs, so we don't
2659 * want to give them something a PHY driver
2660 * will recognise.
2661 *
2662 * Use the mv88e6390 family model number
2663 * instead, for anything which really could be
2664 * a PHY,
2665 */
2666 if (!(val & 0x3f0))
2667 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002668 }
2669
Vivien Didelote57e5e72016-08-15 17:19:00 -04002670 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002671}
2672
Vivien Didelote57e5e72016-08-15 17:19:00 -04002673static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002674{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002675 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2676 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002677 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002678
Andrew Lunnee26a222017-01-24 14:53:48 +01002679 if (!chip->info->ops->phy_write)
2680 return -EOPNOTSUPP;
2681
Vivien Didelotfad09c72016-06-21 12:28:20 -04002682 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002683 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002684 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002685
2686 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002687}
2688
Vivien Didelotfad09c72016-06-21 12:28:20 -04002689static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002690 struct device_node *np,
2691 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002692{
2693 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002694 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002695 struct mii_bus *bus;
2696 int err;
2697
Andrew Lunn2510bab2018-02-22 01:51:49 +01002698 if (external) {
2699 mutex_lock(&chip->reg_lock);
2700 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2701 mutex_unlock(&chip->reg_lock);
2702
2703 if (err)
2704 return err;
2705 }
2706
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002707 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002708 if (!bus)
2709 return -ENOMEM;
2710
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002711 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002712 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002713 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002714 INIT_LIST_HEAD(&mdio_bus->list);
2715 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002716
Andrew Lunnb516d452016-06-04 21:17:06 +02002717 if (np) {
2718 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002719 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002720 } else {
2721 bus->name = "mv88e6xxx SMI";
2722 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2723 }
2724
2725 bus->read = mv88e6xxx_mdio_read;
2726 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002727 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002728
Andrew Lunn6f882842018-03-17 20:32:05 +01002729 if (!external) {
2730 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2731 if (err)
2732 return err;
2733 }
2734
Florian Fainelli00e798c2018-05-15 16:56:19 -07002735 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002736 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002737 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002738 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002739 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002740 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002741
2742 if (external)
2743 list_add_tail(&mdio_bus->list, &chip->mdios);
2744 else
2745 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002746
2747 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002748}
2749
Andrew Lunna3c53be52017-01-24 14:53:50 +01002750static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2751 { .compatible = "marvell,mv88e6xxx-mdio-external",
2752 .data = (void *)true },
2753 { },
2754};
2755
Andrew Lunn3126aee2017-12-07 01:05:57 +01002756static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2757
2758{
2759 struct mv88e6xxx_mdio_bus *mdio_bus;
2760 struct mii_bus *bus;
2761
2762 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2763 bus = mdio_bus->bus;
2764
Andrew Lunn6f882842018-03-17 20:32:05 +01002765 if (!mdio_bus->external)
2766 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2767
Andrew Lunn3126aee2017-12-07 01:05:57 +01002768 mdiobus_unregister(bus);
2769 }
2770}
2771
Andrew Lunna3c53be52017-01-24 14:53:50 +01002772static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2773 struct device_node *np)
2774{
2775 const struct of_device_id *match;
2776 struct device_node *child;
2777 int err;
2778
2779 /* Always register one mdio bus for the internal/default mdio
2780 * bus. This maybe represented in the device tree, but is
2781 * optional.
2782 */
2783 child = of_get_child_by_name(np, "mdio");
2784 err = mv88e6xxx_mdio_register(chip, child, false);
2785 if (err)
2786 return err;
2787
2788 /* Walk the device tree, and see if there are any other nodes
2789 * which say they are compatible with the external mdio
2790 * bus.
2791 */
2792 for_each_available_child_of_node(np, child) {
2793 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2794 if (match) {
2795 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002796 if (err) {
2797 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002798 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002799 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002800 }
2801 }
2802
2803 return 0;
2804}
2805
Vivien Didelot855b1932016-07-20 18:18:35 -04002806static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2807{
Vivien Didelot04bed142016-08-31 18:06:13 -04002808 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002809
2810 return chip->eeprom_len;
2811}
2812
Vivien Didelot855b1932016-07-20 18:18:35 -04002813static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2814 struct ethtool_eeprom *eeprom, u8 *data)
2815{
Vivien Didelot04bed142016-08-31 18:06:13 -04002816 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002817 int err;
2818
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002819 if (!chip->info->ops->get_eeprom)
2820 return -EOPNOTSUPP;
2821
Vivien Didelot855b1932016-07-20 18:18:35 -04002822 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002823 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002824 mutex_unlock(&chip->reg_lock);
2825
2826 if (err)
2827 return err;
2828
2829 eeprom->magic = 0xc3ec4951;
2830
2831 return 0;
2832}
2833
Vivien Didelot855b1932016-07-20 18:18:35 -04002834static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2835 struct ethtool_eeprom *eeprom, u8 *data)
2836{
Vivien Didelot04bed142016-08-31 18:06:13 -04002837 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002838 int err;
2839
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002840 if (!chip->info->ops->set_eeprom)
2841 return -EOPNOTSUPP;
2842
Vivien Didelot855b1932016-07-20 18:18:35 -04002843 if (eeprom->magic != 0xc3ec4951)
2844 return -EINVAL;
2845
2846 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002847 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002848 mutex_unlock(&chip->reg_lock);
2849
2850 return err;
2851}
2852
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002853static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002854 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002855 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2856 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002857 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002858 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002859 .phy_read = mv88e6185_phy_ppu_read,
2860 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002861 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002862 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002863 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002864 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002865 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002866 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002867 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002868 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002869 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002870 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002871 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002872 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002873 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002874 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002875 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002876 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2877 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002878 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002879 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2880 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002881 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002882 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002883 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002884 .ppu_enable = mv88e6185_g1_ppu_enable,
2885 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002886 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002887 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002888 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002889 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002890 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002891};
2892
2893static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002894 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002895 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2896 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002897 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002898 .phy_read = mv88e6185_phy_ppu_read,
2899 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002900 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002901 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002902 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002903 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002904 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002905 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002906 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002907 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002908 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002909 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002910 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2911 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002912 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002913 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002914 .ppu_enable = mv88e6185_g1_ppu_enable,
2915 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002916 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002917 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002918 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002919 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002920};
2921
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002922static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002923 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002924 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2925 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002926 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002927 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2928 .phy_read = mv88e6xxx_g2_smi_phy_read,
2929 .phy_write = mv88e6xxx_g2_smi_phy_write,
2930 .port_set_link = mv88e6xxx_port_set_link,
2931 .port_set_duplex = mv88e6xxx_port_set_duplex,
2932 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002933 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002934 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002935 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002936 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002937 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002938 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002939 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002940 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002941 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002942 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002943 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002944 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002945 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002946 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2947 .stats_get_strings = mv88e6095_stats_get_strings,
2948 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002949 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2950 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002951 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002952 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002953 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002954 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002955 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002956 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002957 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002958 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002959};
2960
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002961static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002962 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002963 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2964 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002965 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002966 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002967 .phy_read = mv88e6xxx_g2_smi_phy_read,
2968 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002969 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002970 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002971 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002972 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002973 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002974 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002975 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002976 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002977 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002978 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002979 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002980 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2981 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002982 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002983 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2984 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002985 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002986 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002987 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002988 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002989 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002990 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002991 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002992};
2993
2994static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002995 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002996 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2997 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002998 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002999 .phy_read = mv88e6185_phy_ppu_read,
3000 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003001 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003002 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003003 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003004 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003005 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003006 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003007 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003008 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003009 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003010 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003011 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003012 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003013 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003014 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003015 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003016 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003017 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3018 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003019 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003020 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3021 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003022 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003023 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003024 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003025 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003026 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003027 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003028 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003029 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003030 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003031};
3032
Vivien Didelot990e27b2017-03-28 13:50:32 -04003033static const struct mv88e6xxx_ops mv88e6141_ops = {
3034 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003035 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3036 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003037 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003038 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3039 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3040 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3041 .phy_read = mv88e6xxx_g2_smi_phy_read,
3042 .phy_write = mv88e6xxx_g2_smi_phy_write,
3043 .port_set_link = mv88e6xxx_port_set_link,
3044 .port_set_duplex = mv88e6xxx_port_set_duplex,
3045 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003046 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003047 .port_tag_remap = mv88e6095_port_tag_remap,
3048 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3049 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3050 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003051 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003052 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003053 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003054 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3055 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003056 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003057 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003058 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003059 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003060 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3061 .stats_get_strings = mv88e6320_stats_get_strings,
3062 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003063 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3064 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003065 .watchdog_ops = &mv88e6390_watchdog_ops,
3066 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003067 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003068 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003069 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003070 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003071 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003072 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003073 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003074};
3075
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003076static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003077 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003078 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3079 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003080 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003081 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003082 .phy_read = mv88e6xxx_g2_smi_phy_read,
3083 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003084 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003085 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003086 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003087 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003088 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003089 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003090 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003091 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003092 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003093 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003094 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003095 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003096 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003097 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003098 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003099 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003100 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3101 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003102 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003103 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3104 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003105 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003106 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003107 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003108 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003109 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003110 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003111 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003112 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003113 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003114};
3115
3116static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003117 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003118 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3119 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003120 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003121 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003122 .phy_read = mv88e6165_phy_read,
3123 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003124 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003125 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003126 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003127 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003128 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003129 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003130 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003131 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003132 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003133 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3134 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003135 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003136 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3137 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003138 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003139 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003140 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003141 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003142 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003143 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003144 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003145 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003146 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003147};
3148
3149static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003150 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003151 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3152 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003153 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003154 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003155 .phy_read = mv88e6xxx_g2_smi_phy_read,
3156 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003157 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003158 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003159 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003160 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003161 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003162 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003163 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003164 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003165 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003166 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003167 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003168 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003169 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003170 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003171 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003172 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003173 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003174 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3175 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003176 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003177 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3178 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003179 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003180 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003181 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003182 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003183 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003184 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003185 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003186};
3187
3188static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003189 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003190 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3191 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003192 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003193 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3194 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003195 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003196 .phy_read = mv88e6xxx_g2_smi_phy_read,
3197 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003198 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003199 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003200 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003201 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003202 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003203 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003204 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003205 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003206 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003207 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003208 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003209 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003210 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003211 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003212 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003213 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003214 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003215 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3216 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003217 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003218 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3219 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003220 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003221 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003222 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003223 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003224 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003225 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003226 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003227 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003228 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003229 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003230};
3231
3232static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003233 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003234 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3235 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003236 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003237 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003238 .phy_read = mv88e6xxx_g2_smi_phy_read,
3239 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003240 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003241 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003242 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003243 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003244 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003245 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003246 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003247 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003248 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003249 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003250 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003251 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003252 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003253 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003254 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003255 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003256 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003257 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3258 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003259 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003260 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3261 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003262 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003263 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003264 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003265 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003266 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003267 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003268 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003269};
3270
3271static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003272 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003273 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3274 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003275 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003276 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3277 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003278 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003279 .phy_read = mv88e6xxx_g2_smi_phy_read,
3280 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003281 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003282 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003283 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003284 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003285 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003286 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003287 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003288 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003289 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003290 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003291 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003292 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003293 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003294 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003295 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003296 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003297 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003298 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3299 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003300 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003301 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3302 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003303 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003304 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003305 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003306 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003307 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003308 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003309 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003310 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003311 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3312 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003313 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003314 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003315};
3316
3317static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003318 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003319 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3320 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003321 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003322 .phy_read = mv88e6185_phy_ppu_read,
3323 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003324 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003325 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003326 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003327 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003328 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003329 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003330 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003331 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003332 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003333 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003334 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003335 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003336 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3337 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003338 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003339 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3340 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003341 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003342 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003343 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003344 .ppu_enable = mv88e6185_g1_ppu_enable,
3345 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003346 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003347 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003348 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003349 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003350};
3351
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003352static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003353 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003354 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003355 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003356 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3357 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003358 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3359 .phy_read = mv88e6xxx_g2_smi_phy_read,
3360 .phy_write = mv88e6xxx_g2_smi_phy_write,
3361 .port_set_link = mv88e6xxx_port_set_link,
3362 .port_set_duplex = mv88e6xxx_port_set_duplex,
3363 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3364 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003365 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003366 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003367 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003368 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003369 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003370 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003371 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003372 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003373 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003374 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003375 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003376 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003377 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3378 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003379 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003380 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3381 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003382 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003383 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003384 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003385 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003386 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003387 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3388 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003389 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003390 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3391 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003392 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003393 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003394};
3395
3396static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003397 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003398 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003399 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003400 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3401 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003402 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3403 .phy_read = mv88e6xxx_g2_smi_phy_read,
3404 .phy_write = mv88e6xxx_g2_smi_phy_write,
3405 .port_set_link = mv88e6xxx_port_set_link,
3406 .port_set_duplex = mv88e6xxx_port_set_duplex,
3407 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3408 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003409 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003410 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003411 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003412 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003413 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003414 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003415 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003416 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003417 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003418 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003419 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003420 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003421 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3422 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003423 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003424 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3425 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003426 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003427 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003428 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003429 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003430 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003431 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3432 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003433 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003434 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3435 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003436 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003437 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003438};
3439
3440static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003441 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003442 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003443 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003444 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3445 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003446 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3447 .phy_read = mv88e6xxx_g2_smi_phy_read,
3448 .phy_write = mv88e6xxx_g2_smi_phy_write,
3449 .port_set_link = mv88e6xxx_port_set_link,
3450 .port_set_duplex = mv88e6xxx_port_set_duplex,
3451 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3452 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003453 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003454 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003455 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003456 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003457 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003458 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003459 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003460 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003461 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003462 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003463 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003464 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003465 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3466 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003467 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003468 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3469 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003470 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003471 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003472 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003473 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003474 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003475 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3476 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003477 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003478 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3479 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003480 .avb_ops = &mv88e6390_avb_ops,
3481 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003482 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003483};
3484
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003485static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003486 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003487 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3488 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003489 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003490 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3491 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003492 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003493 .phy_read = mv88e6xxx_g2_smi_phy_read,
3494 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003495 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003496 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003497 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003498 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003499 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003500 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003501 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003502 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003503 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003504 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003505 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003506 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003507 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003508 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003509 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003510 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003511 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003512 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3513 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003514 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003515 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3516 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003517 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003518 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003519 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003520 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003521 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003522 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003523 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003524 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003525 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3526 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003527 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003528 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003529 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003530 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003531};
3532
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003533static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003534 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003535 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003536 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003537 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3538 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003539 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3540 .phy_read = mv88e6xxx_g2_smi_phy_read,
3541 .phy_write = mv88e6xxx_g2_smi_phy_write,
3542 .port_set_link = mv88e6xxx_port_set_link,
3543 .port_set_duplex = mv88e6xxx_port_set_duplex,
3544 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3545 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003546 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003547 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003548 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003549 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003550 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003551 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003552 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003553 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003554 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003555 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003556 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003557 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003558 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3559 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003560 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003561 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3562 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003563 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003564 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003565 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003566 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003567 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003568 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3569 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003570 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003571 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3572 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003573 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003574 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003575 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003576 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003577};
3578
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003579static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003580 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003581 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3582 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003583 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003584 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3585 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003586 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003587 .phy_read = mv88e6xxx_g2_smi_phy_read,
3588 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003589 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003590 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003591 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003592 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003593 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003594 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003595 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003596 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003597 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003598 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003599 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003600 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003601 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003602 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003603 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003604 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003605 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3606 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003607 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003608 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3609 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003610 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003611 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003612 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003613 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003614 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003615 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003616 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003617 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003618 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003619 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003620};
3621
3622static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003623 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003624 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3625 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003626 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003627 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3628 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003629 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003630 .phy_read = mv88e6xxx_g2_smi_phy_read,
3631 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003632 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003633 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003634 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003635 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003636 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003637 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003638 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003639 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003640 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003641 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003642 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003643 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003644 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003645 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003646 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003647 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003648 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3649 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003650 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003651 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3652 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003653 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003654 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003655 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003656 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003657 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003658 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003659 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003660 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003661};
3662
Vivien Didelot16e329a2017-03-28 13:50:33 -04003663static const struct mv88e6xxx_ops mv88e6341_ops = {
3664 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003665 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3666 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003667 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003668 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3669 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3670 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3671 .phy_read = mv88e6xxx_g2_smi_phy_read,
3672 .phy_write = mv88e6xxx_g2_smi_phy_write,
3673 .port_set_link = mv88e6xxx_port_set_link,
3674 .port_set_duplex = mv88e6xxx_port_set_duplex,
3675 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003676 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003677 .port_tag_remap = mv88e6095_port_tag_remap,
3678 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3679 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3680 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003681 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003682 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003683 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003684 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3685 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003686 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003687 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003688 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003689 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003690 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3691 .stats_get_strings = mv88e6320_stats_get_strings,
3692 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003693 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3694 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003695 .watchdog_ops = &mv88e6390_watchdog_ops,
3696 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003697 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003698 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003699 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003700 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003701 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003702 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003703 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003704 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003705 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003706};
3707
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003708static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003709 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003710 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3711 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003712 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003713 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003714 .phy_read = mv88e6xxx_g2_smi_phy_read,
3715 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003716 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003717 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003718 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003719 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003720 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003721 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003722 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003723 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003724 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003725 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003726 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003727 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003728 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003729 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003730 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003731 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003732 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003733 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3734 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003735 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003736 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3737 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003738 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003739 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003740 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003741 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003742 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003743 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003744 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003745};
3746
3747static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003748 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003749 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3750 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003751 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003752 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003753 .phy_read = mv88e6xxx_g2_smi_phy_read,
3754 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003755 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003756 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003757 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003758 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003759 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003760 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003761 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003762 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003763 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003764 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003765 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003766 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003767 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003768 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003769 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003770 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003771 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003772 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3773 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003774 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003775 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3776 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003777 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003778 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003779 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003780 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003781 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003782 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003783 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003784 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003785 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003786};
3787
3788static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003789 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003790 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3791 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003792 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003793 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3794 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003795 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003796 .phy_read = mv88e6xxx_g2_smi_phy_read,
3797 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003798 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003799 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003800 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003801 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003802 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003803 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003804 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003805 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003806 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003807 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003808 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003809 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003810 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003811 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003812 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003813 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003814 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003815 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3816 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003817 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003818 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3819 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003820 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003821 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003822 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003823 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003824 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003825 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003826 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003827 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003828 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3829 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003830 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003831 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003832 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003833 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3834 .serdes_get_strings = mv88e6352_serdes_get_strings,
3835 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003836 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003837};
3838
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003839static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003840 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003841 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003842 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003843 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3844 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003845 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3846 .phy_read = mv88e6xxx_g2_smi_phy_read,
3847 .phy_write = mv88e6xxx_g2_smi_phy_write,
3848 .port_set_link = mv88e6xxx_port_set_link,
3849 .port_set_duplex = mv88e6xxx_port_set_duplex,
3850 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3851 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003852 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003853 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003854 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003855 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003856 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003857 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003858 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003859 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003860 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003861 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003862 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003863 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003864 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003865 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003866 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3867 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003868 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003869 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3870 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003871 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003872 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003873 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003874 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003875 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003876 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3877 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003878 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003879 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3880 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003881 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003882 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003883 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003884 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003885};
3886
3887static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003888 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003889 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003890 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003891 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3892 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003893 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3894 .phy_read = mv88e6xxx_g2_smi_phy_read,
3895 .phy_write = mv88e6xxx_g2_smi_phy_write,
3896 .port_set_link = mv88e6xxx_port_set_link,
3897 .port_set_duplex = mv88e6xxx_port_set_duplex,
3898 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3899 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003900 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003901 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003902 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003903 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003904 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003905 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003906 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003907 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003908 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003909 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003910 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003911 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003912 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003913 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003914 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3915 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003916 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003917 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3918 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003919 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003920 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003921 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003922 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003923 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003924 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3925 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003926 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003927 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3928 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003929 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003930 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003931 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003932 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003933};
3934
Vivien Didelotf81ec902016-05-09 13:22:58 -04003935static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3936 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003937 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003938 .family = MV88E6XXX_FAMILY_6097,
3939 .name = "Marvell 88E6085",
3940 .num_databases = 4096,
3941 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003942 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003943 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003944 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003945 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003946 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003947 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003948 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003949 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003950 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003951 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003952 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003953 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003954 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003955 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003956 },
3957
3958 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003959 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003960 .family = MV88E6XXX_FAMILY_6095,
3961 .name = "Marvell 88E6095/88E6095F",
3962 .num_databases = 256,
3963 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003964 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003965 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003966 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003967 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003968 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003969 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003970 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003971 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003972 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003973 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003974 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003975 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003976 },
3977
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003978 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003979 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003980 .family = MV88E6XXX_FAMILY_6097,
3981 .name = "Marvell 88E6097/88E6097F",
3982 .num_databases = 4096,
3983 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003984 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003985 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003986 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003987 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003988 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003989 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003990 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003991 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003992 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003993 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003994 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003995 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003996 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003997 .ops = &mv88e6097_ops,
3998 },
3999
Vivien Didelotf81ec902016-05-09 13:22:58 -04004000 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004001 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004002 .family = MV88E6XXX_FAMILY_6165,
4003 .name = "Marvell 88E6123",
4004 .num_databases = 4096,
4005 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004006 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004007 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004008 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004009 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004010 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004011 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004012 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004013 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004014 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004015 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004016 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004017 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004018 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004019 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004020 },
4021
4022 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004023 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004024 .family = MV88E6XXX_FAMILY_6185,
4025 .name = "Marvell 88E6131",
4026 .num_databases = 256,
4027 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004028 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004029 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004030 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004031 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004032 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004033 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004034 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004035 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004036 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004037 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004038 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004039 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004040 },
4041
Vivien Didelot990e27b2017-03-28 13:50:32 -04004042 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004043 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004044 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004045 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004046 .num_databases = 4096,
4047 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004048 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004049 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004050 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004051 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004052 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004053 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004054 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004055 .age_time_coeff = 3750,
4056 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004057 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004058 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004059 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004060 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004061 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004062 .ops = &mv88e6141_ops,
4063 },
4064
Vivien Didelotf81ec902016-05-09 13:22:58 -04004065 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004066 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004067 .family = MV88E6XXX_FAMILY_6165,
4068 .name = "Marvell 88E6161",
4069 .num_databases = 4096,
4070 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004071 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004072 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004073 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004074 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004075 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004076 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004077 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004078 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004079 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004080 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004081 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004082 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004083 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004084 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004085 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004086 },
4087
4088 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004089 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004090 .family = MV88E6XXX_FAMILY_6165,
4091 .name = "Marvell 88E6165",
4092 .num_databases = 4096,
4093 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004094 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004095 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004096 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004097 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004098 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004099 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004100 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004101 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004102 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004103 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004104 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004105 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004106 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004107 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004108 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004109 },
4110
4111 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004112 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004113 .family = MV88E6XXX_FAMILY_6351,
4114 .name = "Marvell 88E6171",
4115 .num_databases = 4096,
4116 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004117 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004118 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004119 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004120 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004121 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004122 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004123 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004124 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004125 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004126 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004127 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004128 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004129 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004130 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004131 },
4132
4133 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004134 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004135 .family = MV88E6XXX_FAMILY_6352,
4136 .name = "Marvell 88E6172",
4137 .num_databases = 4096,
4138 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004139 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004140 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004141 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004142 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004143 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004144 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004145 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004146 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004147 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004148 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004149 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004150 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004151 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004152 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004153 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004154 },
4155
4156 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004157 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004158 .family = MV88E6XXX_FAMILY_6351,
4159 .name = "Marvell 88E6175",
4160 .num_databases = 4096,
4161 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004162 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004163 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004164 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004165 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004166 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004167 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004168 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004169 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004170 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004171 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004172 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004173 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004174 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004175 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004176 },
4177
4178 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004179 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004180 .family = MV88E6XXX_FAMILY_6352,
4181 .name = "Marvell 88E6176",
4182 .num_databases = 4096,
4183 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004184 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004185 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004186 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004187 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004188 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004189 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004190 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004191 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004192 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004193 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004194 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004195 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004196 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004197 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004198 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004199 },
4200
4201 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004202 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004203 .family = MV88E6XXX_FAMILY_6185,
4204 .name = "Marvell 88E6185",
4205 .num_databases = 256,
4206 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004207 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004208 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004209 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004210 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004211 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004212 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004213 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004214 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004215 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004216 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004217 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004218 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004219 },
4220
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004221 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004222 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004223 .family = MV88E6XXX_FAMILY_6390,
4224 .name = "Marvell 88E6190",
4225 .num_databases = 4096,
4226 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004227 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004228 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004229 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004230 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004231 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004232 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004233 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004234 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004235 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004236 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004237 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004238 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004239 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004240 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004241 .ops = &mv88e6190_ops,
4242 },
4243
4244 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004245 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004246 .family = MV88E6XXX_FAMILY_6390,
4247 .name = "Marvell 88E6190X",
4248 .num_databases = 4096,
4249 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004250 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004251 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004252 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004253 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004254 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004255 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004256 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004257 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004258 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004259 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004260 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004261 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004262 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004263 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004264 .ops = &mv88e6190x_ops,
4265 },
4266
4267 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004268 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004269 .family = MV88E6XXX_FAMILY_6390,
4270 .name = "Marvell 88E6191",
4271 .num_databases = 4096,
4272 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004273 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004274 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004275 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004276 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004277 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004278 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004279 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004280 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004281 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004282 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004283 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004284 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004285 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004286 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004287 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004288 },
4289
Vivien Didelotf81ec902016-05-09 13:22:58 -04004290 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004291 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004292 .family = MV88E6XXX_FAMILY_6352,
4293 .name = "Marvell 88E6240",
4294 .num_databases = 4096,
4295 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004296 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004297 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004298 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004299 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004300 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004301 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004302 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004303 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004304 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004305 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004306 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004307 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004308 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004309 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004310 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004311 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004312 },
4313
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004314 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004315 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004316 .family = MV88E6XXX_FAMILY_6390,
4317 .name = "Marvell 88E6290",
4318 .num_databases = 4096,
4319 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004320 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004321 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004322 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004323 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004324 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004325 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004326 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004327 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004328 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004329 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004330 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004331 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004332 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004333 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004334 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004335 .ops = &mv88e6290_ops,
4336 },
4337
Vivien Didelotf81ec902016-05-09 13:22:58 -04004338 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004339 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004340 .family = MV88E6XXX_FAMILY_6320,
4341 .name = "Marvell 88E6320",
4342 .num_databases = 4096,
4343 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004344 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004345 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004346 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004347 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004348 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004349 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004350 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004351 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004352 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004353 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004354 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004355 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004356 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004357 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004358 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004359 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004360 },
4361
4362 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004363 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004364 .family = MV88E6XXX_FAMILY_6320,
4365 .name = "Marvell 88E6321",
4366 .num_databases = 4096,
4367 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004368 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004369 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004370 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004371 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004372 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004373 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004374 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004375 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004376 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004377 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004378 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004379 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004380 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004381 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004382 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004383 },
4384
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004385 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004386 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004387 .family = MV88E6XXX_FAMILY_6341,
4388 .name = "Marvell 88E6341",
4389 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004390 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004391 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004392 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004393 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004394 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004395 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004396 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004397 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004398 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004399 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004400 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004401 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004402 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004403 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004404 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004405 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004406 .ops = &mv88e6341_ops,
4407 },
4408
Vivien Didelotf81ec902016-05-09 13:22:58 -04004409 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004410 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004411 .family = MV88E6XXX_FAMILY_6351,
4412 .name = "Marvell 88E6350",
4413 .num_databases = 4096,
4414 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004415 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004416 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004417 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004418 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004419 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004420 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004421 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004422 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004423 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004424 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004425 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004426 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004427 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004428 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004429 },
4430
4431 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004432 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004433 .family = MV88E6XXX_FAMILY_6351,
4434 .name = "Marvell 88E6351",
4435 .num_databases = 4096,
4436 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004437 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004438 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004439 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004440 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004441 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004442 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004443 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004444 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004445 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004446 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004447 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004448 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004449 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004450 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004451 },
4452
4453 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004454 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004455 .family = MV88E6XXX_FAMILY_6352,
4456 .name = "Marvell 88E6352",
4457 .num_databases = 4096,
4458 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004459 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004460 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004461 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004462 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004463 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004464 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004465 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004466 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004467 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004468 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004469 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004470 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004471 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004472 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004473 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004474 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004475 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004476 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004477 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004478 .family = MV88E6XXX_FAMILY_6390,
4479 .name = "Marvell 88E6390",
4480 .num_databases = 4096,
4481 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004482 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004483 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004484 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004485 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004486 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004487 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004488 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004489 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004490 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004491 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004492 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004493 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004494 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004495 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004496 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004497 .ops = &mv88e6390_ops,
4498 },
4499 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004500 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004501 .family = MV88E6XXX_FAMILY_6390,
4502 .name = "Marvell 88E6390X",
4503 .num_databases = 4096,
4504 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004505 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004506 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004507 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004508 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004509 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004510 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004511 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004512 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004513 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004514 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004515 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004516 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004517 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004518 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004519 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004520 .ops = &mv88e6390x_ops,
4521 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004522};
4523
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004524static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004525{
Vivien Didelota439c062016-04-17 13:23:58 -04004526 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004527
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004528 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4529 if (mv88e6xxx_table[i].prod_num == prod_num)
4530 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004531
Vivien Didelotb9b37712015-10-30 19:39:48 -04004532 return NULL;
4533}
4534
Vivien Didelotfad09c72016-06-21 12:28:20 -04004535static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004536{
4537 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004538 unsigned int prod_num, rev;
4539 u16 id;
4540 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004541
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004542 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004543 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004544 mutex_unlock(&chip->reg_lock);
4545 if (err)
4546 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004547
Vivien Didelot107fcc12017-06-12 12:37:36 -04004548 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4549 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004550
4551 info = mv88e6xxx_lookup_info(prod_num);
4552 if (!info)
4553 return -ENODEV;
4554
Vivien Didelotcaac8542016-06-20 13:14:09 -04004555 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004556 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004557
Vivien Didelotca070c12016-09-02 14:45:34 -04004558 err = mv88e6xxx_g2_require(chip);
4559 if (err)
4560 return err;
4561
Vivien Didelotfad09c72016-06-21 12:28:20 -04004562 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4563 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004564
4565 return 0;
4566}
4567
Vivien Didelotfad09c72016-06-21 12:28:20 -04004568static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004569{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004570 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004571
Vivien Didelotfad09c72016-06-21 12:28:20 -04004572 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4573 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004574 return NULL;
4575
Vivien Didelotfad09c72016-06-21 12:28:20 -04004576 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004577
Vivien Didelotfad09c72016-06-21 12:28:20 -04004578 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004579 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004580
Vivien Didelotfad09c72016-06-21 12:28:20 -04004581 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004582}
4583
Vivien Didelotfad09c72016-06-21 12:28:20 -04004584static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004585 struct mii_bus *bus, int sw_addr)
4586{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004587 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004588 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004589 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004590 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004591 else
4592 return -EINVAL;
4593
Vivien Didelotfad09c72016-06-21 12:28:20 -04004594 chip->bus = bus;
4595 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004596
4597 return 0;
4598}
4599
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004600static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4601 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004602{
Vivien Didelot04bed142016-08-31 18:06:13 -04004603 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004604
Andrew Lunn443d5a12016-12-03 04:35:18 +01004605 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004606}
4607
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004608#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004609static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4610 struct device *host_dev, int sw_addr,
4611 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004612{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004613 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004614 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004615 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004616
Vivien Didelota439c062016-04-17 13:23:58 -04004617 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004618 if (!bus)
4619 return NULL;
4620
Vivien Didelotfad09c72016-06-21 12:28:20 -04004621 chip = mv88e6xxx_alloc_chip(dsa_dev);
4622 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004623 return NULL;
4624
Vivien Didelotcaac8542016-06-20 13:14:09 -04004625 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004626 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004627
Vivien Didelotfad09c72016-06-21 12:28:20 -04004628 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004629 if (err)
4630 goto free;
4631
Vivien Didelotfad09c72016-06-21 12:28:20 -04004632 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004633 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004634 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004635
Andrew Lunndc30c352016-10-16 19:56:49 +02004636 mutex_lock(&chip->reg_lock);
4637 err = mv88e6xxx_switch_reset(chip);
4638 mutex_unlock(&chip->reg_lock);
4639 if (err)
4640 goto free;
4641
Vivien Didelote57e5e72016-08-15 17:19:00 -04004642 mv88e6xxx_phy_init(chip);
4643
Andrew Lunna3c53be52017-01-24 14:53:50 +01004644 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004645 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004646 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004647
Vivien Didelotfad09c72016-06-21 12:28:20 -04004648 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004649
Vivien Didelotfad09c72016-06-21 12:28:20 -04004650 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004651free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004652 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004653
4654 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004655}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004656#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004657
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004658static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004659 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004660{
4661 /* We don't need any dynamic resource from the kernel (yet),
4662 * so skip the prepare phase.
4663 */
4664
4665 return 0;
4666}
4667
4668static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004669 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004670{
Vivien Didelot04bed142016-08-31 18:06:13 -04004671 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004672
4673 mutex_lock(&chip->reg_lock);
4674 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004675 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004676 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4677 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004678 mutex_unlock(&chip->reg_lock);
4679}
4680
4681static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4682 const struct switchdev_obj_port_mdb *mdb)
4683{
Vivien Didelot04bed142016-08-31 18:06:13 -04004684 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004685 int err;
4686
4687 mutex_lock(&chip->reg_lock);
4688 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004689 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004690 mutex_unlock(&chip->reg_lock);
4691
4692 return err;
4693}
4694
Russell King4f859012019-02-20 15:35:05 -08004695static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4696 bool unicast, bool multicast)
4697{
4698 struct mv88e6xxx_chip *chip = ds->priv;
4699 int err = -EOPNOTSUPP;
4700
4701 mutex_lock(&chip->reg_lock);
4702 if (chip->info->ops->port_set_egress_floods)
4703 err = chip->info->ops->port_set_egress_floods(chip, port,
4704 unicast,
4705 multicast);
4706 mutex_unlock(&chip->reg_lock);
4707
4708 return err;
4709}
4710
Florian Fainellia82f67a2017-01-08 14:52:08 -08004711static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004712#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004713 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004714#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004715 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004716 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004717 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004718 .phylink_validate = mv88e6xxx_validate,
4719 .phylink_mac_link_state = mv88e6xxx_link_state,
4720 .phylink_mac_config = mv88e6xxx_mac_config,
4721 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4722 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004723 .get_strings = mv88e6xxx_get_strings,
4724 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4725 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004726 .port_enable = mv88e6xxx_port_enable,
4727 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004728 .get_mac_eee = mv88e6xxx_get_mac_eee,
4729 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004730 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004731 .get_eeprom = mv88e6xxx_get_eeprom,
4732 .set_eeprom = mv88e6xxx_set_eeprom,
4733 .get_regs_len = mv88e6xxx_get_regs_len,
4734 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004735 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004736 .port_bridge_join = mv88e6xxx_port_bridge_join,
4737 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004738 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004739 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004740 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004741 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4742 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4743 .port_vlan_add = mv88e6xxx_port_vlan_add,
4744 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004745 .port_fdb_add = mv88e6xxx_port_fdb_add,
4746 .port_fdb_del = mv88e6xxx_port_fdb_del,
4747 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004748 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4749 .port_mdb_add = mv88e6xxx_port_mdb_add,
4750 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004751 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4752 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004753 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4754 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4755 .port_txtstamp = mv88e6xxx_port_txtstamp,
4756 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4757 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004758};
4759
Florian Fainelliab3d4082017-01-08 14:52:07 -08004760static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4761 .ops = &mv88e6xxx_switch_ops,
4762};
4763
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004764static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004765{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004766 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004767 struct dsa_switch *ds;
4768
Vivien Didelot73b12042017-03-30 17:37:10 -04004769 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004770 if (!ds)
4771 return -ENOMEM;
4772
Vivien Didelotfad09c72016-06-21 12:28:20 -04004773 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004774 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004775 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004776 ds->ageing_time_min = chip->info->age_time_coeff;
4777 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004778
4779 dev_set_drvdata(dev, ds);
4780
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004781 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004782}
4783
Vivien Didelotfad09c72016-06-21 12:28:20 -04004784static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004785{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004786 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004787}
4788
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004789static const void *pdata_device_get_match_data(struct device *dev)
4790{
4791 const struct of_device_id *matches = dev->driver->of_match_table;
4792 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4793
4794 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4795 matches++) {
4796 if (!strcmp(pdata->compatible, matches->compatible))
4797 return matches->data;
4798 }
4799 return NULL;
4800}
4801
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004802/* There is no suspend to RAM support at DSA level yet, the switch configuration
4803 * would be lost after a power cycle so prevent it to be suspended.
4804 */
4805static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4806{
4807 return -EOPNOTSUPP;
4808}
4809
4810static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4811{
4812 return 0;
4813}
4814
4815static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4816
Vivien Didelot57d32312016-06-20 13:13:58 -04004817static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004818{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004819 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004820 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004821 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004822 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004823 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004824 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004825 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004826
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004827 if (!np && !pdata)
4828 return -EINVAL;
4829
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004830 if (np)
4831 compat_info = of_device_get_match_data(dev);
4832
4833 if (pdata) {
4834 compat_info = pdata_device_get_match_data(dev);
4835
4836 if (!pdata->netdev)
4837 return -EINVAL;
4838
4839 for (port = 0; port < DSA_MAX_PORTS; port++) {
4840 if (!(pdata->enabled_ports & (1 << port)))
4841 continue;
4842 if (strcmp(pdata->cd.port_names[port], "cpu"))
4843 continue;
4844 pdata->cd.netdev[port] = &pdata->netdev->dev;
4845 break;
4846 }
4847 }
4848
Vivien Didelotcaac8542016-06-20 13:14:09 -04004849 if (!compat_info)
4850 return -EINVAL;
4851
Vivien Didelotfad09c72016-06-21 12:28:20 -04004852 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004853 if (!chip) {
4854 err = -ENOMEM;
4855 goto out;
4856 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004857
Vivien Didelotfad09c72016-06-21 12:28:20 -04004858 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004859
Vivien Didelotfad09c72016-06-21 12:28:20 -04004860 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004861 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004862 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004863
Andrew Lunnb4308f02016-11-21 23:26:55 +01004864 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004865 if (IS_ERR(chip->reset)) {
4866 err = PTR_ERR(chip->reset);
4867 goto out;
4868 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004869
Vivien Didelotfad09c72016-06-21 12:28:20 -04004870 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004871 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004872 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004873
Vivien Didelote57e5e72016-08-15 17:19:00 -04004874 mv88e6xxx_phy_init(chip);
4875
Andrew Lunn00baabe2018-05-19 22:31:35 +02004876 if (chip->info->ops->get_eeprom) {
4877 if (np)
4878 of_property_read_u32(np, "eeprom-length",
4879 &chip->eeprom_len);
4880 else
4881 chip->eeprom_len = pdata->eeprom_len;
4882 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004883
Andrew Lunndc30c352016-10-16 19:56:49 +02004884 mutex_lock(&chip->reg_lock);
4885 err = mv88e6xxx_switch_reset(chip);
4886 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004887 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004888 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004889
Andrew Lunndc30c352016-10-16 19:56:49 +02004890 chip->irq = of_irq_get(np, 0);
4891 if (chip->irq == -EPROBE_DEFER) {
4892 err = chip->irq;
4893 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004894 }
4895
Andrew Lunn294d7112018-02-22 22:58:32 +01004896 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004897 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004898 * controllers
4899 */
4900 mutex_lock(&chip->reg_lock);
4901 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004902 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004903 else
4904 err = mv88e6xxx_irq_poll_setup(chip);
4905 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004906
Andrew Lunn294d7112018-02-22 22:58:32 +01004907 if (err)
4908 goto out;
4909
4910 if (chip->info->g2_irqs > 0) {
4911 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004912 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004913 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004914 }
4915
Andrew Lunn294d7112018-02-22 22:58:32 +01004916 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4917 if (err)
4918 goto out_g2_irq;
4919
4920 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4921 if (err)
4922 goto out_g1_atu_prob_irq;
4923
Andrew Lunna3c53be52017-01-24 14:53:50 +01004924 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004925 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004926 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004927
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004928 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004929 if (err)
4930 goto out_mdio;
4931
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004932 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004933
4934out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004935 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004936out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004937 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004938out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004939 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004940out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004941 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004942 mv88e6xxx_g2_irq_free(chip);
4943out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004944 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004945 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004946 else
4947 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004948out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004949 if (pdata)
4950 dev_put(pdata->netdev);
4951
Andrew Lunndc30c352016-10-16 19:56:49 +02004952 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004953}
4954
4955static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4956{
4957 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004958 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004959
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004960 if (chip->info->ptp_support) {
4961 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004962 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004963 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004964
Andrew Lunn930188c2016-08-22 16:01:03 +02004965 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004966 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004967 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004968
Andrew Lunn76f38f12018-03-17 20:21:09 +01004969 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4970 mv88e6xxx_g1_atu_prob_irq_free(chip);
4971
4972 if (chip->info->g2_irqs > 0)
4973 mv88e6xxx_g2_irq_free(chip);
4974
Andrew Lunn76f38f12018-03-17 20:21:09 +01004975 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004976 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004977 else
4978 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004979}
4980
4981static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004982 {
4983 .compatible = "marvell,mv88e6085",
4984 .data = &mv88e6xxx_table[MV88E6085],
4985 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004986 {
4987 .compatible = "marvell,mv88e6190",
4988 .data = &mv88e6xxx_table[MV88E6190],
4989 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004990 { /* sentinel */ },
4991};
4992
4993MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4994
4995static struct mdio_driver mv88e6xxx_driver = {
4996 .probe = mv88e6xxx_probe,
4997 .remove = mv88e6xxx_remove,
4998 .mdiodrv.driver = {
4999 .name = "mv88e6085",
5000 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005001 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005002 },
5003};
5004
Ben Hutchings98e67302011-11-25 14:36:19 +00005005static int __init mv88e6xxx_init(void)
5006{
Florian Fainelliab3d4082017-01-08 14:52:07 -08005007 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005008 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00005009}
5010module_init(mv88e6xxx_init);
5011
5012static void __exit mv88e6xxx_cleanup(void)
5013{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005014 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08005015 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00005016}
5017module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005018
5019MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5020MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5021MODULE_LICENSE("GPL");