blob: 733bb137efbfcb3917b61a954e21771aa53203e7 [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;
264 int err;
265
266 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400267 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200268 mutex_unlock(&chip->reg_lock);
269
270 if (err)
271 goto out;
272
273 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
274 if (reg & (1 << n)) {
275 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
276 handle_nested_irq(sub_irq);
277 ++nhandled;
278 }
279 }
280out:
281 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
282}
283
Andrew Lunn294d7112018-02-22 22:58:32 +0100284static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
285{
286 struct mv88e6xxx_chip *chip = dev_id;
287
288 return mv88e6xxx_g1_irq_thread_work(chip);
289}
290
Andrew Lunndc30c352016-10-16 19:56:49 +0200291static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
292{
293 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
294
295 mutex_lock(&chip->reg_lock);
296}
297
298static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
299{
300 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
301 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
302 u16 reg;
303 int err;
304
Vivien Didelotd77f4322017-06-15 12:14:03 -0400305 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200306 if (err)
307 goto out;
308
309 reg &= ~mask;
310 reg |= (~chip->g1_irq.masked & mask);
311
Vivien Didelotd77f4322017-06-15 12:14:03 -0400312 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200313 if (err)
314 goto out;
315
316out:
317 mutex_unlock(&chip->reg_lock);
318}
319
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530320static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200321 .name = "mv88e6xxx-g1",
322 .irq_mask = mv88e6xxx_g1_irq_mask,
323 .irq_unmask = mv88e6xxx_g1_irq_unmask,
324 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
325 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
326};
327
328static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
329 unsigned int irq,
330 irq_hw_number_t hwirq)
331{
332 struct mv88e6xxx_chip *chip = d->host_data;
333
334 irq_set_chip_data(irq, d->host_data);
335 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
336 irq_set_noprobe(irq);
337
338 return 0;
339}
340
341static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
342 .map = mv88e6xxx_g1_irq_domain_map,
343 .xlate = irq_domain_xlate_twocell,
344};
345
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200346/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100347static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200348{
349 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100350 u16 mask;
351
Vivien Didelotd77f4322017-06-15 12:14:03 -0400352 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100353 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400354 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100355
Andreas Färber5edef2f2016-11-27 23:26:28 +0100356 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100357 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200358 irq_dispose_mapping(virq);
359 }
360
Andrew Lunna3db3d32016-11-20 20:14:14 +0100361 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200362}
363
Andrew Lunn294d7112018-02-22 22:58:32 +0100364static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
365{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200366 /*
367 * free_irq must be called without reg_lock taken because the irq
368 * handler takes this lock, too.
369 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100370 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200371
372 mutex_lock(&chip->reg_lock);
373 mv88e6xxx_g1_irq_free_common(chip);
374 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100375}
376
377static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200378{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100379 int err, irq, virq;
380 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200381
382 chip->g1_irq.nirqs = chip->info->g1_irqs;
383 chip->g1_irq.domain = irq_domain_add_simple(
384 NULL, chip->g1_irq.nirqs, 0,
385 &mv88e6xxx_g1_irq_domain_ops, chip);
386 if (!chip->g1_irq.domain)
387 return -ENOMEM;
388
389 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
390 irq_create_mapping(chip->g1_irq.domain, irq);
391
392 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
393 chip->g1_irq.masked = ~0;
394
Vivien Didelotd77f4322017-06-15 12:14:03 -0400395 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200396 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100397 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200398
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100399 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200400
Vivien Didelotd77f4322017-06-15 12:14:03 -0400401 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200402 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100403 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200404
405 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400406 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200407 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100408 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200409
Andrew Lunndc30c352016-10-16 19:56:49 +0200410 return 0;
411
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100412out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100413 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400414 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100415
416out_mapping:
417 for (irq = 0; irq < 16; irq++) {
418 virq = irq_find_mapping(chip->g1_irq.domain, irq);
419 irq_dispose_mapping(virq);
420 }
421
422 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200423
424 return err;
425}
426
Andrew Lunn294d7112018-02-22 22:58:32 +0100427static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
428{
429 int err;
430
431 err = mv88e6xxx_g1_irq_setup_common(chip);
432 if (err)
433 return err;
434
435 err = request_threaded_irq(chip->irq, NULL,
436 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200437 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100438 dev_name(chip->dev), chip);
439 if (err)
440 mv88e6xxx_g1_irq_free_common(chip);
441
442 return err;
443}
444
445static void mv88e6xxx_irq_poll(struct kthread_work *work)
446{
447 struct mv88e6xxx_chip *chip = container_of(work,
448 struct mv88e6xxx_chip,
449 irq_poll_work.work);
450 mv88e6xxx_g1_irq_thread_work(chip);
451
452 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
453 msecs_to_jiffies(100));
454}
455
456static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
457{
458 int err;
459
460 err = mv88e6xxx_g1_irq_setup_common(chip);
461 if (err)
462 return err;
463
464 kthread_init_delayed_work(&chip->irq_poll_work,
465 mv88e6xxx_irq_poll);
466
467 chip->kworker = kthread_create_worker(0, dev_name(chip->dev));
468 if (IS_ERR(chip->kworker))
469 return PTR_ERR(chip->kworker);
470
471 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
472 msecs_to_jiffies(100));
473
474 return 0;
475}
476
477static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
478{
479 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
480 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200481
482 mutex_lock(&chip->reg_lock);
483 mv88e6xxx_g1_irq_free_common(chip);
484 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100485}
486
Vivien Didelotec561272016-09-02 14:45:33 -0400487int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400488{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200489 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400490
Andrew Lunn6441e6692016-08-19 00:01:55 +0200491 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400492 u16 val;
493 int err;
494
495 err = mv88e6xxx_read(chip, addr, reg, &val);
496 if (err)
497 return err;
498
499 if (!(val & mask))
500 return 0;
501
502 usleep_range(1000, 2000);
503 }
504
Andrew Lunn30853552016-08-19 00:01:57 +0200505 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400506 return -ETIMEDOUT;
507}
508
Vivien Didelotf22ab642016-07-18 20:45:31 -0400509/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400510int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400511{
512 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200513 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400514
515 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200516 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
517 if (err)
518 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400519
520 /* Set the Update bit to trigger a write operation */
521 val = BIT(15) | update;
522
523 return mv88e6xxx_write(chip, addr, reg, val);
524}
525
Vivien Didelotd78343d2016-11-04 03:23:36 +0100526static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
Andrew Lunn54186b92018-08-09 15:38:37 +0200527 int link, int speed, int duplex, int pause,
Vivien Didelotd78343d2016-11-04 03:23:36 +0100528 phy_interface_t mode)
529{
530 int err;
531
532 if (!chip->info->ops->port_set_link)
533 return 0;
534
535 /* Port's MAC control must not be changed unless the link is down */
536 err = chip->info->ops->port_set_link(chip, port, 0);
537 if (err)
538 return err;
539
540 if (chip->info->ops->port_set_speed) {
541 err = chip->info->ops->port_set_speed(chip, port, speed);
542 if (err && err != -EOPNOTSUPP)
543 goto restore_link;
544 }
545
Andrew Lunn54186b92018-08-09 15:38:37 +0200546 if (chip->info->ops->port_set_pause) {
547 err = chip->info->ops->port_set_pause(chip, port, pause);
548 if (err)
549 goto restore_link;
550 }
551
Vivien Didelotd78343d2016-11-04 03:23:36 +0100552 if (chip->info->ops->port_set_duplex) {
553 err = chip->info->ops->port_set_duplex(chip, port, duplex);
554 if (err && err != -EOPNOTSUPP)
555 goto restore_link;
556 }
557
558 if (chip->info->ops->port_set_rgmii_delay) {
559 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
560 if (err && err != -EOPNOTSUPP)
561 goto restore_link;
562 }
563
Andrew Lunnf39908d2017-02-04 20:02:50 +0100564 if (chip->info->ops->port_set_cmode) {
565 err = chip->info->ops->port_set_cmode(chip, port, mode);
566 if (err && err != -EOPNOTSUPP)
567 goto restore_link;
568 }
569
Vivien Didelotd78343d2016-11-04 03:23:36 +0100570 err = 0;
571restore_link:
572 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400573 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100574
575 return err;
576}
577
Marek Vasutd700ec42018-09-12 00:15:24 +0200578static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
579{
580 struct mv88e6xxx_chip *chip = ds->priv;
581
582 return port < chip->info->num_internal_phys;
583}
584
Andrew Lunndea87022015-08-31 15:56:47 +0200585/* We expect the switch to perform auto negotiation if there is a real
586 * phy. However, in the case of a fixed link phy, we force the port
587 * settings from the fixed link settings.
588 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400589static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
590 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200591{
Vivien Didelot04bed142016-08-31 18:06:13 -0400592 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200593 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200594
Marek Vasutd700ec42018-09-12 00:15:24 +0200595 if (!phy_is_pseudo_fixed_link(phydev) &&
596 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200597 return;
598
Vivien Didelotfad09c72016-06-21 12:28:20 -0400599 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100600 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200601 phydev->duplex, phydev->pause,
602 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400603 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100604
605 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400606 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200607}
608
Russell King6c422e32018-08-09 15:38:39 +0200609static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
610 unsigned long *mask,
611 struct phylink_link_state *state)
612{
613 if (!phy_interface_mode_is_8023z(state->interface)) {
614 /* 10M and 100M are only supported in non-802.3z mode */
615 phylink_set(mask, 10baseT_Half);
616 phylink_set(mask, 10baseT_Full);
617 phylink_set(mask, 100baseT_Half);
618 phylink_set(mask, 100baseT_Full);
619 }
620}
621
622static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
623 unsigned long *mask,
624 struct phylink_link_state *state)
625{
626 /* FIXME: if the port is in 1000Base-X mode, then it only supports
627 * 1000M FD speeds. In this case, CMODE will indicate 5.
628 */
629 phylink_set(mask, 1000baseT_Full);
630 phylink_set(mask, 1000baseX_Full);
631
632 mv88e6065_phylink_validate(chip, port, mask, state);
633}
634
635static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
636 unsigned long *mask,
637 struct phylink_link_state *state)
638{
639 /* No ethtool bits for 200Mbps */
640 phylink_set(mask, 1000baseT_Full);
641 phylink_set(mask, 1000baseX_Full);
642
643 mv88e6065_phylink_validate(chip, port, mask, state);
644}
645
646static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
647 unsigned long *mask,
648 struct phylink_link_state *state)
649{
650 if (port >= 9)
651 phylink_set(mask, 2500baseX_Full);
652
653 /* No ethtool bits for 200Mbps */
654 phylink_set(mask, 1000baseT_Full);
655 phylink_set(mask, 1000baseX_Full);
656
657 mv88e6065_phylink_validate(chip, port, mask, state);
658}
659
660static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
661 unsigned long *mask,
662 struct phylink_link_state *state)
663{
664 if (port >= 9) {
665 phylink_set(mask, 10000baseT_Full);
666 phylink_set(mask, 10000baseKR_Full);
667 }
668
669 mv88e6390_phylink_validate(chip, port, mask, state);
670}
671
Russell Kingc9a23562018-05-10 13:17:35 -0700672static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
673 unsigned long *supported,
674 struct phylink_link_state *state)
675{
Russell King6c422e32018-08-09 15:38:39 +0200676 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
677 struct mv88e6xxx_chip *chip = ds->priv;
678
679 /* Allow all the expected bits */
680 phylink_set(mask, Autoneg);
681 phylink_set(mask, Pause);
682 phylink_set_port_modes(mask);
683
684 if (chip->info->ops->phylink_validate)
685 chip->info->ops->phylink_validate(chip, port, mask, state);
686
687 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
688 bitmap_and(state->advertising, state->advertising, mask,
689 __ETHTOOL_LINK_MODE_MASK_NBITS);
690
691 /* We can only operate at 2500BaseX or 1000BaseX. If requested
692 * to advertise both, only report advertising at 2500BaseX.
693 */
694 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700695}
696
697static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
698 struct phylink_link_state *state)
699{
700 struct mv88e6xxx_chip *chip = ds->priv;
701 int err;
702
703 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200704 if (chip->info->ops->port_link_state)
705 err = chip->info->ops->port_link_state(chip, port, state);
706 else
707 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700708 mutex_unlock(&chip->reg_lock);
709
710 return err;
711}
712
713static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
714 unsigned int mode,
715 const struct phylink_link_state *state)
716{
717 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200718 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700719
Marek Vasutd700ec42018-09-12 00:15:24 +0200720 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700721 return;
722
723 if (mode == MLO_AN_FIXED) {
724 link = LINK_FORCED_UP;
725 speed = state->speed;
726 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200727 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
728 link = state->link;
729 speed = state->speed;
730 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700731 } else {
732 speed = SPEED_UNFORCED;
733 duplex = DUPLEX_UNFORCED;
734 link = LINK_UNFORCED;
735 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200736 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700737
738 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200739 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700740 state->interface);
741 mutex_unlock(&chip->reg_lock);
742
743 if (err && err != -EOPNOTSUPP)
744 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
745}
746
747static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
748{
749 struct mv88e6xxx_chip *chip = ds->priv;
750 int err;
751
752 mutex_lock(&chip->reg_lock);
753 err = chip->info->ops->port_set_link(chip, port, link);
754 mutex_unlock(&chip->reg_lock);
755
756 if (err)
757 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
758}
759
760static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
761 unsigned int mode,
762 phy_interface_t interface)
763{
764 if (mode == MLO_AN_FIXED)
765 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
766}
767
768static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
769 unsigned int mode, phy_interface_t interface,
770 struct phy_device *phydev)
771{
772 if (mode == MLO_AN_FIXED)
773 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
774}
775
Andrew Lunna605a0f2016-11-21 23:26:58 +0100776static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000777{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100778 if (!chip->info->ops->stats_snapshot)
779 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000780
Andrew Lunna605a0f2016-11-21 23:26:58 +0100781 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000782}
783
Andrew Lunne413e7e2015-04-02 04:06:38 +0200784static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100785 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
786 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
787 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
788 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
789 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
790 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
791 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
792 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
793 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
794 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
795 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
796 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
797 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
798 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
799 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
800 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
801 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
802 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
803 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
804 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
805 { "single", 4, 0x14, STATS_TYPE_BANK0, },
806 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
807 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
808 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
809 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
810 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
811 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
812 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
813 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
814 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
815 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
816 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
817 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
818 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
819 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
820 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
821 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
822 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
823 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
824 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
825 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
826 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
827 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
828 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
829 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
830 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
831 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
832 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
833 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
834 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
835 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
836 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
837 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
838 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
839 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
840 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
841 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
842 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
843 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200844};
845
Vivien Didelotfad09c72016-06-21 12:28:20 -0400846static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100847 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100848 int port, u16 bank1_select,
849 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200850{
Andrew Lunn80c46272015-06-20 18:42:30 +0200851 u32 low;
852 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100853 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200854 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200855 u64 value;
856
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100857 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100858 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200859 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
860 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800861 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200862
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200863 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100864 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200865 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
866 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800867 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200868 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200869 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100870 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100871 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100872 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100873 /* fall through */
874 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100875 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100876 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100877 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100878 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500879 break;
880 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800881 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200882 }
883 value = (((u64)high) << 16) | low;
884 return value;
885}
886
Andrew Lunn436fe172018-03-01 02:02:29 +0100887static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
888 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100889{
890 struct mv88e6xxx_hw_stat *stat;
891 int i, j;
892
893 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
894 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100895 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100896 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
897 ETH_GSTRING_LEN);
898 j++;
899 }
900 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100901
902 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100903}
904
Andrew Lunn436fe172018-03-01 02:02:29 +0100905static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
906 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100907{
Andrew Lunn436fe172018-03-01 02:02:29 +0100908 return mv88e6xxx_stats_get_strings(chip, data,
909 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100910}
911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
913 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100914{
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 return mv88e6xxx_stats_get_strings(chip, data,
916 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100917}
918
Andrew Lunn65f60e42018-03-28 23:50:28 +0200919static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
920 "atu_member_violation",
921 "atu_miss_violation",
922 "atu_full_violation",
923 "vtu_member_violation",
924 "vtu_miss_violation",
925};
926
927static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
928{
929 unsigned int i;
930
931 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
932 strlcpy(data + i * ETH_GSTRING_LEN,
933 mv88e6xxx_atu_vtu_stats_strings[i],
934 ETH_GSTRING_LEN);
935}
936
Andrew Lunndfafe442016-11-21 23:27:02 +0100937static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700938 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100939{
Vivien Didelot04bed142016-08-31 18:06:13 -0400940 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100941 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100942
Florian Fainelli89f09042018-04-25 12:12:50 -0700943 if (stringset != ETH_SS_STATS)
944 return;
945
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100946 mutex_lock(&chip->reg_lock);
947
Andrew Lunndfafe442016-11-21 23:27:02 +0100948 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100949 count = chip->info->ops->stats_get_strings(chip, data);
950
951 if (chip->info->ops->serdes_get_strings) {
952 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200953 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100954 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100955
Andrew Lunn65f60e42018-03-28 23:50:28 +0200956 data += count * ETH_GSTRING_LEN;
957 mv88e6xxx_atu_vtu_get_strings(data);
958
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100959 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100960}
961
962static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
963 int types)
964{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100965 struct mv88e6xxx_hw_stat *stat;
966 int i, j;
967
968 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
969 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100970 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100971 j++;
972 }
973 return j;
974}
975
Andrew Lunndfafe442016-11-21 23:27:02 +0100976static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
977{
978 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
979 STATS_TYPE_PORT);
980}
981
982static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
983{
984 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
985 STATS_TYPE_BANK1);
986}
987
Florian Fainelli89f09042018-04-25 12:12:50 -0700988static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100989{
990 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100991 int serdes_count = 0;
992 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100993
Florian Fainelli89f09042018-04-25 12:12:50 -0700994 if (sset != ETH_SS_STATS)
995 return 0;
996
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100997 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100998 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100999 count = chip->info->ops->stats_get_sset_count(chip);
1000 if (count < 0)
1001 goto out;
1002
1003 if (chip->info->ops->serdes_get_sset_count)
1004 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1005 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001006 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001007 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001008 goto out;
1009 }
1010 count += serdes_count;
1011 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1012
Andrew Lunn436fe172018-03-01 02:02:29 +01001013out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001014 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001015
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001017}
1018
Andrew Lunn436fe172018-03-01 02:02:29 +01001019static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1020 uint64_t *data, int types,
1021 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001022{
1023 struct mv88e6xxx_hw_stat *stat;
1024 int i, j;
1025
1026 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1027 stat = &mv88e6xxx_hw_stats[i];
1028 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001029 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001030 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1031 bank1_select,
1032 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001033 mutex_unlock(&chip->reg_lock);
1034
Andrew Lunn052f9472016-11-21 23:27:03 +01001035 j++;
1036 }
1037 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001038 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001039}
1040
Andrew Lunn436fe172018-03-01 02:02:29 +01001041static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1042 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001043{
1044 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001045 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001046 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001047}
1048
Andrew Lunn436fe172018-03-01 02:02:29 +01001049static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1050 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001051{
1052 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001053 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001054 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1055 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001056}
1057
Andrew Lunn436fe172018-03-01 02:02:29 +01001058static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1059 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001060{
1061 return mv88e6xxx_stats_get_stats(chip, port, data,
1062 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001063 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1064 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001065}
1066
Andrew Lunn65f60e42018-03-28 23:50:28 +02001067static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1068 uint64_t *data)
1069{
1070 *data++ = chip->ports[port].atu_member_violation;
1071 *data++ = chip->ports[port].atu_miss_violation;
1072 *data++ = chip->ports[port].atu_full_violation;
1073 *data++ = chip->ports[port].vtu_member_violation;
1074 *data++ = chip->ports[port].vtu_miss_violation;
1075}
1076
Andrew Lunn052f9472016-11-21 23:27:03 +01001077static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1078 uint64_t *data)
1079{
Andrew Lunn436fe172018-03-01 02:02:29 +01001080 int count = 0;
1081
Andrew Lunn052f9472016-11-21 23:27:03 +01001082 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001083 count = chip->info->ops->stats_get_stats(chip, port, data);
1084
Andrew Lunn65f60e42018-03-28 23:50:28 +02001085 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001086 if (chip->info->ops->serdes_get_stats) {
1087 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001088 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001089 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001090 data += count;
1091 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1092 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001093}
1094
Vivien Didelotf81ec902016-05-09 13:22:58 -04001095static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1096 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001097{
Vivien Didelot04bed142016-08-31 18:06:13 -04001098 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001099 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001100
Vivien Didelotfad09c72016-06-21 12:28:20 -04001101 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001102
Andrew Lunna605a0f2016-11-21 23:26:58 +01001103 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001104 mutex_unlock(&chip->reg_lock);
1105
1106 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001107 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001108
1109 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001110
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001111}
Ben Hutchings98e67302011-11-25 14:36:19 +00001112
Vivien Didelotf81ec902016-05-09 13:22:58 -04001113static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001114{
1115 return 32 * sizeof(u16);
1116}
1117
Vivien Didelotf81ec902016-05-09 13:22:58 -04001118static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1119 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001120{
Vivien Didelot04bed142016-08-31 18:06:13 -04001121 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001122 int err;
1123 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001124 u16 *p = _p;
1125 int i;
1126
1127 regs->version = 0;
1128
1129 memset(p, 0xff, 32 * sizeof(u16));
1130
Vivien Didelotfad09c72016-06-21 12:28:20 -04001131 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001132
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001133 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001134
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001135 err = mv88e6xxx_port_read(chip, port, i, &reg);
1136 if (!err)
1137 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138 }
Vivien Didelot23062512016-05-09 13:22:45 -04001139
Vivien Didelotfad09c72016-06-21 12:28:20 -04001140 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001141}
1142
Vivien Didelot08f50062017-08-01 16:32:41 -04001143static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1144 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001145{
Vivien Didelot5480db62017-08-01 16:32:40 -04001146 /* Nothing to do on the port's MAC */
1147 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001148}
1149
Vivien Didelot08f50062017-08-01 16:32:41 -04001150static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1151 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001152{
Vivien Didelot5480db62017-08-01 16:32:40 -04001153 /* Nothing to do on the port's MAC */
1154 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001155}
1156
Vivien Didelote5887a22017-03-30 17:37:11 -04001157static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001158{
Vivien Didelote5887a22017-03-30 17:37:11 -04001159 struct dsa_switch *ds = NULL;
1160 struct net_device *br;
1161 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001162 int i;
1163
Vivien Didelote5887a22017-03-30 17:37:11 -04001164 if (dev < DSA_MAX_SWITCHES)
1165 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001166
Vivien Didelote5887a22017-03-30 17:37:11 -04001167 /* Prevent frames from unknown switch or port */
1168 if (!ds || port >= ds->num_ports)
1169 return 0;
1170
1171 /* Frames from DSA links and CPU ports can egress any local port */
1172 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1173 return mv88e6xxx_port_mask(chip);
1174
1175 br = ds->ports[port].bridge_dev;
1176 pvlan = 0;
1177
1178 /* Frames from user ports can egress any local DSA links and CPU ports,
1179 * as well as any local member of their bridge group.
1180 */
1181 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1182 if (dsa_is_cpu_port(chip->ds, i) ||
1183 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001184 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001185 pvlan |= BIT(i);
1186
1187 return pvlan;
1188}
1189
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001190static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001191{
1192 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001193
1194 /* prevent frames from going back out of the port they came in on */
1195 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001196
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001197 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001198}
1199
Vivien Didelotf81ec902016-05-09 13:22:58 -04001200static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1201 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001202{
Vivien Didelot04bed142016-08-31 18:06:13 -04001203 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001204 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001205
Vivien Didelotfad09c72016-06-21 12:28:20 -04001206 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001207 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001208 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001209
1210 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001211 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001212}
1213
Vivien Didelot93e18d62018-05-11 17:16:35 -04001214static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1215{
1216 int err;
1217
1218 if (chip->info->ops->ieee_pri_map) {
1219 err = chip->info->ops->ieee_pri_map(chip);
1220 if (err)
1221 return err;
1222 }
1223
1224 if (chip->info->ops->ip_pri_map) {
1225 err = chip->info->ops->ip_pri_map(chip);
1226 if (err)
1227 return err;
1228 }
1229
1230 return 0;
1231}
1232
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001233static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1234{
1235 int target, port;
1236 int err;
1237
1238 if (!chip->info->global2_addr)
1239 return 0;
1240
1241 /* Initialize the routing port to the 32 possible target devices */
1242 for (target = 0; target < 32; target++) {
1243 port = 0x1f;
1244 if (target < DSA_MAX_SWITCHES)
1245 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1246 port = chip->ds->rtable[target];
1247
1248 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1249 if (err)
1250 return err;
1251 }
1252
Vivien Didelot02317e62018-05-09 11:38:49 -04001253 if (chip->info->ops->set_cascade_port) {
1254 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1255 err = chip->info->ops->set_cascade_port(chip, port);
1256 if (err)
1257 return err;
1258 }
1259
Vivien Didelot23c98912018-05-09 11:38:50 -04001260 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1261 if (err)
1262 return err;
1263
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001264 return 0;
1265}
1266
Vivien Didelotb28f8722018-04-26 21:56:44 -04001267static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1268{
1269 /* Clear all trunk masks and mapping */
1270 if (chip->info->global2_addr)
1271 return mv88e6xxx_g2_trunk_clear(chip);
1272
1273 return 0;
1274}
1275
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001276static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1277{
1278 if (chip->info->ops->rmu_disable)
1279 return chip->info->ops->rmu_disable(chip);
1280
1281 return 0;
1282}
1283
Vivien Didelot9e907d72017-07-17 13:03:43 -04001284static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1285{
1286 if (chip->info->ops->pot_clear)
1287 return chip->info->ops->pot_clear(chip);
1288
1289 return 0;
1290}
1291
Vivien Didelot51c901a2017-07-17 13:03:41 -04001292static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1293{
1294 if (chip->info->ops->mgmt_rsvd2cpu)
1295 return chip->info->ops->mgmt_rsvd2cpu(chip);
1296
1297 return 0;
1298}
1299
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001300static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1301{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001302 int err;
1303
Vivien Didelotdaefc942017-03-11 16:12:54 -05001304 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1305 if (err)
1306 return err;
1307
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001308 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1309 if (err)
1310 return err;
1311
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001312 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1313}
1314
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001315static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1316{
1317 int port;
1318 int err;
1319
1320 if (!chip->info->ops->irl_init_all)
1321 return 0;
1322
1323 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1324 /* Disable ingress rate limiting by resetting all per port
1325 * ingress rate limit resources to their initial state.
1326 */
1327 err = chip->info->ops->irl_init_all(chip, port);
1328 if (err)
1329 return err;
1330 }
1331
1332 return 0;
1333}
1334
Vivien Didelot04a69a12017-10-13 14:18:05 -04001335static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1336{
1337 if (chip->info->ops->set_switch_mac) {
1338 u8 addr[ETH_ALEN];
1339
1340 eth_random_addr(addr);
1341
1342 return chip->info->ops->set_switch_mac(chip, addr);
1343 }
1344
1345 return 0;
1346}
1347
Vivien Didelot17a15942017-03-30 17:37:09 -04001348static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1349{
1350 u16 pvlan = 0;
1351
1352 if (!mv88e6xxx_has_pvt(chip))
1353 return -EOPNOTSUPP;
1354
1355 /* Skip the local source device, which uses in-chip port VLAN */
1356 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001357 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001358
1359 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1360}
1361
Vivien Didelot81228992017-03-30 17:37:08 -04001362static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1363{
Vivien Didelot17a15942017-03-30 17:37:09 -04001364 int dev, port;
1365 int err;
1366
Vivien Didelot81228992017-03-30 17:37:08 -04001367 if (!mv88e6xxx_has_pvt(chip))
1368 return 0;
1369
1370 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1371 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1372 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001373 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1374 if (err)
1375 return err;
1376
1377 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1378 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1379 err = mv88e6xxx_pvt_map(chip, dev, port);
1380 if (err)
1381 return err;
1382 }
1383 }
1384
1385 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001386}
1387
Vivien Didelot749efcb2016-09-22 16:49:24 -04001388static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1389{
1390 struct mv88e6xxx_chip *chip = ds->priv;
1391 int err;
1392
1393 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001394 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001395 mutex_unlock(&chip->reg_lock);
1396
1397 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001398 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001399}
1400
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001401static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1402{
1403 if (!chip->info->max_vid)
1404 return 0;
1405
1406 return mv88e6xxx_g1_vtu_flush(chip);
1407}
1408
Vivien Didelotf1394b782017-05-01 14:05:22 -04001409static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1410 struct mv88e6xxx_vtu_entry *entry)
1411{
1412 if (!chip->info->ops->vtu_getnext)
1413 return -EOPNOTSUPP;
1414
1415 return chip->info->ops->vtu_getnext(chip, entry);
1416}
1417
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001418static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1419 struct mv88e6xxx_vtu_entry *entry)
1420{
1421 if (!chip->info->ops->vtu_loadpurge)
1422 return -EOPNOTSUPP;
1423
1424 return chip->info->ops->vtu_loadpurge(chip, entry);
1425}
1426
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001427static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001428{
1429 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001430 struct mv88e6xxx_vtu_entry vlan = {
1431 .vid = chip->info->max_vid,
1432 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001433 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001434
1435 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1436
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001437 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001438 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001439 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001440 if (err)
1441 return err;
1442
1443 set_bit(*fid, fid_bitmap);
1444 }
1445
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001446 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001447 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001448 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001449 if (err)
1450 return err;
1451
1452 if (!vlan.valid)
1453 break;
1454
1455 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001456 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001457
1458 /* The reset value 0x000 is used to indicate that multiple address
1459 * databases are not needed. Return the next positive available.
1460 */
1461 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001462 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001463 return -ENOSPC;
1464
1465 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001466 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001467}
1468
Vivien Didelot567aa592017-05-01 14:05:25 -04001469static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1470 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001471{
1472 int err;
1473
1474 if (!vid)
1475 return -EINVAL;
1476
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001477 entry->vid = vid - 1;
1478 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001479
Vivien Didelotf1394b782017-05-01 14:05:22 -04001480 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001481 if (err)
1482 return err;
1483
Vivien Didelot567aa592017-05-01 14:05:25 -04001484 if (entry->vid == vid && entry->valid)
1485 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001486
Vivien Didelot567aa592017-05-01 14:05:25 -04001487 if (new) {
1488 int i;
1489
1490 /* Initialize a fresh VLAN entry */
1491 memset(entry, 0, sizeof(*entry));
1492 entry->valid = true;
1493 entry->vid = vid;
1494
Vivien Didelot553a7682017-06-07 18:12:16 -04001495 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001496 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001497 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001498 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001499
1500 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001501 }
1502
Vivien Didelot567aa592017-05-01 14:05:25 -04001503 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1504 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001505}
1506
Vivien Didelotda9c3592016-02-12 12:09:40 -05001507static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1508 u16 vid_begin, u16 vid_end)
1509{
Vivien Didelot04bed142016-08-31 18:06:13 -04001510 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001511 struct mv88e6xxx_vtu_entry vlan = {
1512 .vid = vid_begin - 1,
1513 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001514 int i, err;
1515
Andrew Lunndb06ae412017-09-25 23:32:20 +02001516 /* DSA and CPU ports have to be members of multiple vlans */
1517 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1518 return 0;
1519
Vivien Didelotda9c3592016-02-12 12:09:40 -05001520 if (!vid_begin)
1521 return -EOPNOTSUPP;
1522
Vivien Didelotfad09c72016-06-21 12:28:20 -04001523 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001524
Vivien Didelotda9c3592016-02-12 12:09:40 -05001525 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001526 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001527 if (err)
1528 goto unlock;
1529
1530 if (!vlan.valid)
1531 break;
1532
1533 if (vlan.vid > vid_end)
1534 break;
1535
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001536 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001537 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1538 continue;
1539
Andrew Lunncd886462017-11-09 22:29:53 +01001540 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001541 continue;
1542
Vivien Didelotbd00e052017-05-01 14:05:11 -04001543 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001544 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545 continue;
1546
Vivien Didelotc8652c82017-10-16 11:12:19 -04001547 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001548 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001549 break; /* same bridge, check next VLAN */
1550
Vivien Didelotc8652c82017-10-16 11:12:19 -04001551 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001552 continue;
1553
Andrew Lunn743fcc22017-11-09 22:29:54 +01001554 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1555 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001556 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001557 err = -EOPNOTSUPP;
1558 goto unlock;
1559 }
1560 } while (vlan.vid < vid_end);
1561
1562unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001563 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001564
1565 return err;
1566}
1567
Vivien Didelotf81ec902016-05-09 13:22:58 -04001568static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1569 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001570{
Vivien Didelot04bed142016-08-31 18:06:13 -04001571 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001572 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1573 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001574 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001575
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001576 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001577 return -EOPNOTSUPP;
1578
Vivien Didelotfad09c72016-06-21 12:28:20 -04001579 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001580 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001581 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001582
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001583 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001584}
1585
Vivien Didelot57d32312016-06-20 13:13:58 -04001586static int
1587mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001588 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001589{
Vivien Didelot04bed142016-08-31 18:06:13 -04001590 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001591 int err;
1592
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001593 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001594 return -EOPNOTSUPP;
1595
Vivien Didelotda9c3592016-02-12 12:09:40 -05001596 /* If the requested port doesn't belong to the same bridge as the VLAN
1597 * members, do not support it (yet) and fallback to software VLAN.
1598 */
1599 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1600 vlan->vid_end);
1601 if (err)
1602 return err;
1603
Vivien Didelot76e398a2015-11-01 12:33:55 -05001604 /* We don't need any dynamic resource from the kernel (yet),
1605 * so skip the prepare phase.
1606 */
1607 return 0;
1608}
1609
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001610static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1611 const unsigned char *addr, u16 vid,
1612 u8 state)
1613{
1614 struct mv88e6xxx_vtu_entry vlan;
1615 struct mv88e6xxx_atu_entry entry;
1616 int err;
1617
1618 /* Null VLAN ID corresponds to the port private database */
1619 if (vid == 0)
1620 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1621 else
1622 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1623 if (err)
1624 return err;
1625
1626 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1627 ether_addr_copy(entry.mac, addr);
1628 eth_addr_dec(entry.mac);
1629
1630 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1631 if (err)
1632 return err;
1633
1634 /* Initialize a fresh ATU entry if it isn't found */
1635 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1636 !ether_addr_equal(entry.mac, addr)) {
1637 memset(&entry, 0, sizeof(entry));
1638 ether_addr_copy(entry.mac, addr);
1639 }
1640
1641 /* Purge the ATU entry only if no port is using it anymore */
1642 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1643 entry.portvec &= ~BIT(port);
1644 if (!entry.portvec)
1645 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1646 } else {
1647 entry.portvec |= BIT(port);
1648 entry.state = state;
1649 }
1650
1651 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1652}
1653
Andrew Lunn87fa8862017-11-09 22:29:56 +01001654static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1655 u16 vid)
1656{
1657 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1658 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1659
1660 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1661}
1662
1663static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1664{
1665 int port;
1666 int err;
1667
1668 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1669 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1670 if (err)
1671 return err;
1672 }
1673
1674 return 0;
1675}
1676
Vivien Didelotfad09c72016-06-21 12:28:20 -04001677static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001678 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001679{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001680 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001681 int err;
1682
Vivien Didelot567aa592017-05-01 14:05:25 -04001683 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001684 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001685 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001686
Vivien Didelotc91498e2017-06-07 18:12:13 -04001687 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001688
Andrew Lunn87fa8862017-11-09 22:29:56 +01001689 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1690 if (err)
1691 return err;
1692
1693 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001694}
1695
Vivien Didelotf81ec902016-05-09 13:22:58 -04001696static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001697 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001698{
Vivien Didelot04bed142016-08-31 18:06:13 -04001699 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001700 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1701 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001702 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001703 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001704
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001705 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001706 return;
1707
Vivien Didelotc91498e2017-06-07 18:12:13 -04001708 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001709 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001710 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001711 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001712 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001713 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001714
Vivien Didelotfad09c72016-06-21 12:28:20 -04001715 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001716
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001717 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001718 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001719 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1720 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001721
Vivien Didelot77064f32016-11-04 03:23:30 +01001722 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001723 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1724 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001725
Vivien Didelotfad09c72016-06-21 12:28:20 -04001726 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001727}
1728
Vivien Didelotfad09c72016-06-21 12:28:20 -04001729static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001730 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001731{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001732 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001733 int i, err;
1734
Vivien Didelot567aa592017-05-01 14:05:25 -04001735 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001736 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001737 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001738
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001739 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001740 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001741 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001742
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001743 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001744
1745 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001746 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001747 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001748 if (vlan.member[i] !=
1749 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001750 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001751 break;
1752 }
1753 }
1754
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001755 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001756 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001757 return err;
1758
Vivien Didelote606ca32017-03-11 16:12:55 -05001759 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001760}
1761
Vivien Didelotf81ec902016-05-09 13:22:58 -04001762static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1763 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001764{
Vivien Didelot04bed142016-08-31 18:06:13 -04001765 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001766 u16 pvid, vid;
1767 int err = 0;
1768
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001769 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001770 return -EOPNOTSUPP;
1771
Vivien Didelotfad09c72016-06-21 12:28:20 -04001772 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001773
Vivien Didelot77064f32016-11-04 03:23:30 +01001774 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001775 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001776 goto unlock;
1777
Vivien Didelot76e398a2015-11-01 12:33:55 -05001778 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001779 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001780 if (err)
1781 goto unlock;
1782
1783 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001784 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001785 if (err)
1786 goto unlock;
1787 }
1788 }
1789
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001790unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001791 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001792
1793 return err;
1794}
1795
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001796static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1797 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001798{
Vivien Didelot04bed142016-08-31 18:06:13 -04001799 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001800 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001801
Vivien Didelotfad09c72016-06-21 12:28:20 -04001802 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001803 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1804 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001805 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001806
1807 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001808}
1809
Vivien Didelotf81ec902016-05-09 13:22:58 -04001810static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001811 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001812{
Vivien Didelot04bed142016-08-31 18:06:13 -04001813 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001814 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001815
Vivien Didelotfad09c72016-06-21 12:28:20 -04001816 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001817 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001818 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001819 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001820
Vivien Didelot83dabd12016-08-31 11:50:04 -04001821 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001822}
1823
Vivien Didelot83dabd12016-08-31 11:50:04 -04001824static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1825 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001826 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001827{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001828 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001829 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001830 int err;
1831
Vivien Didelot27c0e602017-06-15 12:14:01 -04001832 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001833 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001834
1835 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001836 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001837 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001838 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001839 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001840 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001841
Vivien Didelot27c0e602017-06-15 12:14:01 -04001842 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001843 break;
1844
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001845 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001846 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001847
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001848 if (!is_unicast_ether_addr(addr.mac))
1849 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001850
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001851 is_static = (addr.state ==
1852 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1853 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001854 if (err)
1855 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001856 } while (!is_broadcast_ether_addr(addr.mac));
1857
1858 return err;
1859}
1860
Vivien Didelot83dabd12016-08-31 11:50:04 -04001861static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001862 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001863{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001864 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001865 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001866 };
1867 u16 fid;
1868 int err;
1869
1870 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001871 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001872 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001873 mutex_unlock(&chip->reg_lock);
1874
Vivien Didelot83dabd12016-08-31 11:50:04 -04001875 if (err)
1876 return err;
1877
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001878 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001879 if (err)
1880 return err;
1881
1882 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001883 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001884 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001885 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001886 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001887 if (err)
1888 return err;
1889
1890 if (!vlan.valid)
1891 break;
1892
1893 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001894 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001895 if (err)
1896 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001897 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001898
1899 return err;
1900}
1901
Vivien Didelotf81ec902016-05-09 13:22:58 -04001902static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001903 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001904{
Vivien Didelot04bed142016-08-31 18:06:13 -04001905 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001906
Andrew Lunna61e5402018-02-15 14:38:35 +01001907 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001908}
1909
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001910static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1911 struct net_device *br)
1912{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001913 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001914 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001915 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001916 int err;
1917
1918 /* Remap the Port VLAN of each local bridge group member */
1919 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1920 if (chip->ds->ports[port].bridge_dev == br) {
1921 err = mv88e6xxx_port_vlan_map(chip, port);
1922 if (err)
1923 return err;
1924 }
1925 }
1926
Vivien Didelote96a6e02017-03-30 17:37:13 -04001927 if (!mv88e6xxx_has_pvt(chip))
1928 return 0;
1929
1930 /* Remap the Port VLAN of each cross-chip bridge group member */
1931 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1932 ds = chip->ds->dst->ds[dev];
1933 if (!ds)
1934 break;
1935
1936 for (port = 0; port < ds->num_ports; ++port) {
1937 if (ds->ports[port].bridge_dev == br) {
1938 err = mv88e6xxx_pvt_map(chip, dev, port);
1939 if (err)
1940 return err;
1941 }
1942 }
1943 }
1944
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001945 return 0;
1946}
1947
Vivien Didelotf81ec902016-05-09 13:22:58 -04001948static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001949 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001950{
Vivien Didelot04bed142016-08-31 18:06:13 -04001951 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001952 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001953
Vivien Didelotfad09c72016-06-21 12:28:20 -04001954 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001955 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001956 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001957
Vivien Didelot466dfa02016-02-26 13:16:05 -05001958 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001959}
1960
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001961static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1962 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001963{
Vivien Didelot04bed142016-08-31 18:06:13 -04001964 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001965
Vivien Didelotfad09c72016-06-21 12:28:20 -04001966 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001967 if (mv88e6xxx_bridge_map(chip, br) ||
1968 mv88e6xxx_port_vlan_map(chip, port))
1969 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001970 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001971}
1972
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001973static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1974 int port, struct net_device *br)
1975{
1976 struct mv88e6xxx_chip *chip = ds->priv;
1977 int err;
1978
1979 if (!mv88e6xxx_has_pvt(chip))
1980 return 0;
1981
1982 mutex_lock(&chip->reg_lock);
1983 err = mv88e6xxx_pvt_map(chip, dev, port);
1984 mutex_unlock(&chip->reg_lock);
1985
1986 return err;
1987}
1988
1989static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1990 int port, struct net_device *br)
1991{
1992 struct mv88e6xxx_chip *chip = ds->priv;
1993
1994 if (!mv88e6xxx_has_pvt(chip))
1995 return;
1996
1997 mutex_lock(&chip->reg_lock);
1998 if (mv88e6xxx_pvt_map(chip, dev, port))
1999 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2000 mutex_unlock(&chip->reg_lock);
2001}
2002
Vivien Didelot17e708b2016-12-05 17:30:27 -05002003static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2004{
2005 if (chip->info->ops->reset)
2006 return chip->info->ops->reset(chip);
2007
2008 return 0;
2009}
2010
Vivien Didelot309eca62016-12-05 17:30:26 -05002011static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2012{
2013 struct gpio_desc *gpiod = chip->reset;
2014
2015 /* If there is a GPIO connected to the reset pin, toggle it */
2016 if (gpiod) {
2017 gpiod_set_value_cansleep(gpiod, 1);
2018 usleep_range(10000, 20000);
2019 gpiod_set_value_cansleep(gpiod, 0);
2020 usleep_range(10000, 20000);
2021 }
2022}
2023
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002024static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2025{
2026 int i, err;
2027
2028 /* Set all ports to the Disabled state */
2029 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002030 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002031 if (err)
2032 return err;
2033 }
2034
2035 /* Wait for transmit queues to drain,
2036 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2037 */
2038 usleep_range(2000, 4000);
2039
2040 return 0;
2041}
2042
Vivien Didelotfad09c72016-06-21 12:28:20 -04002043static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002044{
Vivien Didelota935c052016-09-29 12:21:53 -04002045 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002046
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002047 err = mv88e6xxx_disable_ports(chip);
2048 if (err)
2049 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002050
Vivien Didelot309eca62016-12-05 17:30:26 -05002051 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002052
Vivien Didelot17e708b2016-12-05 17:30:27 -05002053 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002054}
2055
Vivien Didelot43145572017-03-11 16:12:59 -05002056static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002057 enum mv88e6xxx_frame_mode frame,
2058 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002059{
2060 int err;
2061
Vivien Didelot43145572017-03-11 16:12:59 -05002062 if (!chip->info->ops->port_set_frame_mode)
2063 return -EOPNOTSUPP;
2064
2065 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002066 if (err)
2067 return err;
2068
Vivien Didelot43145572017-03-11 16:12:59 -05002069 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2070 if (err)
2071 return err;
2072
2073 if (chip->info->ops->port_set_ether_type)
2074 return chip->info->ops->port_set_ether_type(chip, port, etype);
2075
2076 return 0;
2077}
2078
2079static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2080{
2081 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002082 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002083 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002084}
2085
2086static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2087{
2088 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002089 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002090 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002091}
2092
2093static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2094{
2095 return mv88e6xxx_set_port_mode(chip, port,
2096 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002097 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2098 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002099}
2100
2101static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2102{
2103 if (dsa_is_dsa_port(chip->ds, port))
2104 return mv88e6xxx_set_port_mode_dsa(chip, port);
2105
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002106 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002107 return mv88e6xxx_set_port_mode_normal(chip, port);
2108
2109 /* Setup CPU port mode depending on its supported tag format */
2110 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2111 return mv88e6xxx_set_port_mode_dsa(chip, port);
2112
2113 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2114 return mv88e6xxx_set_port_mode_edsa(chip, port);
2115
2116 return -EINVAL;
2117}
2118
Vivien Didelotea698f42017-03-11 16:12:50 -05002119static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2120{
2121 bool message = dsa_is_dsa_port(chip->ds, port);
2122
2123 return mv88e6xxx_port_set_message_port(chip, port, message);
2124}
2125
Vivien Didelot601aeed2017-03-11 16:13:00 -05002126static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2127{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002128 struct dsa_switch *ds = chip->ds;
2129 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002130
2131 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002132 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002133 if (chip->info->ops->port_set_egress_floods)
2134 return chip->info->ops->port_set_egress_floods(chip, port,
2135 flood, flood);
2136
2137 return 0;
2138}
2139
Andrew Lunn6d917822017-05-26 01:03:21 +02002140static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2141 bool on)
2142{
Vivien Didelot523a8902017-05-26 18:02:42 -04002143 if (chip->info->ops->serdes_power)
2144 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002145
Vivien Didelot523a8902017-05-26 18:02:42 -04002146 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002147}
2148
Vivien Didelotfa371c82017-12-05 15:34:10 -05002149static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2150{
2151 struct dsa_switch *ds = chip->ds;
2152 int upstream_port;
2153 int err;
2154
Vivien Didelot07073c72017-12-05 15:34:13 -05002155 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002156 if (chip->info->ops->port_set_upstream_port) {
2157 err = chip->info->ops->port_set_upstream_port(chip, port,
2158 upstream_port);
2159 if (err)
2160 return err;
2161 }
2162
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002163 if (port == upstream_port) {
2164 if (chip->info->ops->set_cpu_port) {
2165 err = chip->info->ops->set_cpu_port(chip,
2166 upstream_port);
2167 if (err)
2168 return err;
2169 }
2170
2171 if (chip->info->ops->set_egress_port) {
2172 err = chip->info->ops->set_egress_port(chip,
2173 upstream_port);
2174 if (err)
2175 return err;
2176 }
2177 }
2178
Vivien Didelotfa371c82017-12-05 15:34:10 -05002179 return 0;
2180}
2181
Vivien Didelotfad09c72016-06-21 12:28:20 -04002182static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002183{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002184 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002185 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002186 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002187
Andrew Lunn7b898462018-08-09 15:38:47 +02002188 chip->ports[port].chip = chip;
2189 chip->ports[port].port = port;
2190
Vivien Didelotd78343d2016-11-04 03:23:36 +01002191 /* MAC Forcing register: don't force link, speed, duplex or flow control
2192 * state to any particular values on physical ports, but force the CPU
2193 * port and all DSA ports to their maximum bandwidth and full duplex.
2194 */
2195 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2196 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2197 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002198 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002199 PHY_INTERFACE_MODE_NA);
2200 else
2201 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2202 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002203 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002204 PHY_INTERFACE_MODE_NA);
2205 if (err)
2206 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002207
2208 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2209 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2210 * tunneling, determine priority by looking at 802.1p and IP
2211 * priority fields (IP prio has precedence), and set STP state
2212 * to Forwarding.
2213 *
2214 * If this is the CPU link, use DSA or EDSA tagging depending
2215 * on which tagging mode was configured.
2216 *
2217 * If this is a link to another switch, use DSA tagging mode.
2218 *
2219 * If this is the upstream port for this switch, enable
2220 * forwarding of unknown unicasts and multicasts.
2221 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002222 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2223 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2224 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2225 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002226 if (err)
2227 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002228
Vivien Didelot601aeed2017-03-11 16:13:00 -05002229 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002230 if (err)
2231 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002232
Vivien Didelot601aeed2017-03-11 16:13:00 -05002233 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002234 if (err)
2235 return err;
2236
Andrew Lunn04aca992017-05-26 01:03:24 +02002237 /* Enable the SERDES interface for DSA and CPU ports. Normal
2238 * ports SERDES are enabled when the port is enabled, thus
2239 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002240 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002241 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2242 err = mv88e6xxx_serdes_power(chip, port, true);
2243 if (err)
2244 return err;
2245 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002246
Vivien Didelot8efdda42015-08-13 12:52:23 -04002247 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002248 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002249 * untagged frames on this port, do a destination address lookup on all
2250 * received packets as usual, disable ARP mirroring and don't send a
2251 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002252 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002253 err = mv88e6xxx_port_set_map_da(chip, port);
2254 if (err)
2255 return err;
2256
Vivien Didelotfa371c82017-12-05 15:34:10 -05002257 err = mv88e6xxx_setup_upstream_port(chip, port);
2258 if (err)
2259 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002260
Andrew Lunna23b2962017-02-04 20:15:28 +01002261 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002262 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002263 if (err)
2264 return err;
2265
Vivien Didelotcd782652017-06-08 18:34:13 -04002266 if (chip->info->ops->port_set_jumbo_size) {
2267 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002268 if (err)
2269 return err;
2270 }
2271
Andrew Lunn54d792f2015-05-06 01:09:47 +02002272 /* Port Association Vector: when learning source addresses
2273 * of packets, add the address to the address database using
2274 * a port bitmap that has only the bit for this port set and
2275 * the other bits clear.
2276 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002277 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002278 /* Disable learning for CPU port */
2279 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002280 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002281
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002282 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2283 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002284 if (err)
2285 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002286
2287 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002288 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2289 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002290 if (err)
2291 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002292
Vivien Didelot08984322017-06-08 18:34:12 -04002293 if (chip->info->ops->port_pause_limit) {
2294 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002295 if (err)
2296 return err;
2297 }
2298
Vivien Didelotc8c94892017-03-11 16:13:01 -05002299 if (chip->info->ops->port_disable_learn_limit) {
2300 err = chip->info->ops->port_disable_learn_limit(chip, port);
2301 if (err)
2302 return err;
2303 }
2304
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002305 if (chip->info->ops->port_disable_pri_override) {
2306 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002307 if (err)
2308 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002309 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002310
Andrew Lunnef0a7312016-12-03 04:35:16 +01002311 if (chip->info->ops->port_tag_remap) {
2312 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002313 if (err)
2314 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002315 }
2316
Andrew Lunnef70b112016-12-03 04:45:18 +01002317 if (chip->info->ops->port_egress_rate_limiting) {
2318 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002319 if (err)
2320 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002321 }
2322
Vivien Didelotea698f42017-03-11 16:12:50 -05002323 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002324 if (err)
2325 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002326
Vivien Didelot207afda2016-04-14 14:42:09 -04002327 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002328 * database, and allow bidirectional communication between the
2329 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002330 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002331 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002332 if (err)
2333 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002334
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002335 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002336 if (err)
2337 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002338
2339 /* Default VLAN ID and priority: don't set a default VLAN
2340 * ID, and set the default packet priority to zero.
2341 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002342 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002343}
2344
Andrew Lunn04aca992017-05-26 01:03:24 +02002345static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2346 struct phy_device *phydev)
2347{
2348 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002349 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002350
2351 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002352
Vivien Didelot523a8902017-05-26 18:02:42 -04002353 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002354
2355 if (!err && chip->info->ops->serdes_irq_setup)
2356 err = chip->info->ops->serdes_irq_setup(chip, port);
2357
Andrew Lunn04aca992017-05-26 01:03:24 +02002358 mutex_unlock(&chip->reg_lock);
2359
2360 return err;
2361}
2362
2363static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2364 struct phy_device *phydev)
2365{
2366 struct mv88e6xxx_chip *chip = ds->priv;
2367
2368 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002369
2370 if (chip->info->ops->serdes_irq_free)
2371 chip->info->ops->serdes_irq_free(chip, port);
2372
Vivien Didelot523a8902017-05-26 18:02:42 -04002373 if (mv88e6xxx_serdes_power(chip, port, false))
2374 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002375
Andrew Lunn04aca992017-05-26 01:03:24 +02002376 mutex_unlock(&chip->reg_lock);
2377}
2378
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002379static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2380 unsigned int ageing_time)
2381{
Vivien Didelot04bed142016-08-31 18:06:13 -04002382 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002383 int err;
2384
2385 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002386 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002387 mutex_unlock(&chip->reg_lock);
2388
2389 return err;
2390}
2391
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002392static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002393{
2394 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002395
Andrew Lunnde2273872016-11-21 23:27:01 +01002396 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002397 if (chip->info->ops->stats_set_histogram) {
2398 err = chip->info->ops->stats_set_histogram(chip);
2399 if (err)
2400 return err;
2401 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002402
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002403 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002404}
2405
Vivien Didelotf81ec902016-05-09 13:22:58 -04002406static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002407{
Vivien Didelot04bed142016-08-31 18:06:13 -04002408 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002409 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002410 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002411 int i;
2412
Vivien Didelotfad09c72016-06-21 12:28:20 -04002413 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002414 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002415
Vivien Didelotfad09c72016-06-21 12:28:20 -04002416 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002417
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002418 /* Cache the cmode of each port. */
2419 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2420 if (chip->info->ops->port_get_cmode) {
2421 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2422 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002423 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002424
2425 chip->ports[i].cmode = cmode;
2426 }
2427 }
2428
Vivien Didelot97299342016-07-18 20:45:30 -04002429 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002430 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002431 if (dsa_is_unused_port(ds, i))
2432 continue;
2433
Vivien Didelot97299342016-07-18 20:45:30 -04002434 err = mv88e6xxx_setup_port(chip, i);
2435 if (err)
2436 goto unlock;
2437 }
2438
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002439 err = mv88e6xxx_irl_setup(chip);
2440 if (err)
2441 goto unlock;
2442
Vivien Didelot04a69a12017-10-13 14:18:05 -04002443 err = mv88e6xxx_mac_setup(chip);
2444 if (err)
2445 goto unlock;
2446
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002447 err = mv88e6xxx_phy_setup(chip);
2448 if (err)
2449 goto unlock;
2450
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002451 err = mv88e6xxx_vtu_setup(chip);
2452 if (err)
2453 goto unlock;
2454
Vivien Didelot81228992017-03-30 17:37:08 -04002455 err = mv88e6xxx_pvt_setup(chip);
2456 if (err)
2457 goto unlock;
2458
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002459 err = mv88e6xxx_atu_setup(chip);
2460 if (err)
2461 goto unlock;
2462
Andrew Lunn87fa8862017-11-09 22:29:56 +01002463 err = mv88e6xxx_broadcast_setup(chip, 0);
2464 if (err)
2465 goto unlock;
2466
Vivien Didelot9e907d72017-07-17 13:03:43 -04002467 err = mv88e6xxx_pot_setup(chip);
2468 if (err)
2469 goto unlock;
2470
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002471 err = mv88e6xxx_rmu_setup(chip);
2472 if (err)
2473 goto unlock;
2474
Vivien Didelot51c901a2017-07-17 13:03:41 -04002475 err = mv88e6xxx_rsvd2cpu_setup(chip);
2476 if (err)
2477 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002478
Vivien Didelotb28f8722018-04-26 21:56:44 -04002479 err = mv88e6xxx_trunk_setup(chip);
2480 if (err)
2481 goto unlock;
2482
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002483 err = mv88e6xxx_devmap_setup(chip);
2484 if (err)
2485 goto unlock;
2486
Vivien Didelot93e18d62018-05-11 17:16:35 -04002487 err = mv88e6xxx_pri_setup(chip);
2488 if (err)
2489 goto unlock;
2490
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002491 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002492 if (chip->info->ptp_support) {
2493 err = mv88e6xxx_ptp_setup(chip);
2494 if (err)
2495 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002496
2497 err = mv88e6xxx_hwtstamp_setup(chip);
2498 if (err)
2499 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002500 }
2501
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002502 err = mv88e6xxx_stats_setup(chip);
2503 if (err)
2504 goto unlock;
2505
Vivien Didelot6b17e862015-08-13 12:52:18 -04002506unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002507 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002508
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002509 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002510}
2511
Vivien Didelote57e5e72016-08-15 17:19:00 -04002512static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002513{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002514 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2515 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002516 u16 val;
2517 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002518
Andrew Lunnee26a222017-01-24 14:53:48 +01002519 if (!chip->info->ops->phy_read)
2520 return -EOPNOTSUPP;
2521
Vivien Didelotfad09c72016-06-21 12:28:20 -04002522 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002523 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002524 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002525
Andrew Lunnda9f3302017-02-01 03:40:05 +01002526 if (reg == MII_PHYSID2) {
2527 /* Some internal PHYS don't have a model number. Use
2528 * the mv88e6390 family model number instead.
2529 */
2530 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002531 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002532 }
2533
Vivien Didelote57e5e72016-08-15 17:19:00 -04002534 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002535}
2536
Vivien Didelote57e5e72016-08-15 17:19:00 -04002537static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002538{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002539 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2540 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002541 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002542
Andrew Lunnee26a222017-01-24 14:53:48 +01002543 if (!chip->info->ops->phy_write)
2544 return -EOPNOTSUPP;
2545
Vivien Didelotfad09c72016-06-21 12:28:20 -04002546 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002547 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002548 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002549
2550 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002551}
2552
Vivien Didelotfad09c72016-06-21 12:28:20 -04002553static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002554 struct device_node *np,
2555 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002556{
2557 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002558 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002559 struct mii_bus *bus;
2560 int err;
2561
Andrew Lunn2510bab2018-02-22 01:51:49 +01002562 if (external) {
2563 mutex_lock(&chip->reg_lock);
2564 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2565 mutex_unlock(&chip->reg_lock);
2566
2567 if (err)
2568 return err;
2569 }
2570
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002571 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002572 if (!bus)
2573 return -ENOMEM;
2574
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002575 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002576 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002577 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002578 INIT_LIST_HEAD(&mdio_bus->list);
2579 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002580
Andrew Lunnb516d452016-06-04 21:17:06 +02002581 if (np) {
2582 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002583 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002584 } else {
2585 bus->name = "mv88e6xxx SMI";
2586 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2587 }
2588
2589 bus->read = mv88e6xxx_mdio_read;
2590 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002591 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002592
Andrew Lunn6f882842018-03-17 20:32:05 +01002593 if (!external) {
2594 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2595 if (err)
2596 return err;
2597 }
2598
Florian Fainelli00e798c2018-05-15 16:56:19 -07002599 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002600 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002601 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002602 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002603 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002604 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002605
2606 if (external)
2607 list_add_tail(&mdio_bus->list, &chip->mdios);
2608 else
2609 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002610
2611 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002612}
2613
Andrew Lunna3c53be52017-01-24 14:53:50 +01002614static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2615 { .compatible = "marvell,mv88e6xxx-mdio-external",
2616 .data = (void *)true },
2617 { },
2618};
2619
Andrew Lunn3126aee2017-12-07 01:05:57 +01002620static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2621
2622{
2623 struct mv88e6xxx_mdio_bus *mdio_bus;
2624 struct mii_bus *bus;
2625
2626 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2627 bus = mdio_bus->bus;
2628
Andrew Lunn6f882842018-03-17 20:32:05 +01002629 if (!mdio_bus->external)
2630 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2631
Andrew Lunn3126aee2017-12-07 01:05:57 +01002632 mdiobus_unregister(bus);
2633 }
2634}
2635
Andrew Lunna3c53be52017-01-24 14:53:50 +01002636static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2637 struct device_node *np)
2638{
2639 const struct of_device_id *match;
2640 struct device_node *child;
2641 int err;
2642
2643 /* Always register one mdio bus for the internal/default mdio
2644 * bus. This maybe represented in the device tree, but is
2645 * optional.
2646 */
2647 child = of_get_child_by_name(np, "mdio");
2648 err = mv88e6xxx_mdio_register(chip, child, false);
2649 if (err)
2650 return err;
2651
2652 /* Walk the device tree, and see if there are any other nodes
2653 * which say they are compatible with the external mdio
2654 * bus.
2655 */
2656 for_each_available_child_of_node(np, child) {
2657 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2658 if (match) {
2659 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002660 if (err) {
2661 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002662 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002663 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002664 }
2665 }
2666
2667 return 0;
2668}
2669
Vivien Didelot855b1932016-07-20 18:18:35 -04002670static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2671{
Vivien Didelot04bed142016-08-31 18:06:13 -04002672 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002673
2674 return chip->eeprom_len;
2675}
2676
Vivien Didelot855b1932016-07-20 18:18:35 -04002677static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2678 struct ethtool_eeprom *eeprom, u8 *data)
2679{
Vivien Didelot04bed142016-08-31 18:06:13 -04002680 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002681 int err;
2682
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002683 if (!chip->info->ops->get_eeprom)
2684 return -EOPNOTSUPP;
2685
Vivien Didelot855b1932016-07-20 18:18:35 -04002686 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002687 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002688 mutex_unlock(&chip->reg_lock);
2689
2690 if (err)
2691 return err;
2692
2693 eeprom->magic = 0xc3ec4951;
2694
2695 return 0;
2696}
2697
Vivien Didelot855b1932016-07-20 18:18:35 -04002698static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2699 struct ethtool_eeprom *eeprom, u8 *data)
2700{
Vivien Didelot04bed142016-08-31 18:06:13 -04002701 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002702 int err;
2703
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002704 if (!chip->info->ops->set_eeprom)
2705 return -EOPNOTSUPP;
2706
Vivien Didelot855b1932016-07-20 18:18:35 -04002707 if (eeprom->magic != 0xc3ec4951)
2708 return -EINVAL;
2709
2710 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002711 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002712 mutex_unlock(&chip->reg_lock);
2713
2714 return err;
2715}
2716
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002717static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002718 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002719 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2720 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002721 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002722 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002723 .phy_read = mv88e6185_phy_ppu_read,
2724 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002725 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002726 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002727 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002728 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002729 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002730 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002731 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002732 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002733 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002734 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002735 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002736 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002737 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002738 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002739 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002740 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2741 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002742 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002743 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2744 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002745 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002746 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002747 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002748 .ppu_enable = mv88e6185_g1_ppu_enable,
2749 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002750 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002751 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002752 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002753 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002754 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002755};
2756
2757static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002758 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002759 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2760 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002761 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002762 .phy_read = mv88e6185_phy_ppu_read,
2763 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002764 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002765 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002766 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002767 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002768 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002769 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002770 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002771 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002772 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002773 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002774 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2775 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002776 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002777 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002778 .ppu_enable = mv88e6185_g1_ppu_enable,
2779 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002780 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002781 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002782 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002783 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002784};
2785
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002786static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002787 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002788 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2789 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002790 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002791 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2792 .phy_read = mv88e6xxx_g2_smi_phy_read,
2793 .phy_write = mv88e6xxx_g2_smi_phy_write,
2794 .port_set_link = mv88e6xxx_port_set_link,
2795 .port_set_duplex = mv88e6xxx_port_set_duplex,
2796 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002797 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002798 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002799 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002800 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002801 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002802 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002803 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002804 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002805 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002806 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002807 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002808 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002809 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002810 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2811 .stats_get_strings = mv88e6095_stats_get_strings,
2812 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002813 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2814 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002815 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002816 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002817 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002818 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002819 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002820 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002821 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002822 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002823};
2824
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002825static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002826 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002827 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2828 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002829 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002830 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002831 .phy_read = mv88e6xxx_g2_smi_phy_read,
2832 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002833 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002834 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002835 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002836 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002837 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002838 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002839 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002840 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002841 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002842 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002843 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002844 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2845 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002846 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002847 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2848 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002849 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002850 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002851 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002852 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002853 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002854 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002855 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002856};
2857
2858static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002859 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002860 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2861 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002862 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002863 .phy_read = mv88e6185_phy_ppu_read,
2864 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002865 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002866 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002867 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002868 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002869 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002870 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002871 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002872 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002873 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002874 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002875 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002876 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002877 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002878 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002879 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002880 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002881 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2882 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002883 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002884 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2885 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002886 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002887 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002888 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002889 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002890 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002891 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002892 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002893 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002894 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002895};
2896
Vivien Didelot990e27b2017-03-28 13:50:32 -04002897static const struct mv88e6xxx_ops mv88e6141_ops = {
2898 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002899 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2900 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002901 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002902 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2903 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2904 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2905 .phy_read = mv88e6xxx_g2_smi_phy_read,
2906 .phy_write = mv88e6xxx_g2_smi_phy_write,
2907 .port_set_link = mv88e6xxx_port_set_link,
2908 .port_set_duplex = mv88e6xxx_port_set_duplex,
2909 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002910 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002911 .port_tag_remap = mv88e6095_port_tag_remap,
2912 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2913 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2914 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002915 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002916 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002917 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002918 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2919 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002920 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002921 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002922 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002923 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002924 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2925 .stats_get_strings = mv88e6320_stats_get_strings,
2926 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002927 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2928 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002929 .watchdog_ops = &mv88e6390_watchdog_ops,
2930 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002931 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002932 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002933 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002934 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002935 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002936 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02002937 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002938};
2939
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002940static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002941 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002942 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2943 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002944 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002945 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002946 .phy_read = mv88e6xxx_g2_smi_phy_read,
2947 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002948 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002949 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002950 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002951 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002952 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002953 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002954 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002955 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002956 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002957 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002958 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002959 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002960 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002961 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002962 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002963 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002964 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2965 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002966 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002967 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2968 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002969 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002970 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002971 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002972 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002973 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002974 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002975 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002976 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002977 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002978};
2979
2980static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002981 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002982 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2983 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002984 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002985 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002986 .phy_read = mv88e6165_phy_read,
2987 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002988 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002989 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002990 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002991 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002992 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002993 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002994 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002995 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002996 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002997 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2998 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002999 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003000 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3001 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003002 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003003 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003004 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003005 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003006 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003007 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003008 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003009 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003010 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003011};
3012
3013static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003014 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003015 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3016 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003017 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003018 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003019 .phy_read = mv88e6xxx_g2_smi_phy_read,
3020 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003021 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003022 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003023 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003024 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003025 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003026 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003027 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003028 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003029 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003030 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003031 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003032 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003033 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003034 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003035 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003036 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003037 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003038 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3039 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003040 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003041 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3042 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003043 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003044 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003045 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003046 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003047 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003048 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003049 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003050};
3051
3052static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003053 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003054 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3055 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003056 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003057 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3058 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003059 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003060 .phy_read = mv88e6xxx_g2_smi_phy_read,
3061 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003062 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003063 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003064 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003065 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003066 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003067 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003068 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003069 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003070 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003071 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003072 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003073 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003074 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003075 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003076 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003077 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003078 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003079 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3080 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003081 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003082 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3083 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003084 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003085 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003086 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003087 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003088 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003089 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003090 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003091 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003092 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003093 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003094};
3095
3096static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003097 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003098 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3099 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003100 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003101 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003102 .phy_read = mv88e6xxx_g2_smi_phy_read,
3103 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003104 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003105 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003106 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003107 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003108 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003109 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003110 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003111 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003112 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003113 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003114 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003115 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003116 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003117 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003118 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003119 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003120 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003121 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3122 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003123 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003124 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3125 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003126 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003127 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003128 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003129 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003130 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003131 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003132 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003133};
3134
3135static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003136 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003137 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3138 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003139 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003140 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3141 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003142 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003143 .phy_read = mv88e6xxx_g2_smi_phy_read,
3144 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003145 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003146 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003147 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003148 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003149 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003150 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003151 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003152 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003153 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003154 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003155 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003156 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003157 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003158 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003159 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003160 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003161 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003162 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3163 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003164 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003165 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3166 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003167 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003168 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003169 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003170 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003171 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003172 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003173 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003174 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003175 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3176 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003177 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003178 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003179};
3180
3181static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003182 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003183 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3184 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003185 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003186 .phy_read = mv88e6185_phy_ppu_read,
3187 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003188 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003189 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003190 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003191 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003192 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003193 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003194 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003195 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003196 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003197 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003198 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003199 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003200 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3201 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003202 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003203 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3204 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003205 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003206 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003207 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003208 .ppu_enable = mv88e6185_g1_ppu_enable,
3209 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003210 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003211 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003212 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003213 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003214};
3215
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003216static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003217 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003218 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003219 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3220 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003221 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3222 .phy_read = mv88e6xxx_g2_smi_phy_read,
3223 .phy_write = mv88e6xxx_g2_smi_phy_write,
3224 .port_set_link = mv88e6xxx_port_set_link,
3225 .port_set_duplex = mv88e6xxx_port_set_duplex,
3226 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3227 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003228 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003229 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003230 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003231 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003232 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003233 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003234 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003235 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003236 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003237 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003238 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003239 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003240 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3241 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003242 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003243 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3244 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003245 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003246 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003247 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003248 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003249 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003250 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3251 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003252 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003253 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3254 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003255 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003256 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003257};
3258
3259static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003260 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003261 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003262 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3263 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003264 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3265 .phy_read = mv88e6xxx_g2_smi_phy_read,
3266 .phy_write = mv88e6xxx_g2_smi_phy_write,
3267 .port_set_link = mv88e6xxx_port_set_link,
3268 .port_set_duplex = mv88e6xxx_port_set_duplex,
3269 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3270 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003271 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003272 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003273 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003274 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003275 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003276 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003277 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003278 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003279 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003280 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003281 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003282 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003283 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3284 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003285 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003286 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3287 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003288 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003289 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003290 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003291 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003292 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003293 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3294 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003295 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003296 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3297 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003298 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003299 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003300};
3301
3302static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003303 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003304 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003305 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3306 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003307 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3308 .phy_read = mv88e6xxx_g2_smi_phy_read,
3309 .phy_write = mv88e6xxx_g2_smi_phy_write,
3310 .port_set_link = mv88e6xxx_port_set_link,
3311 .port_set_duplex = mv88e6xxx_port_set_duplex,
3312 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3313 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003314 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003315 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003316 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003317 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003318 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003319 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003320 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003321 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003322 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003323 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003324 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003325 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003326 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3327 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003328 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003329 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3330 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003331 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003332 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003333 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003334 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003335 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003336 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3337 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003338 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003339 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3340 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003341 .avb_ops = &mv88e6390_avb_ops,
3342 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003343 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003344};
3345
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003346static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003347 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003348 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3349 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003350 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003351 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3352 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003353 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003354 .phy_read = mv88e6xxx_g2_smi_phy_read,
3355 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003356 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003357 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003358 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003359 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003360 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003361 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003362 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003363 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003364 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003365 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003366 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003367 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003368 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003369 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003370 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003371 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003372 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003373 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3374 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003375 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003376 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3377 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003378 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003379 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003380 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003381 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003382 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003383 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003384 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003385 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003386 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3387 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003388 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003389 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003390 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003391 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003392};
3393
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003394static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003395 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003396 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003397 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3398 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003399 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3400 .phy_read = mv88e6xxx_g2_smi_phy_read,
3401 .phy_write = mv88e6xxx_g2_smi_phy_write,
3402 .port_set_link = mv88e6xxx_port_set_link,
3403 .port_set_duplex = mv88e6xxx_port_set_duplex,
3404 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3405 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003406 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003407 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003408 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003409 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003410 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003411 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003412 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003413 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003414 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003415 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003416 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003417 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003418 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3419 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003420 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003421 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3422 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003423 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003424 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003425 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003426 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003427 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003428 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3429 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003430 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003431 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3432 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003433 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003434 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003435 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003436 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003437};
3438
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003439static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003440 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003441 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3442 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003443 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003444 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3445 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003446 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003447 .phy_read = mv88e6xxx_g2_smi_phy_read,
3448 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003449 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003450 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003451 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003452 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003453 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003454 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003455 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003456 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003457 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003458 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003459 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003460 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003461 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003462 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003463 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003464 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003465 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3466 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003467 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003468 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3469 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003470 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003471 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003472 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003473 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003474 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003475 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003476 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003477 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003478 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003479};
3480
3481static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003482 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003483 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3484 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003485 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003486 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3487 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003488 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003489 .phy_read = mv88e6xxx_g2_smi_phy_read,
3490 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003491 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003492 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003493 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003494 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003495 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003496 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003497 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003498 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003499 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003500 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003501 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003502 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003503 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003504 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003505 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003506 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003507 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3508 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003509 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003510 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3511 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003512 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003513 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003514 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003515 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003516 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003517 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003518 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003519};
3520
Vivien Didelot16e329a2017-03-28 13:50:33 -04003521static const struct mv88e6xxx_ops mv88e6341_ops = {
3522 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003523 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3524 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003525 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003526 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3527 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3528 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3529 .phy_read = mv88e6xxx_g2_smi_phy_read,
3530 .phy_write = mv88e6xxx_g2_smi_phy_write,
3531 .port_set_link = mv88e6xxx_port_set_link,
3532 .port_set_duplex = mv88e6xxx_port_set_duplex,
3533 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003534 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003535 .port_tag_remap = mv88e6095_port_tag_remap,
3536 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3537 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3538 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003539 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003540 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003541 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003542 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3543 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003544 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003545 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003546 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003547 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003548 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3549 .stats_get_strings = mv88e6320_stats_get_strings,
3550 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003551 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3552 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003553 .watchdog_ops = &mv88e6390_watchdog_ops,
3554 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003555 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003556 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003557 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003558 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003559 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003560 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003561 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003562 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003563 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003564};
3565
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003566static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003567 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003568 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3569 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003570 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003571 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003572 .phy_read = mv88e6xxx_g2_smi_phy_read,
3573 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003574 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003575 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003576 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003577 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003578 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003579 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003580 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003581 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003582 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003583 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003584 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003585 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003586 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003587 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003588 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003589 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003590 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003591 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3592 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003593 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003594 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3595 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003596 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003597 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003598 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003599 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003600 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003601 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003602 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003603};
3604
3605static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003606 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003607 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3608 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003609 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003610 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003611 .phy_read = mv88e6xxx_g2_smi_phy_read,
3612 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003613 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003614 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003615 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003616 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003617 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003618 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003619 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003620 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003621 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003622 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003623 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003624 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003625 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003626 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003627 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003628 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003629 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003630 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3631 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003632 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003633 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3634 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003635 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003636 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003637 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003638 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003639 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003640 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003641 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003642 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003643 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003644};
3645
3646static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003647 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003648 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3649 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003650 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003651 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3652 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003653 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003654 .phy_read = mv88e6xxx_g2_smi_phy_read,
3655 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003656 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003657 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003658 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003659 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003660 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003661 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003662 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003663 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003664 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003665 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003666 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003667 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003668 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003669 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003670 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003671 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003672 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003673 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3674 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003675 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003676 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3677 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003678 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003679 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003680 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003681 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003682 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003683 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003684 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003685 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003686 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3687 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003688 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003689 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003690 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003691 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3692 .serdes_get_strings = mv88e6352_serdes_get_strings,
3693 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003694 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003695};
3696
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003697static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003698 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003699 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003700 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3701 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003702 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3703 .phy_read = mv88e6xxx_g2_smi_phy_read,
3704 .phy_write = mv88e6xxx_g2_smi_phy_write,
3705 .port_set_link = mv88e6xxx_port_set_link,
3706 .port_set_duplex = mv88e6xxx_port_set_duplex,
3707 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3708 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003709 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003710 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003711 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003712 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003713 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003714 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003715 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003716 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003717 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003718 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003719 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003720 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003721 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003722 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003723 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3724 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003725 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003726 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3727 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003728 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003729 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003730 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003731 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003732 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003733 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3734 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003735 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003736 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3737 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003738 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003739 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003740 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003741 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003742};
3743
3744static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003745 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003746 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003747 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3748 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003749 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3750 .phy_read = mv88e6xxx_g2_smi_phy_read,
3751 .phy_write = mv88e6xxx_g2_smi_phy_write,
3752 .port_set_link = mv88e6xxx_port_set_link,
3753 .port_set_duplex = mv88e6xxx_port_set_duplex,
3754 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3755 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003756 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003757 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003758 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003759 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003760 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003761 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003762 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003763 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003764 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003765 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003766 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003767 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003768 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003769 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003770 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3771 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003772 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003773 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3774 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003775 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003776 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003777 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003778 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003779 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003780 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3781 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003782 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003783 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3784 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003785 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003786 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003787 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003788 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003789};
3790
Vivien Didelotf81ec902016-05-09 13:22:58 -04003791static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3792 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003793 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003794 .family = MV88E6XXX_FAMILY_6097,
3795 .name = "Marvell 88E6085",
3796 .num_databases = 4096,
3797 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003798 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003799 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003800 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003801 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003802 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003803 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003804 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003805 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003806 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003807 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003808 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003809 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003810 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003811 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003812 },
3813
3814 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003815 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003816 .family = MV88E6XXX_FAMILY_6095,
3817 .name = "Marvell 88E6095/88E6095F",
3818 .num_databases = 256,
3819 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003820 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003821 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003822 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003823 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003824 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003825 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003826 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003827 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003828 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003829 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003830 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003831 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003832 },
3833
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003834 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003835 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003836 .family = MV88E6XXX_FAMILY_6097,
3837 .name = "Marvell 88E6097/88E6097F",
3838 .num_databases = 4096,
3839 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003840 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003841 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003842 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003843 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003844 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003845 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003846 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003847 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003848 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003849 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003850 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003851 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003852 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003853 .ops = &mv88e6097_ops,
3854 },
3855
Vivien Didelotf81ec902016-05-09 13:22:58 -04003856 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003857 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003858 .family = MV88E6XXX_FAMILY_6165,
3859 .name = "Marvell 88E6123",
3860 .num_databases = 4096,
3861 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003862 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003863 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003864 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003865 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003866 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003867 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003868 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003869 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003870 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003871 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003872 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003873 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003874 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003875 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003876 },
3877
3878 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003879 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003880 .family = MV88E6XXX_FAMILY_6185,
3881 .name = "Marvell 88E6131",
3882 .num_databases = 256,
3883 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003884 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003885 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003886 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003887 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003888 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003889 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003890 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003891 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003892 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003893 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003894 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003895 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003896 },
3897
Vivien Didelot990e27b2017-03-28 13:50:32 -04003898 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003899 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003900 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003901 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003902 .num_databases = 4096,
3903 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003904 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003905 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003906 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003907 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003908 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003909 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003910 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003911 .age_time_coeff = 3750,
3912 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003913 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003914 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003915 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003916 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003917 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003918 .ops = &mv88e6141_ops,
3919 },
3920
Vivien Didelotf81ec902016-05-09 13:22:58 -04003921 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003922 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003923 .family = MV88E6XXX_FAMILY_6165,
3924 .name = "Marvell 88E6161",
3925 .num_databases = 4096,
3926 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003927 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003928 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003929 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003930 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003931 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003932 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003933 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003934 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003935 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003936 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003937 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003938 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003939 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003940 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003941 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003942 },
3943
3944 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003945 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003946 .family = MV88E6XXX_FAMILY_6165,
3947 .name = "Marvell 88E6165",
3948 .num_databases = 4096,
3949 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003950 .num_internal_phys = 0,
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 = 9,
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,
Andrew Lunndfa54342018-07-18 22:38:22 +02003963 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003964 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003965 },
3966
3967 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003968 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003969 .family = MV88E6XXX_FAMILY_6351,
3970 .name = "Marvell 88E6171",
3971 .num_databases = 4096,
3972 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003973 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003974 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003975 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003976 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003977 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003978 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003979 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003980 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003981 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003982 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003983 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003984 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003985 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003986 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003987 },
3988
3989 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003990 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003991 .family = MV88E6XXX_FAMILY_6352,
3992 .name = "Marvell 88E6172",
3993 .num_databases = 4096,
3994 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003995 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003996 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003997 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003998 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003999 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004000 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004001 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004002 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004003 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004004 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004005 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004006 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004007 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004008 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004009 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004010 },
4011
4012 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004013 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004014 .family = MV88E6XXX_FAMILY_6351,
4015 .name = "Marvell 88E6175",
4016 .num_databases = 4096,
4017 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004018 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004019 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004020 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004021 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004022 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004023 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004024 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004025 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004026 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004027 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004028 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004029 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004030 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004031 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004032 },
4033
4034 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004035 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004036 .family = MV88E6XXX_FAMILY_6352,
4037 .name = "Marvell 88E6176",
4038 .num_databases = 4096,
4039 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004040 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004041 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004042 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004043 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004044 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004045 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004046 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004047 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004048 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004049 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004050 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004051 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004052 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004053 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004054 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004055 },
4056
4057 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004058 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004059 .family = MV88E6XXX_FAMILY_6185,
4060 .name = "Marvell 88E6185",
4061 .num_databases = 256,
4062 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004063 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004064 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004065 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004066 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004067 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004068 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004069 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004070 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004071 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004072 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004073 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004074 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004075 },
4076
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004077 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004078 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004079 .family = MV88E6XXX_FAMILY_6390,
4080 .name = "Marvell 88E6190",
4081 .num_databases = 4096,
4082 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004083 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004084 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004085 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004086 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004087 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004088 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004089 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004090 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004091 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004092 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004093 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004094 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004095 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004096 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004097 .ops = &mv88e6190_ops,
4098 },
4099
4100 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004101 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004102 .family = MV88E6XXX_FAMILY_6390,
4103 .name = "Marvell 88E6190X",
4104 .num_databases = 4096,
4105 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004106 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004107 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004108 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004109 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004110 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004111 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004112 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004113 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004114 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004115 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004116 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004117 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004118 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004119 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004120 .ops = &mv88e6190x_ops,
4121 },
4122
4123 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004124 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004125 .family = MV88E6XXX_FAMILY_6390,
4126 .name = "Marvell 88E6191",
4127 .num_databases = 4096,
4128 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004129 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004130 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004131 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004132 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004133 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004134 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004135 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004136 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004137 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004138 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004139 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004140 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004141 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004142 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004143 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004144 },
4145
Vivien Didelotf81ec902016-05-09 13:22:58 -04004146 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004147 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004148 .family = MV88E6XXX_FAMILY_6352,
4149 .name = "Marvell 88E6240",
4150 .num_databases = 4096,
4151 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004152 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004153 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004154 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004155 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004156 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004157 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004158 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004159 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004160 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004161 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004162 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004163 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004164 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004165 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004166 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004167 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004168 },
4169
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004170 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004171 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004172 .family = MV88E6XXX_FAMILY_6390,
4173 .name = "Marvell 88E6290",
4174 .num_databases = 4096,
4175 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004176 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004177 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004178 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004179 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004180 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004181 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004182 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004183 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004184 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004185 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004186 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004187 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004188 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004189 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004190 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004191 .ops = &mv88e6290_ops,
4192 },
4193
Vivien Didelotf81ec902016-05-09 13:22:58 -04004194 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004195 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004196 .family = MV88E6XXX_FAMILY_6320,
4197 .name = "Marvell 88E6320",
4198 .num_databases = 4096,
4199 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004200 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004201 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004202 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004203 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004204 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004205 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004206 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004207 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004208 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004209 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004210 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004211 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004212 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004213 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004214 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004215 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004216 },
4217
4218 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004219 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004220 .family = MV88E6XXX_FAMILY_6320,
4221 .name = "Marvell 88E6321",
4222 .num_databases = 4096,
4223 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004224 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004225 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004226 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004227 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004228 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004229 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004230 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004231 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004232 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004233 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004234 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004235 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004236 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004237 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004238 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004239 },
4240
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004241 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004242 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004243 .family = MV88E6XXX_FAMILY_6341,
4244 .name = "Marvell 88E6341",
4245 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004246 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004247 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004248 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004249 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004250 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004251 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004252 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004253 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004254 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004255 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004256 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004257 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004258 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004259 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004260 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004261 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004262 .ops = &mv88e6341_ops,
4263 },
4264
Vivien Didelotf81ec902016-05-09 13:22:58 -04004265 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004266 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004267 .family = MV88E6XXX_FAMILY_6351,
4268 .name = "Marvell 88E6350",
4269 .num_databases = 4096,
4270 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004271 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004272 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004273 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004274 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004275 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004276 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004277 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004278 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004279 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004280 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004281 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004282 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004283 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004284 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004285 },
4286
4287 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004288 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004289 .family = MV88E6XXX_FAMILY_6351,
4290 .name = "Marvell 88E6351",
4291 .num_databases = 4096,
4292 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004293 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004294 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004295 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004296 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004297 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004298 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004299 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004300 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004301 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004302 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004303 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004304 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004305 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004306 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004307 },
4308
4309 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004310 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004311 .family = MV88E6XXX_FAMILY_6352,
4312 .name = "Marvell 88E6352",
4313 .num_databases = 4096,
4314 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004315 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004316 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004317 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004318 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004319 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004320 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004321 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004322 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004323 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004324 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004325 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004326 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004327 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004328 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004329 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004330 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004331 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004332 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004333 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004334 .family = MV88E6XXX_FAMILY_6390,
4335 .name = "Marvell 88E6390",
4336 .num_databases = 4096,
4337 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004338 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004339 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004340 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004341 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004342 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004343 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004344 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004345 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004346 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004347 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004348 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004349 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004350 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004351 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004352 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004353 .ops = &mv88e6390_ops,
4354 },
4355 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004356 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004357 .family = MV88E6XXX_FAMILY_6390,
4358 .name = "Marvell 88E6390X",
4359 .num_databases = 4096,
4360 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004361 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004362 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004363 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004364 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004365 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004366 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004367 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004368 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004369 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004370 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004371 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004372 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004373 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004374 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004375 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004376 .ops = &mv88e6390x_ops,
4377 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004378};
4379
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004380static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004381{
Vivien Didelota439c062016-04-17 13:23:58 -04004382 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004383
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004384 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4385 if (mv88e6xxx_table[i].prod_num == prod_num)
4386 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004387
Vivien Didelotb9b37712015-10-30 19:39:48 -04004388 return NULL;
4389}
4390
Vivien Didelotfad09c72016-06-21 12:28:20 -04004391static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004392{
4393 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004394 unsigned int prod_num, rev;
4395 u16 id;
4396 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004397
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004398 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004399 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004400 mutex_unlock(&chip->reg_lock);
4401 if (err)
4402 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004403
Vivien Didelot107fcc12017-06-12 12:37:36 -04004404 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4405 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004406
4407 info = mv88e6xxx_lookup_info(prod_num);
4408 if (!info)
4409 return -ENODEV;
4410
Vivien Didelotcaac8542016-06-20 13:14:09 -04004411 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004412 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004413
Vivien Didelotca070c12016-09-02 14:45:34 -04004414 err = mv88e6xxx_g2_require(chip);
4415 if (err)
4416 return err;
4417
Vivien Didelotfad09c72016-06-21 12:28:20 -04004418 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4419 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004420
4421 return 0;
4422}
4423
Vivien Didelotfad09c72016-06-21 12:28:20 -04004424static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004425{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004426 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004427
Vivien Didelotfad09c72016-06-21 12:28:20 -04004428 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4429 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004430 return NULL;
4431
Vivien Didelotfad09c72016-06-21 12:28:20 -04004432 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004433
Vivien Didelotfad09c72016-06-21 12:28:20 -04004434 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004435 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004436
Vivien Didelotfad09c72016-06-21 12:28:20 -04004437 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004438}
4439
Vivien Didelotfad09c72016-06-21 12:28:20 -04004440static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004441 struct mii_bus *bus, int sw_addr)
4442{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004443 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004444 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004445 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004446 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004447 else
4448 return -EINVAL;
4449
Vivien Didelotfad09c72016-06-21 12:28:20 -04004450 chip->bus = bus;
4451 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004452
4453 return 0;
4454}
4455
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004456static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4457 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004458{
Vivien Didelot04bed142016-08-31 18:06:13 -04004459 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004460
Andrew Lunn443d5a12016-12-03 04:35:18 +01004461 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004462}
4463
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004464#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004465static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4466 struct device *host_dev, int sw_addr,
4467 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004468{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004469 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004470 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004471 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004472
Vivien Didelota439c062016-04-17 13:23:58 -04004473 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004474 if (!bus)
4475 return NULL;
4476
Vivien Didelotfad09c72016-06-21 12:28:20 -04004477 chip = mv88e6xxx_alloc_chip(dsa_dev);
4478 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004479 return NULL;
4480
Vivien Didelotcaac8542016-06-20 13:14:09 -04004481 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004482 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004483
Vivien Didelotfad09c72016-06-21 12:28:20 -04004484 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004485 if (err)
4486 goto free;
4487
Vivien Didelotfad09c72016-06-21 12:28:20 -04004488 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004489 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004490 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004491
Andrew Lunndc30c352016-10-16 19:56:49 +02004492 mutex_lock(&chip->reg_lock);
4493 err = mv88e6xxx_switch_reset(chip);
4494 mutex_unlock(&chip->reg_lock);
4495 if (err)
4496 goto free;
4497
Vivien Didelote57e5e72016-08-15 17:19:00 -04004498 mv88e6xxx_phy_init(chip);
4499
Andrew Lunna3c53be52017-01-24 14:53:50 +01004500 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004501 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004502 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004503
Vivien Didelotfad09c72016-06-21 12:28:20 -04004504 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004505
Vivien Didelotfad09c72016-06-21 12:28:20 -04004506 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004507free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004508 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004509
4510 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004511}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004512#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004513
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004514static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004515 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004516{
4517 /* We don't need any dynamic resource from the kernel (yet),
4518 * so skip the prepare phase.
4519 */
4520
4521 return 0;
4522}
4523
4524static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004525 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004526{
Vivien Didelot04bed142016-08-31 18:06:13 -04004527 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004528
4529 mutex_lock(&chip->reg_lock);
4530 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004531 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004532 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4533 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004534 mutex_unlock(&chip->reg_lock);
4535}
4536
4537static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4538 const struct switchdev_obj_port_mdb *mdb)
4539{
Vivien Didelot04bed142016-08-31 18:06:13 -04004540 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004541 int err;
4542
4543 mutex_lock(&chip->reg_lock);
4544 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004545 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004546 mutex_unlock(&chip->reg_lock);
4547
4548 return err;
4549}
4550
Florian Fainellia82f67a2017-01-08 14:52:08 -08004551static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004552#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004553 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004554#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004555 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004556 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004557 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004558 .phylink_validate = mv88e6xxx_validate,
4559 .phylink_mac_link_state = mv88e6xxx_link_state,
4560 .phylink_mac_config = mv88e6xxx_mac_config,
4561 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4562 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004563 .get_strings = mv88e6xxx_get_strings,
4564 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4565 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004566 .port_enable = mv88e6xxx_port_enable,
4567 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004568 .get_mac_eee = mv88e6xxx_get_mac_eee,
4569 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004570 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004571 .get_eeprom = mv88e6xxx_get_eeprom,
4572 .set_eeprom = mv88e6xxx_set_eeprom,
4573 .get_regs_len = mv88e6xxx_get_regs_len,
4574 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004575 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004576 .port_bridge_join = mv88e6xxx_port_bridge_join,
4577 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4578 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004579 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004580 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4581 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4582 .port_vlan_add = mv88e6xxx_port_vlan_add,
4583 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004584 .port_fdb_add = mv88e6xxx_port_fdb_add,
4585 .port_fdb_del = mv88e6xxx_port_fdb_del,
4586 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004587 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4588 .port_mdb_add = mv88e6xxx_port_mdb_add,
4589 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004590 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4591 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004592 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4593 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4594 .port_txtstamp = mv88e6xxx_port_txtstamp,
4595 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4596 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004597};
4598
Florian Fainelliab3d4082017-01-08 14:52:07 -08004599static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4600 .ops = &mv88e6xxx_switch_ops,
4601};
4602
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004603static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004604{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004605 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004606 struct dsa_switch *ds;
4607
Vivien Didelot73b12042017-03-30 17:37:10 -04004608 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004609 if (!ds)
4610 return -ENOMEM;
4611
Vivien Didelotfad09c72016-06-21 12:28:20 -04004612 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004613 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004614 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004615 ds->ageing_time_min = chip->info->age_time_coeff;
4616 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004617
4618 dev_set_drvdata(dev, ds);
4619
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004620 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004621}
4622
Vivien Didelotfad09c72016-06-21 12:28:20 -04004623static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004624{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004625 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004626}
4627
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004628static const void *pdata_device_get_match_data(struct device *dev)
4629{
4630 const struct of_device_id *matches = dev->driver->of_match_table;
4631 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4632
4633 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4634 matches++) {
4635 if (!strcmp(pdata->compatible, matches->compatible))
4636 return matches->data;
4637 }
4638 return NULL;
4639}
4640
Vivien Didelot57d32312016-06-20 13:13:58 -04004641static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004642{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004643 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004644 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004645 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004646 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004647 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004648 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004649 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004650
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004651 if (!np && !pdata)
4652 return -EINVAL;
4653
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004654 if (np)
4655 compat_info = of_device_get_match_data(dev);
4656
4657 if (pdata) {
4658 compat_info = pdata_device_get_match_data(dev);
4659
4660 if (!pdata->netdev)
4661 return -EINVAL;
4662
4663 for (port = 0; port < DSA_MAX_PORTS; port++) {
4664 if (!(pdata->enabled_ports & (1 << port)))
4665 continue;
4666 if (strcmp(pdata->cd.port_names[port], "cpu"))
4667 continue;
4668 pdata->cd.netdev[port] = &pdata->netdev->dev;
4669 break;
4670 }
4671 }
4672
Vivien Didelotcaac8542016-06-20 13:14:09 -04004673 if (!compat_info)
4674 return -EINVAL;
4675
Vivien Didelotfad09c72016-06-21 12:28:20 -04004676 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004677 if (!chip) {
4678 err = -ENOMEM;
4679 goto out;
4680 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004681
Vivien Didelotfad09c72016-06-21 12:28:20 -04004682 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004683
Vivien Didelotfad09c72016-06-21 12:28:20 -04004684 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004685 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004686 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004687
Andrew Lunnb4308f02016-11-21 23:26:55 +01004688 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004689 if (IS_ERR(chip->reset)) {
4690 err = PTR_ERR(chip->reset);
4691 goto out;
4692 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004693
Vivien Didelotfad09c72016-06-21 12:28:20 -04004694 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004695 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004696 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004697
Vivien Didelote57e5e72016-08-15 17:19:00 -04004698 mv88e6xxx_phy_init(chip);
4699
Andrew Lunn00baabe2018-05-19 22:31:35 +02004700 if (chip->info->ops->get_eeprom) {
4701 if (np)
4702 of_property_read_u32(np, "eeprom-length",
4703 &chip->eeprom_len);
4704 else
4705 chip->eeprom_len = pdata->eeprom_len;
4706 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004707
Andrew Lunndc30c352016-10-16 19:56:49 +02004708 mutex_lock(&chip->reg_lock);
4709 err = mv88e6xxx_switch_reset(chip);
4710 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004711 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004712 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004713
Andrew Lunndc30c352016-10-16 19:56:49 +02004714 chip->irq = of_irq_get(np, 0);
4715 if (chip->irq == -EPROBE_DEFER) {
4716 err = chip->irq;
4717 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004718 }
4719
Andrew Lunn294d7112018-02-22 22:58:32 +01004720 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004721 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004722 * controllers
4723 */
4724 mutex_lock(&chip->reg_lock);
4725 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004726 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004727 else
4728 err = mv88e6xxx_irq_poll_setup(chip);
4729 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004730
Andrew Lunn294d7112018-02-22 22:58:32 +01004731 if (err)
4732 goto out;
4733
4734 if (chip->info->g2_irqs > 0) {
4735 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004736 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004737 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004738 }
4739
Andrew Lunn294d7112018-02-22 22:58:32 +01004740 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4741 if (err)
4742 goto out_g2_irq;
4743
4744 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4745 if (err)
4746 goto out_g1_atu_prob_irq;
4747
Andrew Lunna3c53be52017-01-24 14:53:50 +01004748 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004749 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004750 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004751
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004752 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004753 if (err)
4754 goto out_mdio;
4755
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004756 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004757
4758out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004759 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004760out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004761 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004762out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004763 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004764out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004765 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004766 mv88e6xxx_g2_irq_free(chip);
4767out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004768 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004769 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004770 else
4771 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004772out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004773 if (pdata)
4774 dev_put(pdata->netdev);
4775
Andrew Lunndc30c352016-10-16 19:56:49 +02004776 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004777}
4778
4779static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4780{
4781 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004782 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004783
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004784 if (chip->info->ptp_support) {
4785 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004786 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004787 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004788
Andrew Lunn930188c2016-08-22 16:01:03 +02004789 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004790 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004791 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004792
Andrew Lunn76f38f12018-03-17 20:21:09 +01004793 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4794 mv88e6xxx_g1_atu_prob_irq_free(chip);
4795
4796 if (chip->info->g2_irqs > 0)
4797 mv88e6xxx_g2_irq_free(chip);
4798
Andrew Lunn76f38f12018-03-17 20:21:09 +01004799 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004800 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004801 else
4802 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004803}
4804
4805static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004806 {
4807 .compatible = "marvell,mv88e6085",
4808 .data = &mv88e6xxx_table[MV88E6085],
4809 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004810 {
4811 .compatible = "marvell,mv88e6190",
4812 .data = &mv88e6xxx_table[MV88E6190],
4813 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004814 { /* sentinel */ },
4815};
4816
4817MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4818
4819static struct mdio_driver mv88e6xxx_driver = {
4820 .probe = mv88e6xxx_probe,
4821 .remove = mv88e6xxx_remove,
4822 .mdiodrv.driver = {
4823 .name = "mv88e6085",
4824 .of_match_table = mv88e6xxx_of_match,
4825 },
4826};
4827
Ben Hutchings98e67302011-11-25 14:36:19 +00004828static int __init mv88e6xxx_init(void)
4829{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004830 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004831 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004832}
4833module_init(mv88e6xxx_init);
4834
4835static void __exit mv88e6xxx_cleanup(void)
4836{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004837 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004838 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004839}
4840module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004841
4842MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4843MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4844MODULE_LICENSE("GPL");