blob: 3546c5e2b924241e1f1a21f7d51d0f1174e197bc [file] [log] [blame]
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04002 * Marvell 88e6xxx Ethernet switch single-chip support
3 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00004 * Copyright (c) 2008 Marvell Semiconductor
5 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
7 *
Vivien Didelot4333d612017-03-28 15:10:36 -04008 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
9 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
10 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
Barry Grussling19b2f972013-01-08 16:05:54 +000017#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070018#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020019#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070020#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020021#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000024#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000025#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020026#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000027#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040028#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020029#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020030#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020031#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000032#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010033#include <linux/gpio/consumer.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000034#include <linux/phy.h>
Russell Kingc9a23562018-05-10 13:17:35 -070035#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000036#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040037
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040038#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040039#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040040#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010041#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020042#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010043#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010044#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020045#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000046
Vivien Didelotfad09c72016-06-21 12:28:20 -040047static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048{
Vivien Didelotfad09c72016-06-21 12:28:20 -040049 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
50 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040051 dump_stack();
52 }
53}
54
Vivien Didelot914b32f2016-06-20 13:14:11 -040055/* The switch ADDR[4:1] configuration pins define the chip SMI device address
56 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
57 *
58 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
59 * is the only device connected to the SMI master. In this mode it responds to
60 * all 32 possible SMI addresses, and thus maps directly the internal devices.
61 *
62 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
63 * multiple devices to share the SMI interface. In this mode it responds to only
64 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000065 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040066
Vivien Didelotfad09c72016-06-21 12:28:20 -040067static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040068 int addr, int reg, u16 *val)
69{
Vivien Didelotfad09c72016-06-21 12:28:20 -040070 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040071 return -EOPNOTSUPP;
72
Vivien Didelotfad09c72016-06-21 12:28:20 -040073 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040074}
75
Vivien Didelotfad09c72016-06-21 12:28:20 -040076static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040077 int addr, int reg, u16 val)
78{
Vivien Didelotfad09c72016-06-21 12:28:20 -040079 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040080 return -EOPNOTSUPP;
81
Vivien Didelotfad09c72016-06-21 12:28:20 -040082 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040083}
84
Vivien Didelotfad09c72016-06-21 12:28:20 -040085static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040086 int addr, int reg, u16 *val)
87{
88 int ret;
89
Vivien Didelotfad09c72016-06-21 12:28:20 -040090 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040091 if (ret < 0)
92 return ret;
93
94 *val = ret & 0xffff;
95
96 return 0;
97}
98
Vivien Didelotfad09c72016-06-21 12:28:20 -040099static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400100 int addr, int reg, u16 val)
101{
102 int ret;
103
Vivien Didelotfad09c72016-06-21 12:28:20 -0400104 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400105 if (ret < 0)
106 return ret;
107
108 return 0;
109}
110
Vivien Didelotc08026a2016-09-29 12:21:59 -0400111static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400112 .read = mv88e6xxx_smi_single_chip_read,
113 .write = mv88e6xxx_smi_single_chip_write,
114};
115
Vivien Didelotfad09c72016-06-21 12:28:20 -0400116static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000117{
118 int ret;
119 int i;
120
121 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400122 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000123 if (ret < 0)
124 return ret;
125
Andrew Lunncca8b132015-04-02 04:06:39 +0200126 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000127 return 0;
128 }
129
130 return -ETIMEDOUT;
131}
132
Vivien Didelotfad09c72016-06-21 12:28:20 -0400133static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400134 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000135{
136 int ret;
137
Barry Grussling3675c8d2013-01-08 16:05:53 +0000138 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400139 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000140 if (ret < 0)
141 return ret;
142
Barry Grussling3675c8d2013-01-08 16:05:53 +0000143 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400144 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200145 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000146 if (ret < 0)
147 return ret;
148
Barry Grussling3675c8d2013-01-08 16:05:53 +0000149 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400150 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000151 if (ret < 0)
152 return ret;
153
Barry Grussling3675c8d2013-01-08 16:05:53 +0000154 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400155 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000156 if (ret < 0)
157 return ret;
158
Vivien Didelot914b32f2016-06-20 13:14:11 -0400159 *val = ret & 0xffff;
160
161 return 0;
162}
163
Vivien Didelotfad09c72016-06-21 12:28:20 -0400164static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400165 int addr, int reg, u16 val)
166{
167 int ret;
168
169 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400170 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400171 if (ret < 0)
172 return ret;
173
174 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400175 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400176 if (ret < 0)
177 return ret;
178
179 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400180 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400181 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
182 if (ret < 0)
183 return ret;
184
185 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400186 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400187 if (ret < 0)
188 return ret;
189
190 return 0;
191}
192
Vivien Didelotc08026a2016-09-29 12:21:59 -0400193static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400194 .read = mv88e6xxx_smi_multi_chip_read,
195 .write = mv88e6xxx_smi_multi_chip_write,
196};
197
Vivien Didelotec561272016-09-02 14:45:33 -0400198int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400199{
200 int err;
201
Vivien Didelotfad09c72016-06-21 12:28:20 -0400202 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400203
Vivien Didelotfad09c72016-06-21 12:28:20 -0400204 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400205 if (err)
206 return err;
207
Vivien Didelotfad09c72016-06-21 12:28:20 -0400208 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400209 addr, reg, *val);
210
211 return 0;
212}
213
Vivien Didelotec561272016-09-02 14:45:33 -0400214int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400215{
216 int err;
217
Vivien Didelotfad09c72016-06-21 12:28:20 -0400218 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400219
Vivien Didelotfad09c72016-06-21 12:28:20 -0400220 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400221 if (err)
222 return err;
223
Vivien Didelotfad09c72016-06-21 12:28:20 -0400224 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400225 addr, reg, val);
226
227 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000228}
229
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200230struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100231{
232 struct mv88e6xxx_mdio_bus *mdio_bus;
233
234 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
235 list);
236 if (!mdio_bus)
237 return NULL;
238
239 return mdio_bus->bus;
240}
241
Andrew Lunndc30c352016-10-16 19:56:49 +0200242static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
243{
244 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
245 unsigned int n = d->hwirq;
246
247 chip->g1_irq.masked |= (1 << n);
248}
249
250static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
251{
252 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
253 unsigned int n = d->hwirq;
254
255 chip->g1_irq.masked &= ~(1 << n);
256}
257
Andrew Lunn294d7112018-02-22 22:58:32 +0100258static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200259{
Andrew Lunndc30c352016-10-16 19:56:49 +0200260 unsigned int nhandled = 0;
261 unsigned int sub_irq;
262 unsigned int n;
263 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500264 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200265 int err;
266
267 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400268 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200269 mutex_unlock(&chip->reg_lock);
270
271 if (err)
272 goto out;
273
John David Anglin7c0db242019-02-11 13:40:21 -0500274 do {
275 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
276 if (reg & (1 << n)) {
277 sub_irq = irq_find_mapping(chip->g1_irq.domain,
278 n);
279 handle_nested_irq(sub_irq);
280 ++nhandled;
281 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200282 }
John David Anglin7c0db242019-02-11 13:40:21 -0500283
284 mutex_lock(&chip->reg_lock);
285 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
286 if (err)
287 goto unlock;
288 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
289unlock:
290 mutex_unlock(&chip->reg_lock);
291 if (err)
292 goto out;
293 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
294 } while (reg & ctl1);
295
Andrew Lunndc30c352016-10-16 19:56:49 +0200296out:
297 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
298}
299
Andrew Lunn294d7112018-02-22 22:58:32 +0100300static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
301{
302 struct mv88e6xxx_chip *chip = dev_id;
303
304 return mv88e6xxx_g1_irq_thread_work(chip);
305}
306
Andrew Lunndc30c352016-10-16 19:56:49 +0200307static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
308{
309 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
310
311 mutex_lock(&chip->reg_lock);
312}
313
314static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
315{
316 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
317 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
318 u16 reg;
319 int err;
320
Vivien Didelotd77f4322017-06-15 12:14:03 -0400321 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200322 if (err)
323 goto out;
324
325 reg &= ~mask;
326 reg |= (~chip->g1_irq.masked & mask);
327
Vivien Didelotd77f4322017-06-15 12:14:03 -0400328 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200329 if (err)
330 goto out;
331
332out:
333 mutex_unlock(&chip->reg_lock);
334}
335
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530336static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200337 .name = "mv88e6xxx-g1",
338 .irq_mask = mv88e6xxx_g1_irq_mask,
339 .irq_unmask = mv88e6xxx_g1_irq_unmask,
340 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
341 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
342};
343
344static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
345 unsigned int irq,
346 irq_hw_number_t hwirq)
347{
348 struct mv88e6xxx_chip *chip = d->host_data;
349
350 irq_set_chip_data(irq, d->host_data);
351 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
352 irq_set_noprobe(irq);
353
354 return 0;
355}
356
357static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
358 .map = mv88e6xxx_g1_irq_domain_map,
359 .xlate = irq_domain_xlate_twocell,
360};
361
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200362/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100363static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200364{
365 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100366 u16 mask;
367
Vivien Didelotd77f4322017-06-15 12:14:03 -0400368 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100369 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400370 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100371
Andreas Färber5edef2f2016-11-27 23:26:28 +0100372 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100373 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200374 irq_dispose_mapping(virq);
375 }
376
Andrew Lunna3db3d32016-11-20 20:14:14 +0100377 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200378}
379
Andrew Lunn294d7112018-02-22 22:58:32 +0100380static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
381{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200382 /*
383 * free_irq must be called without reg_lock taken because the irq
384 * handler takes this lock, too.
385 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100386 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200387
388 mutex_lock(&chip->reg_lock);
389 mv88e6xxx_g1_irq_free_common(chip);
390 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100391}
392
393static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200394{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100395 int err, irq, virq;
396 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200397
398 chip->g1_irq.nirqs = chip->info->g1_irqs;
399 chip->g1_irq.domain = irq_domain_add_simple(
400 NULL, chip->g1_irq.nirqs, 0,
401 &mv88e6xxx_g1_irq_domain_ops, chip);
402 if (!chip->g1_irq.domain)
403 return -ENOMEM;
404
405 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
406 irq_create_mapping(chip->g1_irq.domain, irq);
407
408 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
409 chip->g1_irq.masked = ~0;
410
Vivien Didelotd77f4322017-06-15 12:14:03 -0400411 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200412 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100413 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200414
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100415 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200416
Vivien Didelotd77f4322017-06-15 12:14:03 -0400417 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200418 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100419 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200420
421 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400422 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200423 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100424 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200425
Andrew Lunndc30c352016-10-16 19:56:49 +0200426 return 0;
427
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100428out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100429 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400430 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100431
432out_mapping:
433 for (irq = 0; irq < 16; irq++) {
434 virq = irq_find_mapping(chip->g1_irq.domain, irq);
435 irq_dispose_mapping(virq);
436 }
437
438 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200439
440 return err;
441}
442
Andrew Lunn294d7112018-02-22 22:58:32 +0100443static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
444{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100445 static struct lock_class_key lock_key;
446 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100447 int err;
448
449 err = mv88e6xxx_g1_irq_setup_common(chip);
450 if (err)
451 return err;
452
Andrew Lunnf6d97582019-02-23 17:43:56 +0100453 /* These lock classes tells lockdep that global 1 irqs are in
454 * a different category than their parent GPIO, so it won't
455 * report false recursion.
456 */
457 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
458
Andrew Lunn294d7112018-02-22 22:58:32 +0100459 err = request_threaded_irq(chip->irq, NULL,
460 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200461 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100462 dev_name(chip->dev), chip);
463 if (err)
464 mv88e6xxx_g1_irq_free_common(chip);
465
466 return err;
467}
468
469static void mv88e6xxx_irq_poll(struct kthread_work *work)
470{
471 struct mv88e6xxx_chip *chip = container_of(work,
472 struct mv88e6xxx_chip,
473 irq_poll_work.work);
474 mv88e6xxx_g1_irq_thread_work(chip);
475
476 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
477 msecs_to_jiffies(100));
478}
479
480static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
481{
482 int err;
483
484 err = mv88e6xxx_g1_irq_setup_common(chip);
485 if (err)
486 return err;
487
488 kthread_init_delayed_work(&chip->irq_poll_work,
489 mv88e6xxx_irq_poll);
490
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800491 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100492 if (IS_ERR(chip->kworker))
493 return PTR_ERR(chip->kworker);
494
495 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
496 msecs_to_jiffies(100));
497
498 return 0;
499}
500
501static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
502{
503 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
504 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200505
506 mutex_lock(&chip->reg_lock);
507 mv88e6xxx_g1_irq_free_common(chip);
508 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100509}
510
Vivien Didelotec561272016-09-02 14:45:33 -0400511int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400512{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200513 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400514
Andrew Lunn6441e6692016-08-19 00:01:55 +0200515 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400516 u16 val;
517 int err;
518
519 err = mv88e6xxx_read(chip, addr, reg, &val);
520 if (err)
521 return err;
522
523 if (!(val & mask))
524 return 0;
525
526 usleep_range(1000, 2000);
527 }
528
Andrew Lunn30853552016-08-19 00:01:57 +0200529 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400530 return -ETIMEDOUT;
531}
532
Vivien Didelotf22ab642016-07-18 20:45:31 -0400533/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400534int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400535{
536 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200537 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400538
539 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200540 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
541 if (err)
542 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400543
544 /* Set the Update bit to trigger a write operation */
545 val = BIT(15) | update;
546
547 return mv88e6xxx_write(chip, addr, reg, val);
548}
549
Vivien Didelotd78343d2016-11-04 03:23:36 +0100550static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
Andrew Lunn54186b92018-08-09 15:38:37 +0200551 int link, int speed, int duplex, int pause,
Vivien Didelotd78343d2016-11-04 03:23:36 +0100552 phy_interface_t mode)
553{
554 int err;
555
556 if (!chip->info->ops->port_set_link)
557 return 0;
558
559 /* Port's MAC control must not be changed unless the link is down */
560 err = chip->info->ops->port_set_link(chip, port, 0);
561 if (err)
562 return err;
563
564 if (chip->info->ops->port_set_speed) {
565 err = chip->info->ops->port_set_speed(chip, port, speed);
566 if (err && err != -EOPNOTSUPP)
567 goto restore_link;
568 }
569
Andrew Lunn54186b92018-08-09 15:38:37 +0200570 if (chip->info->ops->port_set_pause) {
571 err = chip->info->ops->port_set_pause(chip, port, pause);
572 if (err)
573 goto restore_link;
574 }
575
Vivien Didelotd78343d2016-11-04 03:23:36 +0100576 if (chip->info->ops->port_set_duplex) {
577 err = chip->info->ops->port_set_duplex(chip, port, duplex);
578 if (err && err != -EOPNOTSUPP)
579 goto restore_link;
580 }
581
582 if (chip->info->ops->port_set_rgmii_delay) {
583 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
584 if (err && err != -EOPNOTSUPP)
585 goto restore_link;
586 }
587
Andrew Lunnf39908d2017-02-04 20:02:50 +0100588 if (chip->info->ops->port_set_cmode) {
589 err = chip->info->ops->port_set_cmode(chip, port, mode);
590 if (err && err != -EOPNOTSUPP)
591 goto restore_link;
592 }
593
Vivien Didelotd78343d2016-11-04 03:23:36 +0100594 err = 0;
595restore_link:
596 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400597 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100598
599 return err;
600}
601
Marek Vasutd700ec42018-09-12 00:15:24 +0200602static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
603{
604 struct mv88e6xxx_chip *chip = ds->priv;
605
606 return port < chip->info->num_internal_phys;
607}
608
Andrew Lunndea87022015-08-31 15:56:47 +0200609/* We expect the switch to perform auto negotiation if there is a real
610 * phy. However, in the case of a fixed link phy, we force the port
611 * settings from the fixed link settings.
612 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400613static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
614 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200615{
Vivien Didelot04bed142016-08-31 18:06:13 -0400616 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200617 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200618
Marek Vasutd700ec42018-09-12 00:15:24 +0200619 if (!phy_is_pseudo_fixed_link(phydev) &&
620 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200621 return;
622
Vivien Didelotfad09c72016-06-21 12:28:20 -0400623 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100624 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200625 phydev->duplex, phydev->pause,
626 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400627 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100628
629 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400630 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200631}
632
Russell King6c422e32018-08-09 15:38:39 +0200633static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
634 unsigned long *mask,
635 struct phylink_link_state *state)
636{
637 if (!phy_interface_mode_is_8023z(state->interface)) {
638 /* 10M and 100M are only supported in non-802.3z mode */
639 phylink_set(mask, 10baseT_Half);
640 phylink_set(mask, 10baseT_Full);
641 phylink_set(mask, 100baseT_Half);
642 phylink_set(mask, 100baseT_Full);
643 }
644}
645
646static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
647 unsigned long *mask,
648 struct phylink_link_state *state)
649{
650 /* FIXME: if the port is in 1000Base-X mode, then it only supports
651 * 1000M FD speeds. In this case, CMODE will indicate 5.
652 */
653 phylink_set(mask, 1000baseT_Full);
654 phylink_set(mask, 1000baseX_Full);
655
656 mv88e6065_phylink_validate(chip, port, mask, state);
657}
658
659static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
660 unsigned long *mask,
661 struct phylink_link_state *state)
662{
663 /* No ethtool bits for 200Mbps */
664 phylink_set(mask, 1000baseT_Full);
665 phylink_set(mask, 1000baseX_Full);
666
667 mv88e6065_phylink_validate(chip, port, mask, state);
668}
669
670static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
671 unsigned long *mask,
672 struct phylink_link_state *state)
673{
Andrew Lunnec260162019-02-08 22:25:44 +0100674 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200675 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100676 phylink_set(mask, 2500baseT_Full);
677 }
Russell King6c422e32018-08-09 15:38:39 +0200678
679 /* No ethtool bits for 200Mbps */
680 phylink_set(mask, 1000baseT_Full);
681 phylink_set(mask, 1000baseX_Full);
682
683 mv88e6065_phylink_validate(chip, port, mask, state);
684}
685
686static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
687 unsigned long *mask,
688 struct phylink_link_state *state)
689{
690 if (port >= 9) {
691 phylink_set(mask, 10000baseT_Full);
692 phylink_set(mask, 10000baseKR_Full);
693 }
694
695 mv88e6390_phylink_validate(chip, port, mask, state);
696}
697
Russell Kingc9a23562018-05-10 13:17:35 -0700698static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
699 unsigned long *supported,
700 struct phylink_link_state *state)
701{
Russell King6c422e32018-08-09 15:38:39 +0200702 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
703 struct mv88e6xxx_chip *chip = ds->priv;
704
705 /* Allow all the expected bits */
706 phylink_set(mask, Autoneg);
707 phylink_set(mask, Pause);
708 phylink_set_port_modes(mask);
709
710 if (chip->info->ops->phylink_validate)
711 chip->info->ops->phylink_validate(chip, port, mask, state);
712
713 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
714 bitmap_and(state->advertising, state->advertising, mask,
715 __ETHTOOL_LINK_MODE_MASK_NBITS);
716
717 /* We can only operate at 2500BaseX or 1000BaseX. If requested
718 * to advertise both, only report advertising at 2500BaseX.
719 */
720 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700721}
722
723static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
724 struct phylink_link_state *state)
725{
726 struct mv88e6xxx_chip *chip = ds->priv;
727 int err;
728
729 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200730 if (chip->info->ops->port_link_state)
731 err = chip->info->ops->port_link_state(chip, port, state);
732 else
733 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700734 mutex_unlock(&chip->reg_lock);
735
736 return err;
737}
738
739static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
740 unsigned int mode,
741 const struct phylink_link_state *state)
742{
743 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200744 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700745
Marek Vasutd700ec42018-09-12 00:15:24 +0200746 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700747 return;
748
749 if (mode == MLO_AN_FIXED) {
750 link = LINK_FORCED_UP;
751 speed = state->speed;
752 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200753 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
754 link = state->link;
755 speed = state->speed;
756 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700757 } else {
758 speed = SPEED_UNFORCED;
759 duplex = DUPLEX_UNFORCED;
760 link = LINK_UNFORCED;
761 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200762 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700763
764 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200765 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700766 state->interface);
767 mutex_unlock(&chip->reg_lock);
768
769 if (err && err != -EOPNOTSUPP)
770 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
771}
772
773static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
774{
775 struct mv88e6xxx_chip *chip = ds->priv;
776 int err;
777
778 mutex_lock(&chip->reg_lock);
779 err = chip->info->ops->port_set_link(chip, port, link);
780 mutex_unlock(&chip->reg_lock);
781
782 if (err)
783 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
784}
785
786static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
787 unsigned int mode,
788 phy_interface_t interface)
789{
790 if (mode == MLO_AN_FIXED)
791 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
792}
793
794static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
795 unsigned int mode, phy_interface_t interface,
796 struct phy_device *phydev)
797{
798 if (mode == MLO_AN_FIXED)
799 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
800}
801
Andrew Lunna605a0f2016-11-21 23:26:58 +0100802static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000803{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100804 if (!chip->info->ops->stats_snapshot)
805 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000806
Andrew Lunna605a0f2016-11-21 23:26:58 +0100807 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000808}
809
Andrew Lunne413e7e2015-04-02 04:06:38 +0200810static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100811 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
812 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
813 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
814 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
815 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
816 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
817 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
818 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
819 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
820 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
821 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
822 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
823 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
824 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
825 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
826 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
827 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
828 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
829 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
830 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
831 { "single", 4, 0x14, STATS_TYPE_BANK0, },
832 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
833 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
834 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
835 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
836 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
837 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
838 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
839 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
840 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
841 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
842 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
843 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
844 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
845 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
846 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
847 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
848 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
849 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
850 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
851 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
852 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
853 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
854 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
855 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
856 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
857 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
858 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
859 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
860 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
861 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
862 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
863 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
864 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
865 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
866 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
867 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
868 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
869 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200870};
871
Vivien Didelotfad09c72016-06-21 12:28:20 -0400872static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100873 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100874 int port, u16 bank1_select,
875 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200876{
Andrew Lunn80c46272015-06-20 18:42:30 +0200877 u32 low;
878 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100879 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200880 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200881 u64 value;
882
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100883 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100884 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200885 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
886 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800887 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200888
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200889 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100890 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200891 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
892 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800893 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200894 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200895 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100896 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100897 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100898 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100899 /* fall through */
900 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100901 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100902 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100903 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100904 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500905 break;
906 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800907 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200908 }
909 value = (((u64)high) << 16) | low;
910 return value;
911}
912
Andrew Lunn436fe172018-03-01 02:02:29 +0100913static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
914 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100915{
916 struct mv88e6xxx_hw_stat *stat;
917 int i, j;
918
919 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
920 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100921 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100922 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
923 ETH_GSTRING_LEN);
924 j++;
925 }
926 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100927
928 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100929}
930
Andrew Lunn436fe172018-03-01 02:02:29 +0100931static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
932 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100933{
Andrew Lunn436fe172018-03-01 02:02:29 +0100934 return mv88e6xxx_stats_get_strings(chip, data,
935 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100936}
937
Andrew Lunn436fe172018-03-01 02:02:29 +0100938static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
939 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100940{
Andrew Lunn436fe172018-03-01 02:02:29 +0100941 return mv88e6xxx_stats_get_strings(chip, data,
942 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100943}
944
Andrew Lunn65f60e42018-03-28 23:50:28 +0200945static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
946 "atu_member_violation",
947 "atu_miss_violation",
948 "atu_full_violation",
949 "vtu_member_violation",
950 "vtu_miss_violation",
951};
952
953static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
954{
955 unsigned int i;
956
957 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
958 strlcpy(data + i * ETH_GSTRING_LEN,
959 mv88e6xxx_atu_vtu_stats_strings[i],
960 ETH_GSTRING_LEN);
961}
962
Andrew Lunndfafe442016-11-21 23:27:02 +0100963static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700964 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100965{
Vivien Didelot04bed142016-08-31 18:06:13 -0400966 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100967 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100968
Florian Fainelli89f09042018-04-25 12:12:50 -0700969 if (stringset != ETH_SS_STATS)
970 return;
971
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100972 mutex_lock(&chip->reg_lock);
973
Andrew Lunndfafe442016-11-21 23:27:02 +0100974 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100975 count = chip->info->ops->stats_get_strings(chip, data);
976
977 if (chip->info->ops->serdes_get_strings) {
978 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200979 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100980 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100981
Andrew Lunn65f60e42018-03-28 23:50:28 +0200982 data += count * ETH_GSTRING_LEN;
983 mv88e6xxx_atu_vtu_get_strings(data);
984
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100985 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100986}
987
988static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
989 int types)
990{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100991 struct mv88e6xxx_hw_stat *stat;
992 int i, j;
993
994 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
995 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100996 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100997 j++;
998 }
999 return j;
1000}
1001
Andrew Lunndfafe442016-11-21 23:27:02 +01001002static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1003{
1004 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1005 STATS_TYPE_PORT);
1006}
1007
1008static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1009{
1010 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1011 STATS_TYPE_BANK1);
1012}
1013
Florian Fainelli89f09042018-04-25 12:12:50 -07001014static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001015{
1016 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001017 int serdes_count = 0;
1018 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001019
Florian Fainelli89f09042018-04-25 12:12:50 -07001020 if (sset != ETH_SS_STATS)
1021 return 0;
1022
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001023 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001024 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001025 count = chip->info->ops->stats_get_sset_count(chip);
1026 if (count < 0)
1027 goto out;
1028
1029 if (chip->info->ops->serdes_get_sset_count)
1030 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1031 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001032 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001033 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001034 goto out;
1035 }
1036 count += serdes_count;
1037 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1038
Andrew Lunn436fe172018-03-01 02:02:29 +01001039out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001040 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001041
Andrew Lunn436fe172018-03-01 02:02:29 +01001042 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001043}
1044
Andrew Lunn436fe172018-03-01 02:02:29 +01001045static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1046 uint64_t *data, int types,
1047 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001048{
1049 struct mv88e6xxx_hw_stat *stat;
1050 int i, j;
1051
1052 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1053 stat = &mv88e6xxx_hw_stats[i];
1054 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001055 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001056 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1057 bank1_select,
1058 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001059 mutex_unlock(&chip->reg_lock);
1060
Andrew Lunn052f9472016-11-21 23:27:03 +01001061 j++;
1062 }
1063 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001064 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001065}
1066
Andrew Lunn436fe172018-03-01 02:02:29 +01001067static int mv88e6095_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_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001072 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001073}
1074
Andrew Lunn436fe172018-03-01 02:02:29 +01001075static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1076 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001077{
1078 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001079 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001080 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1081 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001082}
1083
Andrew Lunn436fe172018-03-01 02:02:29 +01001084static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1085 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001086{
1087 return mv88e6xxx_stats_get_stats(chip, port, data,
1088 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001089 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1090 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001091}
1092
Andrew Lunn65f60e42018-03-28 23:50:28 +02001093static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1094 uint64_t *data)
1095{
1096 *data++ = chip->ports[port].atu_member_violation;
1097 *data++ = chip->ports[port].atu_miss_violation;
1098 *data++ = chip->ports[port].atu_full_violation;
1099 *data++ = chip->ports[port].vtu_member_violation;
1100 *data++ = chip->ports[port].vtu_miss_violation;
1101}
1102
Andrew Lunn052f9472016-11-21 23:27:03 +01001103static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1104 uint64_t *data)
1105{
Andrew Lunn436fe172018-03-01 02:02:29 +01001106 int count = 0;
1107
Andrew Lunn052f9472016-11-21 23:27:03 +01001108 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001109 count = chip->info->ops->stats_get_stats(chip, port, data);
1110
Andrew Lunn65f60e42018-03-28 23:50:28 +02001111 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001112 if (chip->info->ops->serdes_get_stats) {
1113 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001114 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001115 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001116 data += count;
1117 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1118 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001119}
1120
Vivien Didelotf81ec902016-05-09 13:22:58 -04001121static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1122 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001123{
Vivien Didelot04bed142016-08-31 18:06:13 -04001124 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001125 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001126
Vivien Didelotfad09c72016-06-21 12:28:20 -04001127 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001128
Andrew Lunna605a0f2016-11-21 23:26:58 +01001129 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001130 mutex_unlock(&chip->reg_lock);
1131
1132 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001133 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001134
1135 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001136
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001137}
Ben Hutchings98e67302011-11-25 14:36:19 +00001138
Vivien Didelotf81ec902016-05-09 13:22:58 -04001139static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001140{
1141 return 32 * sizeof(u16);
1142}
1143
Vivien Didelotf81ec902016-05-09 13:22:58 -04001144static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1145 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001146{
Vivien Didelot04bed142016-08-31 18:06:13 -04001147 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001148 int err;
1149 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001150 u16 *p = _p;
1151 int i;
1152
Vivien Didelota5f39322018-12-17 16:05:21 -05001153 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001154
1155 memset(p, 0xff, 32 * sizeof(u16));
1156
Vivien Didelotfad09c72016-06-21 12:28:20 -04001157 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001158
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001159 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001160
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001161 err = mv88e6xxx_port_read(chip, port, i, &reg);
1162 if (!err)
1163 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001164 }
Vivien Didelot23062512016-05-09 13:22:45 -04001165
Vivien Didelotfad09c72016-06-21 12:28:20 -04001166 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001167}
1168
Vivien Didelot08f50062017-08-01 16:32:41 -04001169static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1170 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001171{
Vivien Didelot5480db62017-08-01 16:32:40 -04001172 /* Nothing to do on the port's MAC */
1173 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001174}
1175
Vivien Didelot08f50062017-08-01 16:32:41 -04001176static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1177 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001178{
Vivien Didelot5480db62017-08-01 16:32:40 -04001179 /* Nothing to do on the port's MAC */
1180 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001181}
1182
Vivien Didelote5887a22017-03-30 17:37:11 -04001183static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001184{
Vivien Didelote5887a22017-03-30 17:37:11 -04001185 struct dsa_switch *ds = NULL;
1186 struct net_device *br;
1187 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001188 int i;
1189
Vivien Didelote5887a22017-03-30 17:37:11 -04001190 if (dev < DSA_MAX_SWITCHES)
1191 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001192
Vivien Didelote5887a22017-03-30 17:37:11 -04001193 /* Prevent frames from unknown switch or port */
1194 if (!ds || port >= ds->num_ports)
1195 return 0;
1196
1197 /* Frames from DSA links and CPU ports can egress any local port */
1198 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1199 return mv88e6xxx_port_mask(chip);
1200
1201 br = ds->ports[port].bridge_dev;
1202 pvlan = 0;
1203
1204 /* Frames from user ports can egress any local DSA links and CPU ports,
1205 * as well as any local member of their bridge group.
1206 */
1207 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1208 if (dsa_is_cpu_port(chip->ds, i) ||
1209 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001210 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001211 pvlan |= BIT(i);
1212
1213 return pvlan;
1214}
1215
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001216static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001217{
1218 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001219
1220 /* prevent frames from going back out of the port they came in on */
1221 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001222
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001223 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001224}
1225
Vivien Didelotf81ec902016-05-09 13:22:58 -04001226static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1227 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001228{
Vivien Didelot04bed142016-08-31 18:06:13 -04001229 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001230 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001231
Vivien Didelotfad09c72016-06-21 12:28:20 -04001232 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001233 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001234 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001235
1236 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001237 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001238}
1239
Vivien Didelot93e18d62018-05-11 17:16:35 -04001240static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1241{
1242 int err;
1243
1244 if (chip->info->ops->ieee_pri_map) {
1245 err = chip->info->ops->ieee_pri_map(chip);
1246 if (err)
1247 return err;
1248 }
1249
1250 if (chip->info->ops->ip_pri_map) {
1251 err = chip->info->ops->ip_pri_map(chip);
1252 if (err)
1253 return err;
1254 }
1255
1256 return 0;
1257}
1258
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001259static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1260{
1261 int target, port;
1262 int err;
1263
1264 if (!chip->info->global2_addr)
1265 return 0;
1266
1267 /* Initialize the routing port to the 32 possible target devices */
1268 for (target = 0; target < 32; target++) {
1269 port = 0x1f;
1270 if (target < DSA_MAX_SWITCHES)
1271 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1272 port = chip->ds->rtable[target];
1273
1274 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1275 if (err)
1276 return err;
1277 }
1278
Vivien Didelot02317e62018-05-09 11:38:49 -04001279 if (chip->info->ops->set_cascade_port) {
1280 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1281 err = chip->info->ops->set_cascade_port(chip, port);
1282 if (err)
1283 return err;
1284 }
1285
Vivien Didelot23c98912018-05-09 11:38:50 -04001286 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1287 if (err)
1288 return err;
1289
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001290 return 0;
1291}
1292
Vivien Didelotb28f8722018-04-26 21:56:44 -04001293static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1294{
1295 /* Clear all trunk masks and mapping */
1296 if (chip->info->global2_addr)
1297 return mv88e6xxx_g2_trunk_clear(chip);
1298
1299 return 0;
1300}
1301
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001302static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1303{
1304 if (chip->info->ops->rmu_disable)
1305 return chip->info->ops->rmu_disable(chip);
1306
1307 return 0;
1308}
1309
Vivien Didelot9e907d72017-07-17 13:03:43 -04001310static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1311{
1312 if (chip->info->ops->pot_clear)
1313 return chip->info->ops->pot_clear(chip);
1314
1315 return 0;
1316}
1317
Vivien Didelot51c901a2017-07-17 13:03:41 -04001318static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1319{
1320 if (chip->info->ops->mgmt_rsvd2cpu)
1321 return chip->info->ops->mgmt_rsvd2cpu(chip);
1322
1323 return 0;
1324}
1325
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001326static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1327{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001328 int err;
1329
Vivien Didelotdaefc942017-03-11 16:12:54 -05001330 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1331 if (err)
1332 return err;
1333
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001334 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1335 if (err)
1336 return err;
1337
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001338 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1339}
1340
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001341static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1342{
1343 int port;
1344 int err;
1345
1346 if (!chip->info->ops->irl_init_all)
1347 return 0;
1348
1349 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1350 /* Disable ingress rate limiting by resetting all per port
1351 * ingress rate limit resources to their initial state.
1352 */
1353 err = chip->info->ops->irl_init_all(chip, port);
1354 if (err)
1355 return err;
1356 }
1357
1358 return 0;
1359}
1360
Vivien Didelot04a69a12017-10-13 14:18:05 -04001361static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1362{
1363 if (chip->info->ops->set_switch_mac) {
1364 u8 addr[ETH_ALEN];
1365
1366 eth_random_addr(addr);
1367
1368 return chip->info->ops->set_switch_mac(chip, addr);
1369 }
1370
1371 return 0;
1372}
1373
Vivien Didelot17a15942017-03-30 17:37:09 -04001374static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1375{
1376 u16 pvlan = 0;
1377
1378 if (!mv88e6xxx_has_pvt(chip))
1379 return -EOPNOTSUPP;
1380
1381 /* Skip the local source device, which uses in-chip port VLAN */
1382 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001383 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001384
1385 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1386}
1387
Vivien Didelot81228992017-03-30 17:37:08 -04001388static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1389{
Vivien Didelot17a15942017-03-30 17:37:09 -04001390 int dev, port;
1391 int err;
1392
Vivien Didelot81228992017-03-30 17:37:08 -04001393 if (!mv88e6xxx_has_pvt(chip))
1394 return 0;
1395
1396 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1397 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1398 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001399 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1400 if (err)
1401 return err;
1402
1403 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1404 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1405 err = mv88e6xxx_pvt_map(chip, dev, port);
1406 if (err)
1407 return err;
1408 }
1409 }
1410
1411 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001412}
1413
Vivien Didelot749efcb2016-09-22 16:49:24 -04001414static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1415{
1416 struct mv88e6xxx_chip *chip = ds->priv;
1417 int err;
1418
1419 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001420 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001421 mutex_unlock(&chip->reg_lock);
1422
1423 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001424 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001425}
1426
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001427static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1428{
1429 if (!chip->info->max_vid)
1430 return 0;
1431
1432 return mv88e6xxx_g1_vtu_flush(chip);
1433}
1434
Vivien Didelotf1394b782017-05-01 14:05:22 -04001435static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1436 struct mv88e6xxx_vtu_entry *entry)
1437{
1438 if (!chip->info->ops->vtu_getnext)
1439 return -EOPNOTSUPP;
1440
1441 return chip->info->ops->vtu_getnext(chip, entry);
1442}
1443
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001444static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1445 struct mv88e6xxx_vtu_entry *entry)
1446{
1447 if (!chip->info->ops->vtu_loadpurge)
1448 return -EOPNOTSUPP;
1449
1450 return chip->info->ops->vtu_loadpurge(chip, entry);
1451}
1452
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001453static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001454{
1455 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001456 struct mv88e6xxx_vtu_entry vlan = {
1457 .vid = chip->info->max_vid,
1458 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001459 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001460
1461 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1462
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001463 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001464 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001465 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001466 if (err)
1467 return err;
1468
1469 set_bit(*fid, fid_bitmap);
1470 }
1471
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001472 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001473 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001474 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001475 if (err)
1476 return err;
1477
1478 if (!vlan.valid)
1479 break;
1480
1481 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001482 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001483
1484 /* The reset value 0x000 is used to indicate that multiple address
1485 * databases are not needed. Return the next positive available.
1486 */
1487 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001488 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001489 return -ENOSPC;
1490
1491 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001492 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001493}
1494
Vivien Didelot567aa592017-05-01 14:05:25 -04001495static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1496 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001497{
1498 int err;
1499
1500 if (!vid)
1501 return -EINVAL;
1502
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001503 entry->vid = vid - 1;
1504 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001505
Vivien Didelotf1394b782017-05-01 14:05:22 -04001506 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001507 if (err)
1508 return err;
1509
Vivien Didelot567aa592017-05-01 14:05:25 -04001510 if (entry->vid == vid && entry->valid)
1511 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001512
Vivien Didelot567aa592017-05-01 14:05:25 -04001513 if (new) {
1514 int i;
1515
1516 /* Initialize a fresh VLAN entry */
1517 memset(entry, 0, sizeof(*entry));
1518 entry->valid = true;
1519 entry->vid = vid;
1520
Vivien Didelot553a7682017-06-07 18:12:16 -04001521 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001522 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001523 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001524 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001525
1526 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001527 }
1528
Vivien Didelot567aa592017-05-01 14:05:25 -04001529 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1530 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001531}
1532
Vivien Didelotda9c3592016-02-12 12:09:40 -05001533static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1534 u16 vid_begin, u16 vid_end)
1535{
Vivien Didelot04bed142016-08-31 18:06:13 -04001536 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001537 struct mv88e6xxx_vtu_entry vlan = {
1538 .vid = vid_begin - 1,
1539 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001540 int i, err;
1541
Andrew Lunndb06ae412017-09-25 23:32:20 +02001542 /* DSA and CPU ports have to be members of multiple vlans */
1543 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1544 return 0;
1545
Vivien Didelotda9c3592016-02-12 12:09:40 -05001546 if (!vid_begin)
1547 return -EOPNOTSUPP;
1548
Vivien Didelotfad09c72016-06-21 12:28:20 -04001549 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001550
Vivien Didelotda9c3592016-02-12 12:09:40 -05001551 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001552 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001553 if (err)
1554 goto unlock;
1555
1556 if (!vlan.valid)
1557 break;
1558
1559 if (vlan.vid > vid_end)
1560 break;
1561
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001562 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001563 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1564 continue;
1565
Andrew Lunncd886462017-11-09 22:29:53 +01001566 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001567 continue;
1568
Vivien Didelotbd00e052017-05-01 14:05:11 -04001569 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001570 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001571 continue;
1572
Vivien Didelotc8652c82017-10-16 11:12:19 -04001573 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001574 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001575 break; /* same bridge, check next VLAN */
1576
Vivien Didelotc8652c82017-10-16 11:12:19 -04001577 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001578 continue;
1579
Andrew Lunn743fcc22017-11-09 22:29:54 +01001580 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1581 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001582 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001583 err = -EOPNOTSUPP;
1584 goto unlock;
1585 }
1586 } while (vlan.vid < vid_end);
1587
1588unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001589 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001590
1591 return err;
1592}
1593
Vivien Didelotf81ec902016-05-09 13:22:58 -04001594static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1595 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001596{
Vivien Didelot04bed142016-08-31 18:06:13 -04001597 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001598 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1599 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001600 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001601
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001602 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001603 return -EOPNOTSUPP;
1604
Vivien Didelotfad09c72016-06-21 12:28:20 -04001605 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001606 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001607 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001608
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001609 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001610}
1611
Vivien Didelot57d32312016-06-20 13:13:58 -04001612static int
1613mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001614 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001615{
Vivien Didelot04bed142016-08-31 18:06:13 -04001616 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001617 int err;
1618
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001619 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001620 return -EOPNOTSUPP;
1621
Vivien Didelotda9c3592016-02-12 12:09:40 -05001622 /* If the requested port doesn't belong to the same bridge as the VLAN
1623 * members, do not support it (yet) and fallback to software VLAN.
1624 */
1625 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1626 vlan->vid_end);
1627 if (err)
1628 return err;
1629
Vivien Didelot76e398a2015-11-01 12:33:55 -05001630 /* We don't need any dynamic resource from the kernel (yet),
1631 * so skip the prepare phase.
1632 */
1633 return 0;
1634}
1635
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001636static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1637 const unsigned char *addr, u16 vid,
1638 u8 state)
1639{
1640 struct mv88e6xxx_vtu_entry vlan;
1641 struct mv88e6xxx_atu_entry entry;
1642 int err;
1643
1644 /* Null VLAN ID corresponds to the port private database */
1645 if (vid == 0)
1646 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1647 else
1648 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1649 if (err)
1650 return err;
1651
1652 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1653 ether_addr_copy(entry.mac, addr);
1654 eth_addr_dec(entry.mac);
1655
1656 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1657 if (err)
1658 return err;
1659
1660 /* Initialize a fresh ATU entry if it isn't found */
1661 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1662 !ether_addr_equal(entry.mac, addr)) {
1663 memset(&entry, 0, sizeof(entry));
1664 ether_addr_copy(entry.mac, addr);
1665 }
1666
1667 /* Purge the ATU entry only if no port is using it anymore */
1668 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1669 entry.portvec &= ~BIT(port);
1670 if (!entry.portvec)
1671 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1672 } else {
1673 entry.portvec |= BIT(port);
1674 entry.state = state;
1675 }
1676
1677 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1678}
1679
Andrew Lunn87fa8862017-11-09 22:29:56 +01001680static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1681 u16 vid)
1682{
1683 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1684 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1685
1686 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1687}
1688
1689static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1690{
1691 int port;
1692 int err;
1693
1694 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1695 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1696 if (err)
1697 return err;
1698 }
1699
1700 return 0;
1701}
1702
Vivien Didelotfad09c72016-06-21 12:28:20 -04001703static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001704 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001705{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001706 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001707 int err;
1708
Vivien Didelot567aa592017-05-01 14:05:25 -04001709 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001710 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001711 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001712
Vivien Didelotc91498e2017-06-07 18:12:13 -04001713 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001714
Andrew Lunn87fa8862017-11-09 22:29:56 +01001715 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1716 if (err)
1717 return err;
1718
1719 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001720}
1721
Vivien Didelotf81ec902016-05-09 13:22:58 -04001722static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001723 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001724{
Vivien Didelot04bed142016-08-31 18:06:13 -04001725 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001726 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1727 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001728 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001729 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001730
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001731 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001732 return;
1733
Vivien Didelotc91498e2017-06-07 18:12:13 -04001734 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001735 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001736 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001737 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001738 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001739 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001740
Vivien Didelotfad09c72016-06-21 12:28:20 -04001741 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001742
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001743 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001744 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001745 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1746 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001747
Vivien Didelot77064f32016-11-04 03:23:30 +01001748 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001749 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1750 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001751
Vivien Didelotfad09c72016-06-21 12:28:20 -04001752 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001753}
1754
Vivien Didelotfad09c72016-06-21 12:28:20 -04001755static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001756 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001757{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001758 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001759 int i, err;
1760
Vivien Didelot567aa592017-05-01 14:05:25 -04001761 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001762 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001763 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001764
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001765 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001766 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001767 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001768
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001769 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001770
1771 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001772 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001773 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001774 if (vlan.member[i] !=
1775 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001776 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001777 break;
1778 }
1779 }
1780
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001781 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001782 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001783 return err;
1784
Vivien Didelote606ca32017-03-11 16:12:55 -05001785 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001786}
1787
Vivien Didelotf81ec902016-05-09 13:22:58 -04001788static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1789 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001790{
Vivien Didelot04bed142016-08-31 18:06:13 -04001791 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001792 u16 pvid, vid;
1793 int err = 0;
1794
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001795 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001796 return -EOPNOTSUPP;
1797
Vivien Didelotfad09c72016-06-21 12:28:20 -04001798 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001799
Vivien Didelot77064f32016-11-04 03:23:30 +01001800 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001801 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001802 goto unlock;
1803
Vivien Didelot76e398a2015-11-01 12:33:55 -05001804 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001805 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001806 if (err)
1807 goto unlock;
1808
1809 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001810 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001811 if (err)
1812 goto unlock;
1813 }
1814 }
1815
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001816unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001817 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001818
1819 return err;
1820}
1821
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001822static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1823 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001824{
Vivien Didelot04bed142016-08-31 18:06:13 -04001825 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001826 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001827
Vivien Didelotfad09c72016-06-21 12:28:20 -04001828 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001829 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1830 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001831 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001832
1833 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001834}
1835
Vivien Didelotf81ec902016-05-09 13:22:58 -04001836static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001837 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001838{
Vivien Didelot04bed142016-08-31 18:06:13 -04001839 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001840 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001841
Vivien Didelotfad09c72016-06-21 12:28:20 -04001842 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001843 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001844 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001845 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001846
Vivien Didelot83dabd12016-08-31 11:50:04 -04001847 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001848}
1849
Vivien Didelot83dabd12016-08-31 11:50:04 -04001850static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1851 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001852 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001853{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001854 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001855 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001856 int err;
1857
Vivien Didelot27c0e602017-06-15 12:14:01 -04001858 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001859 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001860
1861 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001862 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001863 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001864 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001865 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001866 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001867
Vivien Didelot27c0e602017-06-15 12:14:01 -04001868 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001869 break;
1870
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001871 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001872 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001873
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001874 if (!is_unicast_ether_addr(addr.mac))
1875 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001876
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001877 is_static = (addr.state ==
1878 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1879 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001880 if (err)
1881 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001882 } while (!is_broadcast_ether_addr(addr.mac));
1883
1884 return err;
1885}
1886
Vivien Didelot83dabd12016-08-31 11:50:04 -04001887static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001888 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001889{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001890 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001891 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001892 };
1893 u16 fid;
1894 int err;
1895
1896 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001897 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001898 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001899 mutex_unlock(&chip->reg_lock);
1900
Vivien Didelot83dabd12016-08-31 11:50:04 -04001901 if (err)
1902 return err;
1903
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001904 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001905 if (err)
1906 return err;
1907
1908 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001909 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001910 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001911 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001912 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001913 if (err)
1914 return err;
1915
1916 if (!vlan.valid)
1917 break;
1918
1919 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001920 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001921 if (err)
1922 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001923 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001924
1925 return err;
1926}
1927
Vivien Didelotf81ec902016-05-09 13:22:58 -04001928static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001929 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001930{
Vivien Didelot04bed142016-08-31 18:06:13 -04001931 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001932
Andrew Lunna61e5402018-02-15 14:38:35 +01001933 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001934}
1935
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001936static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1937 struct net_device *br)
1938{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001939 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001940 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001941 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001942 int err;
1943
1944 /* Remap the Port VLAN of each local bridge group member */
1945 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1946 if (chip->ds->ports[port].bridge_dev == br) {
1947 err = mv88e6xxx_port_vlan_map(chip, port);
1948 if (err)
1949 return err;
1950 }
1951 }
1952
Vivien Didelote96a6e02017-03-30 17:37:13 -04001953 if (!mv88e6xxx_has_pvt(chip))
1954 return 0;
1955
1956 /* Remap the Port VLAN of each cross-chip bridge group member */
1957 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1958 ds = chip->ds->dst->ds[dev];
1959 if (!ds)
1960 break;
1961
1962 for (port = 0; port < ds->num_ports; ++port) {
1963 if (ds->ports[port].bridge_dev == br) {
1964 err = mv88e6xxx_pvt_map(chip, dev, port);
1965 if (err)
1966 return err;
1967 }
1968 }
1969 }
1970
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001971 return 0;
1972}
1973
Vivien Didelotf81ec902016-05-09 13:22:58 -04001974static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001975 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001976{
Vivien Didelot04bed142016-08-31 18:06:13 -04001977 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001978 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001979
Vivien Didelotfad09c72016-06-21 12:28:20 -04001980 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001981 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001982 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001983
Vivien Didelot466dfa02016-02-26 13:16:05 -05001984 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001985}
1986
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001987static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1988 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001989{
Vivien Didelot04bed142016-08-31 18:06:13 -04001990 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001991
Vivien Didelotfad09c72016-06-21 12:28:20 -04001992 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001993 if (mv88e6xxx_bridge_map(chip, br) ||
1994 mv88e6xxx_port_vlan_map(chip, port))
1995 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001996 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001997}
1998
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001999static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2000 int port, struct net_device *br)
2001{
2002 struct mv88e6xxx_chip *chip = ds->priv;
2003 int err;
2004
2005 if (!mv88e6xxx_has_pvt(chip))
2006 return 0;
2007
2008 mutex_lock(&chip->reg_lock);
2009 err = mv88e6xxx_pvt_map(chip, dev, port);
2010 mutex_unlock(&chip->reg_lock);
2011
2012 return err;
2013}
2014
2015static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2016 int port, struct net_device *br)
2017{
2018 struct mv88e6xxx_chip *chip = ds->priv;
2019
2020 if (!mv88e6xxx_has_pvt(chip))
2021 return;
2022
2023 mutex_lock(&chip->reg_lock);
2024 if (mv88e6xxx_pvt_map(chip, dev, port))
2025 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2026 mutex_unlock(&chip->reg_lock);
2027}
2028
Vivien Didelot17e708b2016-12-05 17:30:27 -05002029static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2030{
2031 if (chip->info->ops->reset)
2032 return chip->info->ops->reset(chip);
2033
2034 return 0;
2035}
2036
Vivien Didelot309eca62016-12-05 17:30:26 -05002037static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2038{
2039 struct gpio_desc *gpiod = chip->reset;
2040
2041 /* If there is a GPIO connected to the reset pin, toggle it */
2042 if (gpiod) {
2043 gpiod_set_value_cansleep(gpiod, 1);
2044 usleep_range(10000, 20000);
2045 gpiod_set_value_cansleep(gpiod, 0);
2046 usleep_range(10000, 20000);
2047 }
2048}
2049
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002050static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2051{
2052 int i, err;
2053
2054 /* Set all ports to the Disabled state */
2055 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002056 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002057 if (err)
2058 return err;
2059 }
2060
2061 /* Wait for transmit queues to drain,
2062 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2063 */
2064 usleep_range(2000, 4000);
2065
2066 return 0;
2067}
2068
Vivien Didelotfad09c72016-06-21 12:28:20 -04002069static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002070{
Vivien Didelota935c052016-09-29 12:21:53 -04002071 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002072
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002073 err = mv88e6xxx_disable_ports(chip);
2074 if (err)
2075 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002076
Vivien Didelot309eca62016-12-05 17:30:26 -05002077 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002078
Vivien Didelot17e708b2016-12-05 17:30:27 -05002079 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002080}
2081
Vivien Didelot43145572017-03-11 16:12:59 -05002082static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002083 enum mv88e6xxx_frame_mode frame,
2084 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002085{
2086 int err;
2087
Vivien Didelot43145572017-03-11 16:12:59 -05002088 if (!chip->info->ops->port_set_frame_mode)
2089 return -EOPNOTSUPP;
2090
2091 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002092 if (err)
2093 return err;
2094
Vivien Didelot43145572017-03-11 16:12:59 -05002095 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2096 if (err)
2097 return err;
2098
2099 if (chip->info->ops->port_set_ether_type)
2100 return chip->info->ops->port_set_ether_type(chip, port, etype);
2101
2102 return 0;
2103}
2104
2105static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2106{
2107 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002108 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002109 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002110}
2111
2112static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2113{
2114 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002115 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002116 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002117}
2118
2119static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2120{
2121 return mv88e6xxx_set_port_mode(chip, port,
2122 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002123 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2124 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002125}
2126
2127static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2128{
2129 if (dsa_is_dsa_port(chip->ds, port))
2130 return mv88e6xxx_set_port_mode_dsa(chip, port);
2131
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002132 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002133 return mv88e6xxx_set_port_mode_normal(chip, port);
2134
2135 /* Setup CPU port mode depending on its supported tag format */
2136 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2137 return mv88e6xxx_set_port_mode_dsa(chip, port);
2138
2139 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2140 return mv88e6xxx_set_port_mode_edsa(chip, port);
2141
2142 return -EINVAL;
2143}
2144
Vivien Didelotea698f42017-03-11 16:12:50 -05002145static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2146{
2147 bool message = dsa_is_dsa_port(chip->ds, port);
2148
2149 return mv88e6xxx_port_set_message_port(chip, port, message);
2150}
2151
Vivien Didelot601aeed2017-03-11 16:13:00 -05002152static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2153{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002154 struct dsa_switch *ds = chip->ds;
2155 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002156
2157 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002158 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002159 if (chip->info->ops->port_set_egress_floods)
2160 return chip->info->ops->port_set_egress_floods(chip, port,
2161 flood, flood);
2162
2163 return 0;
2164}
2165
Andrew Lunn6d917822017-05-26 01:03:21 +02002166static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2167 bool on)
2168{
Vivien Didelot523a8902017-05-26 18:02:42 -04002169 if (chip->info->ops->serdes_power)
2170 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002171
Vivien Didelot523a8902017-05-26 18:02:42 -04002172 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002173}
2174
Vivien Didelotfa371c82017-12-05 15:34:10 -05002175static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2176{
2177 struct dsa_switch *ds = chip->ds;
2178 int upstream_port;
2179 int err;
2180
Vivien Didelot07073c72017-12-05 15:34:13 -05002181 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002182 if (chip->info->ops->port_set_upstream_port) {
2183 err = chip->info->ops->port_set_upstream_port(chip, port,
2184 upstream_port);
2185 if (err)
2186 return err;
2187 }
2188
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002189 if (port == upstream_port) {
2190 if (chip->info->ops->set_cpu_port) {
2191 err = chip->info->ops->set_cpu_port(chip,
2192 upstream_port);
2193 if (err)
2194 return err;
2195 }
2196
2197 if (chip->info->ops->set_egress_port) {
2198 err = chip->info->ops->set_egress_port(chip,
2199 upstream_port);
2200 if (err)
2201 return err;
2202 }
2203 }
2204
Vivien Didelotfa371c82017-12-05 15:34:10 -05002205 return 0;
2206}
2207
Vivien Didelotfad09c72016-06-21 12:28:20 -04002208static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002209{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002210 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002211 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002212 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002213
Andrew Lunn7b898462018-08-09 15:38:47 +02002214 chip->ports[port].chip = chip;
2215 chip->ports[port].port = port;
2216
Vivien Didelotd78343d2016-11-04 03:23:36 +01002217 /* MAC Forcing register: don't force link, speed, duplex or flow control
2218 * state to any particular values on physical ports, but force the CPU
2219 * port and all DSA ports to their maximum bandwidth and full duplex.
2220 */
2221 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2222 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2223 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002224 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002225 PHY_INTERFACE_MODE_NA);
2226 else
2227 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2228 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002229 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002230 PHY_INTERFACE_MODE_NA);
2231 if (err)
2232 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002233
2234 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2235 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2236 * tunneling, determine priority by looking at 802.1p and IP
2237 * priority fields (IP prio has precedence), and set STP state
2238 * to Forwarding.
2239 *
2240 * If this is the CPU link, use DSA or EDSA tagging depending
2241 * on which tagging mode was configured.
2242 *
2243 * If this is a link to another switch, use DSA tagging mode.
2244 *
2245 * If this is the upstream port for this switch, enable
2246 * forwarding of unknown unicasts and multicasts.
2247 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002248 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2249 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2250 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2251 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002252 if (err)
2253 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002254
Vivien Didelot601aeed2017-03-11 16:13:00 -05002255 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002256 if (err)
2257 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002258
Vivien Didelot601aeed2017-03-11 16:13:00 -05002259 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002260 if (err)
2261 return err;
2262
Andrew Lunn04aca992017-05-26 01:03:24 +02002263 /* Enable the SERDES interface for DSA and CPU ports. Normal
2264 * ports SERDES are enabled when the port is enabled, thus
2265 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002266 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002267 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2268 err = mv88e6xxx_serdes_power(chip, port, true);
2269 if (err)
2270 return err;
2271 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002272
Vivien Didelot8efdda42015-08-13 12:52:23 -04002273 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002274 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002275 * untagged frames on this port, do a destination address lookup on all
2276 * received packets as usual, disable ARP mirroring and don't send a
2277 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002278 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002279 err = mv88e6xxx_port_set_map_da(chip, port);
2280 if (err)
2281 return err;
2282
Vivien Didelotfa371c82017-12-05 15:34:10 -05002283 err = mv88e6xxx_setup_upstream_port(chip, port);
2284 if (err)
2285 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002286
Andrew Lunna23b2962017-02-04 20:15:28 +01002287 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002288 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002289 if (err)
2290 return err;
2291
Vivien Didelotcd782652017-06-08 18:34:13 -04002292 if (chip->info->ops->port_set_jumbo_size) {
2293 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002294 if (err)
2295 return err;
2296 }
2297
Andrew Lunn54d792f2015-05-06 01:09:47 +02002298 /* Port Association Vector: when learning source addresses
2299 * of packets, add the address to the address database using
2300 * a port bitmap that has only the bit for this port set and
2301 * the other bits clear.
2302 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002303 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002304 /* Disable learning for CPU port */
2305 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002306 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002307
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002308 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2309 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002310 if (err)
2311 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002312
2313 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002314 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2315 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002316 if (err)
2317 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002318
Vivien Didelot08984322017-06-08 18:34:12 -04002319 if (chip->info->ops->port_pause_limit) {
2320 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002321 if (err)
2322 return err;
2323 }
2324
Vivien Didelotc8c94892017-03-11 16:13:01 -05002325 if (chip->info->ops->port_disable_learn_limit) {
2326 err = chip->info->ops->port_disable_learn_limit(chip, port);
2327 if (err)
2328 return err;
2329 }
2330
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002331 if (chip->info->ops->port_disable_pri_override) {
2332 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002333 if (err)
2334 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002335 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002336
Andrew Lunnef0a7312016-12-03 04:35:16 +01002337 if (chip->info->ops->port_tag_remap) {
2338 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002339 if (err)
2340 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002341 }
2342
Andrew Lunnef70b112016-12-03 04:45:18 +01002343 if (chip->info->ops->port_egress_rate_limiting) {
2344 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002345 if (err)
2346 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002347 }
2348
Vivien Didelotea698f42017-03-11 16:12:50 -05002349 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002350 if (err)
2351 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002352
Vivien Didelot207afda2016-04-14 14:42:09 -04002353 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002354 * database, and allow bidirectional communication between the
2355 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002356 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002357 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002358 if (err)
2359 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002360
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002361 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002362 if (err)
2363 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002364
2365 /* Default VLAN ID and priority: don't set a default VLAN
2366 * ID, and set the default packet priority to zero.
2367 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002368 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002369}
2370
Andrew Lunn04aca992017-05-26 01:03:24 +02002371static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2372 struct phy_device *phydev)
2373{
2374 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002375 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002376
2377 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002378
Vivien Didelot523a8902017-05-26 18:02:42 -04002379 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002380
2381 if (!err && chip->info->ops->serdes_irq_setup)
2382 err = chip->info->ops->serdes_irq_setup(chip, port);
2383
Andrew Lunn04aca992017-05-26 01:03:24 +02002384 mutex_unlock(&chip->reg_lock);
2385
2386 return err;
2387}
2388
2389static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2390 struct phy_device *phydev)
2391{
2392 struct mv88e6xxx_chip *chip = ds->priv;
2393
2394 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002395
2396 if (chip->info->ops->serdes_irq_free)
2397 chip->info->ops->serdes_irq_free(chip, port);
2398
Vivien Didelot523a8902017-05-26 18:02:42 -04002399 if (mv88e6xxx_serdes_power(chip, port, false))
2400 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002401
Andrew Lunn04aca992017-05-26 01:03:24 +02002402 mutex_unlock(&chip->reg_lock);
2403}
2404
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002405static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2406 unsigned int ageing_time)
2407{
Vivien Didelot04bed142016-08-31 18:06:13 -04002408 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002409 int err;
2410
2411 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002412 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002413 mutex_unlock(&chip->reg_lock);
2414
2415 return err;
2416}
2417
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002418static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002419{
2420 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002421
Andrew Lunnde2273872016-11-21 23:27:01 +01002422 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002423 if (chip->info->ops->stats_set_histogram) {
2424 err = chip->info->ops->stats_set_histogram(chip);
2425 if (err)
2426 return err;
2427 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002428
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002429 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002430}
2431
Andrew Lunnea890982019-01-09 00:24:03 +01002432/* The mv88e6390 has some hidden registers used for debug and
2433 * development. The errata also makes use of them.
2434 */
2435static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2436 int reg, u16 val)
2437{
2438 u16 ctrl;
2439 int err;
2440
2441 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2442 PORT_RESERVED_1A, val);
2443 if (err)
2444 return err;
2445
2446 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2447 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2448 reg;
2449
2450 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2451 PORT_RESERVED_1A, ctrl);
2452}
2453
2454static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2455{
2456 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2457 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2458}
2459
2460
2461static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2462 int reg, u16 *val)
2463{
2464 u16 ctrl;
2465 int err;
2466
2467 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2468 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2469 reg;
2470
2471 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2472 PORT_RESERVED_1A, ctrl);
2473 if (err)
2474 return err;
2475
2476 err = mv88e6390_hidden_wait(chip);
2477 if (err)
2478 return err;
2479
2480 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2481 PORT_RESERVED_1A, val);
2482}
2483
2484/* Check if the errata has already been applied. */
2485static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2486{
2487 int port;
2488 int err;
2489 u16 val;
2490
2491 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2492 err = mv88e6390_hidden_read(chip, port, 0, &val);
2493 if (err) {
2494 dev_err(chip->dev,
2495 "Error reading hidden register: %d\n", err);
2496 return false;
2497 }
2498 if (val != 0x01c0)
2499 return false;
2500 }
2501
2502 return true;
2503}
2504
2505/* The 6390 copper ports have an errata which require poking magic
2506 * values into undocumented hidden registers and then performing a
2507 * software reset.
2508 */
2509static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2510{
2511 int port;
2512 int err;
2513
2514 if (mv88e6390_setup_errata_applied(chip))
2515 return 0;
2516
2517 /* Set the ports into blocking mode */
2518 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2519 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2520 if (err)
2521 return err;
2522 }
2523
2524 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2525 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2526 if (err)
2527 return err;
2528 }
2529
2530 return mv88e6xxx_software_reset(chip);
2531}
2532
Vivien Didelotf81ec902016-05-09 13:22:58 -04002533static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002534{
Vivien Didelot04bed142016-08-31 18:06:13 -04002535 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002536 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002537 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002538 int i;
2539
Vivien Didelotfad09c72016-06-21 12:28:20 -04002540 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002541 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002542
Vivien Didelotfad09c72016-06-21 12:28:20 -04002543 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002544
Andrew Lunnea890982019-01-09 00:24:03 +01002545 if (chip->info->ops->setup_errata) {
2546 err = chip->info->ops->setup_errata(chip);
2547 if (err)
2548 goto unlock;
2549 }
2550
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002551 /* Cache the cmode of each port. */
2552 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2553 if (chip->info->ops->port_get_cmode) {
2554 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2555 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002556 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002557
2558 chip->ports[i].cmode = cmode;
2559 }
2560 }
2561
Vivien Didelot97299342016-07-18 20:45:30 -04002562 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002563 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002564 if (dsa_is_unused_port(ds, i))
2565 continue;
2566
Vivien Didelot97299342016-07-18 20:45:30 -04002567 err = mv88e6xxx_setup_port(chip, i);
2568 if (err)
2569 goto unlock;
2570 }
2571
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002572 err = mv88e6xxx_irl_setup(chip);
2573 if (err)
2574 goto unlock;
2575
Vivien Didelot04a69a12017-10-13 14:18:05 -04002576 err = mv88e6xxx_mac_setup(chip);
2577 if (err)
2578 goto unlock;
2579
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002580 err = mv88e6xxx_phy_setup(chip);
2581 if (err)
2582 goto unlock;
2583
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002584 err = mv88e6xxx_vtu_setup(chip);
2585 if (err)
2586 goto unlock;
2587
Vivien Didelot81228992017-03-30 17:37:08 -04002588 err = mv88e6xxx_pvt_setup(chip);
2589 if (err)
2590 goto unlock;
2591
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002592 err = mv88e6xxx_atu_setup(chip);
2593 if (err)
2594 goto unlock;
2595
Andrew Lunn87fa8862017-11-09 22:29:56 +01002596 err = mv88e6xxx_broadcast_setup(chip, 0);
2597 if (err)
2598 goto unlock;
2599
Vivien Didelot9e907d72017-07-17 13:03:43 -04002600 err = mv88e6xxx_pot_setup(chip);
2601 if (err)
2602 goto unlock;
2603
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002604 err = mv88e6xxx_rmu_setup(chip);
2605 if (err)
2606 goto unlock;
2607
Vivien Didelot51c901a2017-07-17 13:03:41 -04002608 err = mv88e6xxx_rsvd2cpu_setup(chip);
2609 if (err)
2610 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002611
Vivien Didelotb28f8722018-04-26 21:56:44 -04002612 err = mv88e6xxx_trunk_setup(chip);
2613 if (err)
2614 goto unlock;
2615
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002616 err = mv88e6xxx_devmap_setup(chip);
2617 if (err)
2618 goto unlock;
2619
Vivien Didelot93e18d62018-05-11 17:16:35 -04002620 err = mv88e6xxx_pri_setup(chip);
2621 if (err)
2622 goto unlock;
2623
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002624 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002625 if (chip->info->ptp_support) {
2626 err = mv88e6xxx_ptp_setup(chip);
2627 if (err)
2628 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002629
2630 err = mv88e6xxx_hwtstamp_setup(chip);
2631 if (err)
2632 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002633 }
2634
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002635 err = mv88e6xxx_stats_setup(chip);
2636 if (err)
2637 goto unlock;
2638
Vivien Didelot6b17e862015-08-13 12:52:18 -04002639unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002640 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002641
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002642 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002643}
2644
Vivien Didelote57e5e72016-08-15 17:19:00 -04002645static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002646{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002647 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2648 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002649 u16 val;
2650 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002651
Andrew Lunnee26a222017-01-24 14:53:48 +01002652 if (!chip->info->ops->phy_read)
2653 return -EOPNOTSUPP;
2654
Vivien Didelotfad09c72016-06-21 12:28:20 -04002655 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002656 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002657 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002658
Andrew Lunnda9f3302017-02-01 03:40:05 +01002659 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002660 /* Some internal PHYs don't have a model number. */
2661 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2662 /* Then there is the 6165 family. It gets is
2663 * PHYs correct. But it can also have two
2664 * SERDES interfaces in the PHY address
2665 * space. And these don't have a model
2666 * number. But they are not PHYs, so we don't
2667 * want to give them something a PHY driver
2668 * will recognise.
2669 *
2670 * Use the mv88e6390 family model number
2671 * instead, for anything which really could be
2672 * a PHY,
2673 */
2674 if (!(val & 0x3f0))
2675 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002676 }
2677
Vivien Didelote57e5e72016-08-15 17:19:00 -04002678 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002679}
2680
Vivien Didelote57e5e72016-08-15 17:19:00 -04002681static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002682{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002683 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2684 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002685 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002686
Andrew Lunnee26a222017-01-24 14:53:48 +01002687 if (!chip->info->ops->phy_write)
2688 return -EOPNOTSUPP;
2689
Vivien Didelotfad09c72016-06-21 12:28:20 -04002690 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002691 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002692 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002693
2694 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002695}
2696
Vivien Didelotfad09c72016-06-21 12:28:20 -04002697static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002698 struct device_node *np,
2699 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002700{
2701 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002702 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002703 struct mii_bus *bus;
2704 int err;
2705
Andrew Lunn2510bab2018-02-22 01:51:49 +01002706 if (external) {
2707 mutex_lock(&chip->reg_lock);
2708 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2709 mutex_unlock(&chip->reg_lock);
2710
2711 if (err)
2712 return err;
2713 }
2714
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002715 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002716 if (!bus)
2717 return -ENOMEM;
2718
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002719 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002720 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002721 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002722 INIT_LIST_HEAD(&mdio_bus->list);
2723 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002724
Andrew Lunnb516d452016-06-04 21:17:06 +02002725 if (np) {
2726 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002727 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002728 } else {
2729 bus->name = "mv88e6xxx SMI";
2730 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2731 }
2732
2733 bus->read = mv88e6xxx_mdio_read;
2734 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002735 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002736
Andrew Lunn6f882842018-03-17 20:32:05 +01002737 if (!external) {
2738 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2739 if (err)
2740 return err;
2741 }
2742
Florian Fainelli00e798c2018-05-15 16:56:19 -07002743 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002744 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002745 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002746 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002747 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002748 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002749
2750 if (external)
2751 list_add_tail(&mdio_bus->list, &chip->mdios);
2752 else
2753 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002754
2755 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002756}
2757
Andrew Lunna3c53be52017-01-24 14:53:50 +01002758static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2759 { .compatible = "marvell,mv88e6xxx-mdio-external",
2760 .data = (void *)true },
2761 { },
2762};
2763
Andrew Lunn3126aee2017-12-07 01:05:57 +01002764static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2765
2766{
2767 struct mv88e6xxx_mdio_bus *mdio_bus;
2768 struct mii_bus *bus;
2769
2770 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2771 bus = mdio_bus->bus;
2772
Andrew Lunn6f882842018-03-17 20:32:05 +01002773 if (!mdio_bus->external)
2774 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2775
Andrew Lunn3126aee2017-12-07 01:05:57 +01002776 mdiobus_unregister(bus);
2777 }
2778}
2779
Andrew Lunna3c53be52017-01-24 14:53:50 +01002780static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2781 struct device_node *np)
2782{
2783 const struct of_device_id *match;
2784 struct device_node *child;
2785 int err;
2786
2787 /* Always register one mdio bus for the internal/default mdio
2788 * bus. This maybe represented in the device tree, but is
2789 * optional.
2790 */
2791 child = of_get_child_by_name(np, "mdio");
2792 err = mv88e6xxx_mdio_register(chip, child, false);
2793 if (err)
2794 return err;
2795
2796 /* Walk the device tree, and see if there are any other nodes
2797 * which say they are compatible with the external mdio
2798 * bus.
2799 */
2800 for_each_available_child_of_node(np, child) {
2801 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2802 if (match) {
2803 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002804 if (err) {
2805 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002806 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002807 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002808 }
2809 }
2810
2811 return 0;
2812}
2813
Vivien Didelot855b1932016-07-20 18:18:35 -04002814static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2815{
Vivien Didelot04bed142016-08-31 18:06:13 -04002816 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002817
2818 return chip->eeprom_len;
2819}
2820
Vivien Didelot855b1932016-07-20 18:18:35 -04002821static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2822 struct ethtool_eeprom *eeprom, u8 *data)
2823{
Vivien Didelot04bed142016-08-31 18:06:13 -04002824 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002825 int err;
2826
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002827 if (!chip->info->ops->get_eeprom)
2828 return -EOPNOTSUPP;
2829
Vivien Didelot855b1932016-07-20 18:18:35 -04002830 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002831 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002832 mutex_unlock(&chip->reg_lock);
2833
2834 if (err)
2835 return err;
2836
2837 eeprom->magic = 0xc3ec4951;
2838
2839 return 0;
2840}
2841
Vivien Didelot855b1932016-07-20 18:18:35 -04002842static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2843 struct ethtool_eeprom *eeprom, u8 *data)
2844{
Vivien Didelot04bed142016-08-31 18:06:13 -04002845 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002846 int err;
2847
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002848 if (!chip->info->ops->set_eeprom)
2849 return -EOPNOTSUPP;
2850
Vivien Didelot855b1932016-07-20 18:18:35 -04002851 if (eeprom->magic != 0xc3ec4951)
2852 return -EINVAL;
2853
2854 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002855 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002856 mutex_unlock(&chip->reg_lock);
2857
2858 return err;
2859}
2860
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002861static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002862 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002863 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2864 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002865 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002866 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002867 .phy_read = mv88e6185_phy_ppu_read,
2868 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002869 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002870 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002871 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002872 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002873 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002874 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002875 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002876 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002877 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002878 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002879 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002880 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002881 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002882 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002883 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002884 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2885 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002886 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002887 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2888 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002889 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002890 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002891 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002892 .ppu_enable = mv88e6185_g1_ppu_enable,
2893 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002894 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002895 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002896 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002897 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002898 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002899};
2900
2901static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002902 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002903 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2904 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002905 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002906 .phy_read = mv88e6185_phy_ppu_read,
2907 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002908 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002909 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002910 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002911 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002912 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002913 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002914 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002915 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002916 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002917 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002918 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2919 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002920 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002921 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002922 .ppu_enable = mv88e6185_g1_ppu_enable,
2923 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002924 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002925 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002926 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002927 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002928};
2929
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002930static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002931 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002932 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2933 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002934 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002935 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2936 .phy_read = mv88e6xxx_g2_smi_phy_read,
2937 .phy_write = mv88e6xxx_g2_smi_phy_write,
2938 .port_set_link = mv88e6xxx_port_set_link,
2939 .port_set_duplex = mv88e6xxx_port_set_duplex,
2940 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002941 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002942 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002943 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002944 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002945 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002946 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002947 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002948 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002949 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002950 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002951 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002952 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002953 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002954 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2955 .stats_get_strings = mv88e6095_stats_get_strings,
2956 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002957 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2958 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002959 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002960 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002961 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002962 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002963 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002964 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002965 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002966 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002967};
2968
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002969static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002970 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002971 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2972 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002973 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002974 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002975 .phy_read = mv88e6xxx_g2_smi_phy_read,
2976 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002977 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002978 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002979 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002980 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002981 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002982 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002983 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002984 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002985 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002986 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002987 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002988 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2989 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002990 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002991 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2992 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002993 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002994 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002995 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002996 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002997 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002998 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002999 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003000};
3001
3002static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003003 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003004 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3005 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003006 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003007 .phy_read = mv88e6185_phy_ppu_read,
3008 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003009 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003010 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003011 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003012 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003013 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003014 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003015 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003016 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003017 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003018 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003019 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003020 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003021 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003022 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003023 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003024 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003025 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3026 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003027 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003028 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3029 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003030 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003031 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003032 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003033 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003034 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003035 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003036 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003037 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003038 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003039};
3040
Vivien Didelot990e27b2017-03-28 13:50:32 -04003041static const struct mv88e6xxx_ops mv88e6141_ops = {
3042 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003043 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3044 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003045 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003046 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3047 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3048 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3049 .phy_read = mv88e6xxx_g2_smi_phy_read,
3050 .phy_write = mv88e6xxx_g2_smi_phy_write,
3051 .port_set_link = mv88e6xxx_port_set_link,
3052 .port_set_duplex = mv88e6xxx_port_set_duplex,
3053 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003054 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003055 .port_tag_remap = mv88e6095_port_tag_remap,
3056 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3057 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3058 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003059 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003060 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003061 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003062 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3063 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003064 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003065 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003066 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003067 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003068 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3069 .stats_get_strings = mv88e6320_stats_get_strings,
3070 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003071 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3072 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003073 .watchdog_ops = &mv88e6390_watchdog_ops,
3074 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003075 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003076 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003077 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003078 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003079 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003080 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003081 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003082};
3083
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003084static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003085 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003086 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3087 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003088 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003089 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003090 .phy_read = mv88e6xxx_g2_smi_phy_read,
3091 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003092 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003093 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003094 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003095 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003096 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003097 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003098 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003099 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003100 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003101 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003102 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003103 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003104 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003105 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003106 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003107 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003108 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3109 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003110 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003111 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3112 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003113 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003114 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003115 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003116 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003117 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003118 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003119 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003120 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003121 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003122};
3123
3124static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003125 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003126 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3127 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003128 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003129 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003130 .phy_read = mv88e6165_phy_read,
3131 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003132 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003133 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003134 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003135 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003136 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003137 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003138 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003139 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003140 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003141 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3142 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003143 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003144 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3145 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003146 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003147 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003148 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003149 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003150 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003151 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003152 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003153 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003154 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003155};
3156
3157static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003158 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003159 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3160 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003161 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003162 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003163 .phy_read = mv88e6xxx_g2_smi_phy_read,
3164 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003165 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003166 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003167 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003168 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003169 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003170 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003171 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003172 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003173 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003174 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003175 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003176 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003177 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003178 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003179 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003180 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003181 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003182 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3183 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003184 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003185 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3186 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003187 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003188 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003189 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003190 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003191 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003192 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003193 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003194};
3195
3196static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003197 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003198 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3199 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003200 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003201 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3202 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003203 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003204 .phy_read = mv88e6xxx_g2_smi_phy_read,
3205 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003206 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003207 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003208 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003209 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003210 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003211 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003212 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003213 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003214 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003215 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003216 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003217 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003218 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003219 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003220 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003221 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003222 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003223 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3224 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003225 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003226 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3227 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003228 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003229 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003230 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003231 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003232 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003233 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003234 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003235 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003236 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003237 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003238};
3239
3240static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003241 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003242 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3243 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003244 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003245 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003246 .phy_read = mv88e6xxx_g2_smi_phy_read,
3247 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003248 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003249 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003250 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003251 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003252 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003253 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003254 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003255 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003256 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003257 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003258 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003259 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003260 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003261 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003262 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003263 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003264 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003265 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3266 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003267 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003268 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3269 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003270 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003271 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003272 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003273 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003274 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003275 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003276 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003277};
3278
3279static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003280 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003281 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3282 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003283 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003284 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3285 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003286 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003287 .phy_read = mv88e6xxx_g2_smi_phy_read,
3288 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003289 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003290 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003291 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003292 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003293 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003294 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003295 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003296 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003297 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003298 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003299 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003300 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003301 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003302 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003303 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003304 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003305 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003306 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3307 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003308 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003309 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3310 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003311 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003312 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003313 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003314 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003315 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003316 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003317 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003318 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003319 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3320 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003321 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003322 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003323};
3324
3325static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003326 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003327 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3328 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003329 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003330 .phy_read = mv88e6185_phy_ppu_read,
3331 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003332 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003333 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003334 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003335 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003336 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003337 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003338 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003339 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003340 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003341 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003342 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003343 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003344 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3345 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003346 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003347 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3348 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003349 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003350 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003351 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003352 .ppu_enable = mv88e6185_g1_ppu_enable,
3353 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003354 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003355 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003356 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003357 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003358};
3359
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003360static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003361 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003362 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003363 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003364 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3365 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003366 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3367 .phy_read = mv88e6xxx_g2_smi_phy_read,
3368 .phy_write = mv88e6xxx_g2_smi_phy_write,
3369 .port_set_link = mv88e6xxx_port_set_link,
3370 .port_set_duplex = mv88e6xxx_port_set_duplex,
3371 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3372 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003373 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003374 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003375 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003376 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003377 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003378 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003379 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003380 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003381 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003382 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003383 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003384 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003385 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3386 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003387 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003388 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3389 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003390 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003391 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003392 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003393 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003394 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003395 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3396 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003397 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003398 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3399 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003400 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003401 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003402};
3403
3404static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003405 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003406 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003407 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003408 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3409 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003410 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3411 .phy_read = mv88e6xxx_g2_smi_phy_read,
3412 .phy_write = mv88e6xxx_g2_smi_phy_write,
3413 .port_set_link = mv88e6xxx_port_set_link,
3414 .port_set_duplex = mv88e6xxx_port_set_duplex,
3415 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3416 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003417 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003418 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003419 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003420 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003421 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003422 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003423 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003424 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003425 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003426 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003427 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003428 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003429 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3430 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003431 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003432 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3433 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003434 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003435 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003436 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003437 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003438 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003439 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3440 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003441 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003442 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3443 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003444 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003445 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003446};
3447
3448static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003449 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003450 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003451 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003452 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3453 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003454 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3455 .phy_read = mv88e6xxx_g2_smi_phy_read,
3456 .phy_write = mv88e6xxx_g2_smi_phy_write,
3457 .port_set_link = mv88e6xxx_port_set_link,
3458 .port_set_duplex = mv88e6xxx_port_set_duplex,
3459 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3460 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003461 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003462 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003463 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003464 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003465 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003466 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003467 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003468 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003469 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003470 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003471 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003472 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003473 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3474 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003475 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003476 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3477 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003478 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003479 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003480 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003481 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003482 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003483 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3484 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003485 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003486 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3487 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003488 .avb_ops = &mv88e6390_avb_ops,
3489 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003490 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003491};
3492
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003493static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003494 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003495 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3496 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003497 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003498 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3499 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003500 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003501 .phy_read = mv88e6xxx_g2_smi_phy_read,
3502 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003503 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003504 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003505 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003506 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003507 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003508 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003509 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003510 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003511 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003512 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003513 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003514 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003515 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003516 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003517 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003518 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003519 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003520 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3521 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003522 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003523 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3524 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003525 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003526 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003527 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003528 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003529 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003530 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003531 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003532 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003533 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3534 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003535 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003536 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003537 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003538 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003539};
3540
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003541static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003542 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003543 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003544 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003545 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3546 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003547 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3548 .phy_read = mv88e6xxx_g2_smi_phy_read,
3549 .phy_write = mv88e6xxx_g2_smi_phy_write,
3550 .port_set_link = mv88e6xxx_port_set_link,
3551 .port_set_duplex = mv88e6xxx_port_set_duplex,
3552 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3553 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003554 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003555 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003556 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003557 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003558 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003559 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003560 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003561 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003562 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003563 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003564 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003565 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003566 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3567 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003568 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003569 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3570 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003571 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003572 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003573 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003574 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003575 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003576 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3577 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003578 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003579 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3580 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003581 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003582 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003583 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003584 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003585};
3586
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003587static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003588 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003589 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3590 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003591 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003592 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3593 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003594 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003595 .phy_read = mv88e6xxx_g2_smi_phy_read,
3596 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003597 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003598 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003599 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003600 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003601 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003602 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003603 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003604 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003605 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003606 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003607 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003608 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003609 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003610 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003611 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003612 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003613 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3614 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003615 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003616 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3617 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003618 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003619 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003620 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003621 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003622 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003623 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003624 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003625 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003626 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003627 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003628};
3629
3630static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003631 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003632 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3633 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003634 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003635 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3636 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003637 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003638 .phy_read = mv88e6xxx_g2_smi_phy_read,
3639 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003640 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003641 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003642 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003643 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003644 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003645 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003646 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003647 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003648 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003649 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003650 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003651 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003652 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003653 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003654 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003655 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003656 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3657 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003658 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003659 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3660 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003661 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003662 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003663 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003664 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003665 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003666 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003667 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003668 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003669};
3670
Vivien Didelot16e329a2017-03-28 13:50:33 -04003671static const struct mv88e6xxx_ops mv88e6341_ops = {
3672 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003673 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3674 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003675 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003676 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3677 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3678 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3679 .phy_read = mv88e6xxx_g2_smi_phy_read,
3680 .phy_write = mv88e6xxx_g2_smi_phy_write,
3681 .port_set_link = mv88e6xxx_port_set_link,
3682 .port_set_duplex = mv88e6xxx_port_set_duplex,
3683 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003684 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003685 .port_tag_remap = mv88e6095_port_tag_remap,
3686 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3687 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3688 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003689 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003690 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003691 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003692 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3693 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003694 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003695 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003696 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003697 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003698 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3699 .stats_get_strings = mv88e6320_stats_get_strings,
3700 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003701 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3702 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003703 .watchdog_ops = &mv88e6390_watchdog_ops,
3704 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003705 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003706 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003707 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003708 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003709 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003710 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003711 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003712 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003713 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003714};
3715
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003716static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003717 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003718 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3719 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003720 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003721 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003722 .phy_read = mv88e6xxx_g2_smi_phy_read,
3723 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003724 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003725 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003726 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003727 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003728 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003729 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003730 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003731 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003732 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003733 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003734 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003735 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003736 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003737 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003738 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003739 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003740 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003741 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3742 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003743 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003744 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3745 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003746 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003747 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003748 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003749 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003750 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003751 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003752 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003753};
3754
3755static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003756 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003757 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3758 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003759 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003760 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003761 .phy_read = mv88e6xxx_g2_smi_phy_read,
3762 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003763 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003764 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003765 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003766 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003767 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003768 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003769 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003770 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003771 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003772 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003773 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003774 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003775 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003776 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003777 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003778 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003779 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003780 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3781 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003782 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003783 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3784 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003785 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003786 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003787 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003788 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003789 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003790 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003791 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003792 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003793 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003794};
3795
3796static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003797 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003798 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3799 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003800 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003801 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3802 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003803 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003804 .phy_read = mv88e6xxx_g2_smi_phy_read,
3805 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003806 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003807 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003808 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003809 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003810 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003811 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003812 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003813 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003814 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003815 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003816 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003817 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003818 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003819 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003820 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003821 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003822 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003823 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3824 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003825 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003826 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3827 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003828 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003829 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003830 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003831 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003832 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003833 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003834 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003835 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003836 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3837 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003838 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003839 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003840 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003841 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3842 .serdes_get_strings = mv88e6352_serdes_get_strings,
3843 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003844 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003845};
3846
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003847static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003848 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003849 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003850 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003851 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3852 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003853 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3854 .phy_read = mv88e6xxx_g2_smi_phy_read,
3855 .phy_write = mv88e6xxx_g2_smi_phy_write,
3856 .port_set_link = mv88e6xxx_port_set_link,
3857 .port_set_duplex = mv88e6xxx_port_set_duplex,
3858 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3859 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003860 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003861 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003862 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003863 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003864 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003865 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003866 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003867 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003868 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003869 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003870 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003871 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003872 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003873 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003874 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3875 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003876 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003877 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3878 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003879 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003880 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003881 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003882 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003883 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003884 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3885 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003886 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003887 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3888 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003889 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003890 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003891 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003892 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003893};
3894
3895static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003896 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003897 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003898 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003899 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3900 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003901 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3902 .phy_read = mv88e6xxx_g2_smi_phy_read,
3903 .phy_write = mv88e6xxx_g2_smi_phy_write,
3904 .port_set_link = mv88e6xxx_port_set_link,
3905 .port_set_duplex = mv88e6xxx_port_set_duplex,
3906 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3907 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003908 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003909 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003910 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003911 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003912 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003913 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003914 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003915 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003916 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003917 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003918 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003919 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003920 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003921 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003922 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3923 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003924 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003925 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3926 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003927 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003928 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003929 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003930 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003931 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003932 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3933 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003934 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003935 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3936 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003937 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003938 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003939 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003940 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003941};
3942
Vivien Didelotf81ec902016-05-09 13:22:58 -04003943static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3944 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003945 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003946 .family = MV88E6XXX_FAMILY_6097,
3947 .name = "Marvell 88E6085",
3948 .num_databases = 4096,
3949 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003950 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003951 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003952 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003953 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003954 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003955 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003956 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003957 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003958 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003959 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003960 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003961 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003962 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003963 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003964 },
3965
3966 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003967 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003968 .family = MV88E6XXX_FAMILY_6095,
3969 .name = "Marvell 88E6095/88E6095F",
3970 .num_databases = 256,
3971 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003972 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003973 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003974 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003975 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003976 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003977 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003978 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003979 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003980 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003981 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003982 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003983 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003984 },
3985
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003986 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003987 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003988 .family = MV88E6XXX_FAMILY_6097,
3989 .name = "Marvell 88E6097/88E6097F",
3990 .num_databases = 4096,
3991 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003992 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003993 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003994 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003995 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003996 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003997 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003998 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003999 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004000 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004001 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004002 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004003 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004004 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004005 .ops = &mv88e6097_ops,
4006 },
4007
Vivien Didelotf81ec902016-05-09 13:22:58 -04004008 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004009 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004010 .family = MV88E6XXX_FAMILY_6165,
4011 .name = "Marvell 88E6123",
4012 .num_databases = 4096,
4013 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004014 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004015 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004016 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004017 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004018 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004019 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004020 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004021 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004022 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004023 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004024 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004025 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004026 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004027 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004028 },
4029
4030 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004031 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004032 .family = MV88E6XXX_FAMILY_6185,
4033 .name = "Marvell 88E6131",
4034 .num_databases = 256,
4035 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004036 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004037 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004038 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004039 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004040 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004041 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004042 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004043 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004044 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004045 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004046 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004047 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004048 },
4049
Vivien Didelot990e27b2017-03-28 13:50:32 -04004050 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004051 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004052 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004053 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004054 .num_databases = 4096,
4055 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004056 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004057 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004058 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004059 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004060 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004061 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004062 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004063 .age_time_coeff = 3750,
4064 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004065 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004066 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004067 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004068 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004069 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004070 .ops = &mv88e6141_ops,
4071 },
4072
Vivien Didelotf81ec902016-05-09 13:22:58 -04004073 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004074 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004075 .family = MV88E6XXX_FAMILY_6165,
4076 .name = "Marvell 88E6161",
4077 .num_databases = 4096,
4078 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004079 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004080 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004081 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004082 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004083 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004084 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004085 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004086 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004087 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004088 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004089 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004090 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004091 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004092 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004093 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004094 },
4095
4096 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004097 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004098 .family = MV88E6XXX_FAMILY_6165,
4099 .name = "Marvell 88E6165",
4100 .num_databases = 4096,
4101 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004102 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004103 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004104 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004105 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004106 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004107 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004108 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004109 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004110 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004111 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004112 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004113 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004114 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004115 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004116 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004117 },
4118
4119 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004120 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004121 .family = MV88E6XXX_FAMILY_6351,
4122 .name = "Marvell 88E6171",
4123 .num_databases = 4096,
4124 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004125 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004126 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004127 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004128 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004129 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004130 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004131 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004132 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004133 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004134 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004135 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004136 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004137 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004138 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004139 },
4140
4141 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004142 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004143 .family = MV88E6XXX_FAMILY_6352,
4144 .name = "Marvell 88E6172",
4145 .num_databases = 4096,
4146 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004147 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004148 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004149 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004150 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004151 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004152 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004153 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004154 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004155 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004156 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004157 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004158 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004159 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004160 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004161 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004162 },
4163
4164 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004165 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004166 .family = MV88E6XXX_FAMILY_6351,
4167 .name = "Marvell 88E6175",
4168 .num_databases = 4096,
4169 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004170 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004171 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004172 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004173 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004174 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004175 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004176 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004177 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004178 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004179 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004180 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004181 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004182 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004183 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004184 },
4185
4186 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004187 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004188 .family = MV88E6XXX_FAMILY_6352,
4189 .name = "Marvell 88E6176",
4190 .num_databases = 4096,
4191 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004192 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004193 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004194 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004195 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004196 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004197 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004198 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004199 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004200 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004201 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004202 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004203 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004204 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004205 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004206 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004207 },
4208
4209 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004210 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004211 .family = MV88E6XXX_FAMILY_6185,
4212 .name = "Marvell 88E6185",
4213 .num_databases = 256,
4214 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004215 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004216 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004217 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004218 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004219 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004220 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004221 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004222 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004223 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004224 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004225 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004226 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004227 },
4228
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004229 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004230 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004231 .family = MV88E6XXX_FAMILY_6390,
4232 .name = "Marvell 88E6190",
4233 .num_databases = 4096,
4234 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004235 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004236 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004237 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004238 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004239 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004240 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004241 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004242 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004243 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004244 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004245 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004246 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004247 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004248 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004249 .ops = &mv88e6190_ops,
4250 },
4251
4252 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004253 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004254 .family = MV88E6XXX_FAMILY_6390,
4255 .name = "Marvell 88E6190X",
4256 .num_databases = 4096,
4257 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004258 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004259 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004260 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004261 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004262 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004263 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004264 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004265 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004266 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004267 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004268 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004269 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004270 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004271 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004272 .ops = &mv88e6190x_ops,
4273 },
4274
4275 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004276 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004277 .family = MV88E6XXX_FAMILY_6390,
4278 .name = "Marvell 88E6191",
4279 .num_databases = 4096,
4280 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004281 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004282 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004283 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004284 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004285 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004286 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004287 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004288 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004289 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004290 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004291 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004292 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004293 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004294 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004295 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004296 },
4297
Vivien Didelotf81ec902016-05-09 13:22:58 -04004298 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004299 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004300 .family = MV88E6XXX_FAMILY_6352,
4301 .name = "Marvell 88E6240",
4302 .num_databases = 4096,
4303 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004304 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004305 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004306 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004307 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004308 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004309 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004310 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004311 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004312 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004313 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004314 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004315 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004316 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004317 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004318 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004319 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004320 },
4321
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004322 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004323 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004324 .family = MV88E6XXX_FAMILY_6390,
4325 .name = "Marvell 88E6290",
4326 .num_databases = 4096,
4327 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004328 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004329 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004330 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004331 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004332 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004333 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004334 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004335 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004336 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004337 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004338 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004339 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004340 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004341 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004342 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004343 .ops = &mv88e6290_ops,
4344 },
4345
Vivien Didelotf81ec902016-05-09 13:22:58 -04004346 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004347 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004348 .family = MV88E6XXX_FAMILY_6320,
4349 .name = "Marvell 88E6320",
4350 .num_databases = 4096,
4351 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004352 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004353 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004354 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004355 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004356 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004357 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004358 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004359 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004360 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004361 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004362 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004363 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004364 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004365 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004366 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004367 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004368 },
4369
4370 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004371 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004372 .family = MV88E6XXX_FAMILY_6320,
4373 .name = "Marvell 88E6321",
4374 .num_databases = 4096,
4375 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004376 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004377 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004378 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004379 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004380 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004381 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004382 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004383 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004384 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004385 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004386 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004387 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004388 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004389 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004390 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004391 },
4392
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004393 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004394 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004395 .family = MV88E6XXX_FAMILY_6341,
4396 .name = "Marvell 88E6341",
4397 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004398 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004399 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004400 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004401 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004402 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004403 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004404 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004405 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004406 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004407 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004408 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004409 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004410 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004411 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004412 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004413 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004414 .ops = &mv88e6341_ops,
4415 },
4416
Vivien Didelotf81ec902016-05-09 13:22:58 -04004417 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004418 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004419 .family = MV88E6XXX_FAMILY_6351,
4420 .name = "Marvell 88E6350",
4421 .num_databases = 4096,
4422 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004423 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004424 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004425 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004426 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004427 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004428 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004429 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004430 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004431 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004432 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004433 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004434 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004435 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004436 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004437 },
4438
4439 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004440 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004441 .family = MV88E6XXX_FAMILY_6351,
4442 .name = "Marvell 88E6351",
4443 .num_databases = 4096,
4444 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004445 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004446 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004447 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004448 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004449 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004450 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004451 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004452 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004453 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004454 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004455 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004456 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004457 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004458 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004459 },
4460
4461 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004462 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004463 .family = MV88E6XXX_FAMILY_6352,
4464 .name = "Marvell 88E6352",
4465 .num_databases = 4096,
4466 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004467 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004468 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004469 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004470 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004471 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004472 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004473 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004474 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004475 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004476 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004477 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004478 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004479 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004480 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004481 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004482 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004483 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004484 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004485 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004486 .family = MV88E6XXX_FAMILY_6390,
4487 .name = "Marvell 88E6390",
4488 .num_databases = 4096,
4489 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004490 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004491 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004492 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004493 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004494 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004495 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004496 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004497 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004498 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004499 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004500 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004501 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004502 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004503 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004504 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004505 .ops = &mv88e6390_ops,
4506 },
4507 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004508 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004509 .family = MV88E6XXX_FAMILY_6390,
4510 .name = "Marvell 88E6390X",
4511 .num_databases = 4096,
4512 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004513 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004514 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004515 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004516 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004517 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004518 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004519 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004520 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004521 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004522 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004523 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004524 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004525 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004526 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004527 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004528 .ops = &mv88e6390x_ops,
4529 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004530};
4531
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004532static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004533{
Vivien Didelota439c062016-04-17 13:23:58 -04004534 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004535
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004536 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4537 if (mv88e6xxx_table[i].prod_num == prod_num)
4538 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004539
Vivien Didelotb9b37712015-10-30 19:39:48 -04004540 return NULL;
4541}
4542
Vivien Didelotfad09c72016-06-21 12:28:20 -04004543static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004544{
4545 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004546 unsigned int prod_num, rev;
4547 u16 id;
4548 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004549
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004550 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004551 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004552 mutex_unlock(&chip->reg_lock);
4553 if (err)
4554 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004555
Vivien Didelot107fcc12017-06-12 12:37:36 -04004556 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4557 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004558
4559 info = mv88e6xxx_lookup_info(prod_num);
4560 if (!info)
4561 return -ENODEV;
4562
Vivien Didelotcaac8542016-06-20 13:14:09 -04004563 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004564 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004565
Vivien Didelotca070c12016-09-02 14:45:34 -04004566 err = mv88e6xxx_g2_require(chip);
4567 if (err)
4568 return err;
4569
Vivien Didelotfad09c72016-06-21 12:28:20 -04004570 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4571 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004572
4573 return 0;
4574}
4575
Vivien Didelotfad09c72016-06-21 12:28:20 -04004576static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004577{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004578 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004579
Vivien Didelotfad09c72016-06-21 12:28:20 -04004580 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4581 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004582 return NULL;
4583
Vivien Didelotfad09c72016-06-21 12:28:20 -04004584 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004585
Vivien Didelotfad09c72016-06-21 12:28:20 -04004586 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004587 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004588
Vivien Didelotfad09c72016-06-21 12:28:20 -04004589 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004590}
4591
Vivien Didelotfad09c72016-06-21 12:28:20 -04004592static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004593 struct mii_bus *bus, int sw_addr)
4594{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004595 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004596 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004597 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004598 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004599 else
4600 return -EINVAL;
4601
Vivien Didelotfad09c72016-06-21 12:28:20 -04004602 chip->bus = bus;
4603 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004604
4605 return 0;
4606}
4607
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004608static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4609 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004610{
Vivien Didelot04bed142016-08-31 18:06:13 -04004611 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004612
Andrew Lunn443d5a12016-12-03 04:35:18 +01004613 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004614}
4615
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004616#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004617static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4618 struct device *host_dev, int sw_addr,
4619 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004620{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004621 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004622 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004623 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004624
Vivien Didelota439c062016-04-17 13:23:58 -04004625 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004626 if (!bus)
4627 return NULL;
4628
Vivien Didelotfad09c72016-06-21 12:28:20 -04004629 chip = mv88e6xxx_alloc_chip(dsa_dev);
4630 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004631 return NULL;
4632
Vivien Didelotcaac8542016-06-20 13:14:09 -04004633 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004634 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004635
Vivien Didelotfad09c72016-06-21 12:28:20 -04004636 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004637 if (err)
4638 goto free;
4639
Vivien Didelotfad09c72016-06-21 12:28:20 -04004640 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004641 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004642 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004643
Andrew Lunndc30c352016-10-16 19:56:49 +02004644 mutex_lock(&chip->reg_lock);
4645 err = mv88e6xxx_switch_reset(chip);
4646 mutex_unlock(&chip->reg_lock);
4647 if (err)
4648 goto free;
4649
Vivien Didelote57e5e72016-08-15 17:19:00 -04004650 mv88e6xxx_phy_init(chip);
4651
Andrew Lunna3c53be52017-01-24 14:53:50 +01004652 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004653 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004654 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004655
Vivien Didelotfad09c72016-06-21 12:28:20 -04004656 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004657
Vivien Didelotfad09c72016-06-21 12:28:20 -04004658 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004659free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004660 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004661
4662 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004663}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004664#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004665
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004666static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004667 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004668{
4669 /* We don't need any dynamic resource from the kernel (yet),
4670 * so skip the prepare phase.
4671 */
4672
4673 return 0;
4674}
4675
4676static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004677 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004678{
Vivien Didelot04bed142016-08-31 18:06:13 -04004679 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004680
4681 mutex_lock(&chip->reg_lock);
4682 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004683 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004684 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4685 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004686 mutex_unlock(&chip->reg_lock);
4687}
4688
4689static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4690 const struct switchdev_obj_port_mdb *mdb)
4691{
Vivien Didelot04bed142016-08-31 18:06:13 -04004692 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004693 int err;
4694
4695 mutex_lock(&chip->reg_lock);
4696 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004697 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004698 mutex_unlock(&chip->reg_lock);
4699
4700 return err;
4701}
4702
Russell King4f859012019-02-20 15:35:05 -08004703static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
4704 bool unicast, bool multicast)
4705{
4706 struct mv88e6xxx_chip *chip = ds->priv;
4707 int err = -EOPNOTSUPP;
4708
4709 mutex_lock(&chip->reg_lock);
4710 if (chip->info->ops->port_set_egress_floods)
4711 err = chip->info->ops->port_set_egress_floods(chip, port,
4712 unicast,
4713 multicast);
4714 mutex_unlock(&chip->reg_lock);
4715
4716 return err;
4717}
4718
Florian Fainellia82f67a2017-01-08 14:52:08 -08004719static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004720#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004721 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004722#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004723 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004724 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004725 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004726 .phylink_validate = mv88e6xxx_validate,
4727 .phylink_mac_link_state = mv88e6xxx_link_state,
4728 .phylink_mac_config = mv88e6xxx_mac_config,
4729 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4730 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004731 .get_strings = mv88e6xxx_get_strings,
4732 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4733 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004734 .port_enable = mv88e6xxx_port_enable,
4735 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004736 .get_mac_eee = mv88e6xxx_get_mac_eee,
4737 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004738 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004739 .get_eeprom = mv88e6xxx_get_eeprom,
4740 .set_eeprom = mv88e6xxx_set_eeprom,
4741 .get_regs_len = mv88e6xxx_get_regs_len,
4742 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004743 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004744 .port_bridge_join = mv88e6xxx_port_bridge_join,
4745 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08004746 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004747 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004748 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004749 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4750 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4751 .port_vlan_add = mv88e6xxx_port_vlan_add,
4752 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004753 .port_fdb_add = mv88e6xxx_port_fdb_add,
4754 .port_fdb_del = mv88e6xxx_port_fdb_del,
4755 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004756 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4757 .port_mdb_add = mv88e6xxx_port_mdb_add,
4758 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004759 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4760 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004761 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4762 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4763 .port_txtstamp = mv88e6xxx_port_txtstamp,
4764 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4765 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004766};
4767
Florian Fainelliab3d4082017-01-08 14:52:07 -08004768static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4769 .ops = &mv88e6xxx_switch_ops,
4770};
4771
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004772static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004773{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004774 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004775 struct dsa_switch *ds;
4776
Vivien Didelot73b12042017-03-30 17:37:10 -04004777 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004778 if (!ds)
4779 return -ENOMEM;
4780
Vivien Didelotfad09c72016-06-21 12:28:20 -04004781 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004782 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004783 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004784 ds->ageing_time_min = chip->info->age_time_coeff;
4785 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004786
4787 dev_set_drvdata(dev, ds);
4788
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004789 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004790}
4791
Vivien Didelotfad09c72016-06-21 12:28:20 -04004792static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004793{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004794 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004795}
4796
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004797static const void *pdata_device_get_match_data(struct device *dev)
4798{
4799 const struct of_device_id *matches = dev->driver->of_match_table;
4800 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4801
4802 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4803 matches++) {
4804 if (!strcmp(pdata->compatible, matches->compatible))
4805 return matches->data;
4806 }
4807 return NULL;
4808}
4809
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004810/* There is no suspend to RAM support at DSA level yet, the switch configuration
4811 * would be lost after a power cycle so prevent it to be suspended.
4812 */
4813static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4814{
4815 return -EOPNOTSUPP;
4816}
4817
4818static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4819{
4820 return 0;
4821}
4822
4823static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4824
Vivien Didelot57d32312016-06-20 13:13:58 -04004825static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004826{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004827 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004828 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004829 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004830 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004831 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004832 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004833 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004834
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004835 if (!np && !pdata)
4836 return -EINVAL;
4837
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004838 if (np)
4839 compat_info = of_device_get_match_data(dev);
4840
4841 if (pdata) {
4842 compat_info = pdata_device_get_match_data(dev);
4843
4844 if (!pdata->netdev)
4845 return -EINVAL;
4846
4847 for (port = 0; port < DSA_MAX_PORTS; port++) {
4848 if (!(pdata->enabled_ports & (1 << port)))
4849 continue;
4850 if (strcmp(pdata->cd.port_names[port], "cpu"))
4851 continue;
4852 pdata->cd.netdev[port] = &pdata->netdev->dev;
4853 break;
4854 }
4855 }
4856
Vivien Didelotcaac8542016-06-20 13:14:09 -04004857 if (!compat_info)
4858 return -EINVAL;
4859
Vivien Didelotfad09c72016-06-21 12:28:20 -04004860 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004861 if (!chip) {
4862 err = -ENOMEM;
4863 goto out;
4864 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004865
Vivien Didelotfad09c72016-06-21 12:28:20 -04004866 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004867
Vivien Didelotfad09c72016-06-21 12:28:20 -04004868 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004869 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004870 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004871
Andrew Lunnb4308f02016-11-21 23:26:55 +01004872 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004873 if (IS_ERR(chip->reset)) {
4874 err = PTR_ERR(chip->reset);
4875 goto out;
4876 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004877
Vivien Didelotfad09c72016-06-21 12:28:20 -04004878 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004879 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004880 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004881
Vivien Didelote57e5e72016-08-15 17:19:00 -04004882 mv88e6xxx_phy_init(chip);
4883
Andrew Lunn00baabe2018-05-19 22:31:35 +02004884 if (chip->info->ops->get_eeprom) {
4885 if (np)
4886 of_property_read_u32(np, "eeprom-length",
4887 &chip->eeprom_len);
4888 else
4889 chip->eeprom_len = pdata->eeprom_len;
4890 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004891
Andrew Lunndc30c352016-10-16 19:56:49 +02004892 mutex_lock(&chip->reg_lock);
4893 err = mv88e6xxx_switch_reset(chip);
4894 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004895 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004896 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004897
Andrew Lunndc30c352016-10-16 19:56:49 +02004898 chip->irq = of_irq_get(np, 0);
4899 if (chip->irq == -EPROBE_DEFER) {
4900 err = chip->irq;
4901 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004902 }
4903
Andrew Lunn294d7112018-02-22 22:58:32 +01004904 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004905 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004906 * controllers
4907 */
4908 mutex_lock(&chip->reg_lock);
4909 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004910 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004911 else
4912 err = mv88e6xxx_irq_poll_setup(chip);
4913 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004914
Andrew Lunn294d7112018-02-22 22:58:32 +01004915 if (err)
4916 goto out;
4917
4918 if (chip->info->g2_irqs > 0) {
4919 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004920 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004921 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004922 }
4923
Andrew Lunn294d7112018-02-22 22:58:32 +01004924 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4925 if (err)
4926 goto out_g2_irq;
4927
4928 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4929 if (err)
4930 goto out_g1_atu_prob_irq;
4931
Andrew Lunna3c53be52017-01-24 14:53:50 +01004932 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004933 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004934 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004935
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004936 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004937 if (err)
4938 goto out_mdio;
4939
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004940 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004941
4942out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004943 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004944out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004945 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004946out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004947 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004948out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004949 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004950 mv88e6xxx_g2_irq_free(chip);
4951out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004952 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004953 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004954 else
4955 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004956out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004957 if (pdata)
4958 dev_put(pdata->netdev);
4959
Andrew Lunndc30c352016-10-16 19:56:49 +02004960 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004961}
4962
4963static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4964{
4965 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004966 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004967
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004968 if (chip->info->ptp_support) {
4969 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004970 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004971 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004972
Andrew Lunn930188c2016-08-22 16:01:03 +02004973 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004974 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004975 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004976
Andrew Lunn76f38f12018-03-17 20:21:09 +01004977 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4978 mv88e6xxx_g1_atu_prob_irq_free(chip);
4979
4980 if (chip->info->g2_irqs > 0)
4981 mv88e6xxx_g2_irq_free(chip);
4982
Andrew Lunn76f38f12018-03-17 20:21:09 +01004983 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004984 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004985 else
4986 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004987}
4988
4989static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004990 {
4991 .compatible = "marvell,mv88e6085",
4992 .data = &mv88e6xxx_table[MV88E6085],
4993 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004994 {
4995 .compatible = "marvell,mv88e6190",
4996 .data = &mv88e6xxx_table[MV88E6190],
4997 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004998 { /* sentinel */ },
4999};
5000
5001MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5002
5003static struct mdio_driver mv88e6xxx_driver = {
5004 .probe = mv88e6xxx_probe,
5005 .remove = mv88e6xxx_remove,
5006 .mdiodrv.driver = {
5007 .name = "mv88e6085",
5008 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005009 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005010 },
5011};
5012
Ben Hutchings98e67302011-11-25 14:36:19 +00005013static int __init mv88e6xxx_init(void)
5014{
Florian Fainelliab3d4082017-01-08 14:52:07 -08005015 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005016 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00005017}
5018module_init(mv88e6xxx_init);
5019
5020static void __exit mv88e6xxx_cleanup(void)
5021{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005022 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08005023 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00005024}
5025module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005026
5027MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5028MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5029MODULE_LICENSE("GPL");