blob: 66e0281604dfad8f358b1bf773750e27b87c4550 [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,
Andrew Lunn422a9fd62018-03-25 23:43:14 +0200437 IRQF_ONESHOT,
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
Andrew Lunndea87022015-08-31 15:56:47 +0200578/* We expect the switch to perform auto negotiation if there is a real
579 * phy. However, in the case of a fixed link phy, we force the port
580 * settings from the fixed link settings.
581 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400582static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
583 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200584{
Vivien Didelot04bed142016-08-31 18:06:13 -0400585 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200586 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200587
588 if (!phy_is_pseudo_fixed_link(phydev))
589 return;
590
Vivien Didelotfad09c72016-06-21 12:28:20 -0400591 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100592 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200593 phydev->duplex, phydev->pause,
594 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400595 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100596
597 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400598 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200599}
600
Russell King6c422e32018-08-09 15:38:39 +0200601static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
602 unsigned long *mask,
603 struct phylink_link_state *state)
604{
605 if (!phy_interface_mode_is_8023z(state->interface)) {
606 /* 10M and 100M are only supported in non-802.3z mode */
607 phylink_set(mask, 10baseT_Half);
608 phylink_set(mask, 10baseT_Full);
609 phylink_set(mask, 100baseT_Half);
610 phylink_set(mask, 100baseT_Full);
611 }
612}
613
614static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
615 unsigned long *mask,
616 struct phylink_link_state *state)
617{
618 /* FIXME: if the port is in 1000Base-X mode, then it only supports
619 * 1000M FD speeds. In this case, CMODE will indicate 5.
620 */
621 phylink_set(mask, 1000baseT_Full);
622 phylink_set(mask, 1000baseX_Full);
623
624 mv88e6065_phylink_validate(chip, port, mask, state);
625}
626
627static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
628 unsigned long *mask,
629 struct phylink_link_state *state)
630{
631 /* No ethtool bits for 200Mbps */
632 phylink_set(mask, 1000baseT_Full);
633 phylink_set(mask, 1000baseX_Full);
634
635 mv88e6065_phylink_validate(chip, port, mask, state);
636}
637
638static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
639 unsigned long *mask,
640 struct phylink_link_state *state)
641{
642 if (port >= 9)
643 phylink_set(mask, 2500baseX_Full);
644
645 /* No ethtool bits for 200Mbps */
646 phylink_set(mask, 1000baseT_Full);
647 phylink_set(mask, 1000baseX_Full);
648
649 mv88e6065_phylink_validate(chip, port, mask, state);
650}
651
652static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
653 unsigned long *mask,
654 struct phylink_link_state *state)
655{
656 if (port >= 9) {
657 phylink_set(mask, 10000baseT_Full);
658 phylink_set(mask, 10000baseKR_Full);
659 }
660
661 mv88e6390_phylink_validate(chip, port, mask, state);
662}
663
Russell Kingc9a23562018-05-10 13:17:35 -0700664static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
665 unsigned long *supported,
666 struct phylink_link_state *state)
667{
Russell King6c422e32018-08-09 15:38:39 +0200668 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
669 struct mv88e6xxx_chip *chip = ds->priv;
670
671 /* Allow all the expected bits */
672 phylink_set(mask, Autoneg);
673 phylink_set(mask, Pause);
674 phylink_set_port_modes(mask);
675
676 if (chip->info->ops->phylink_validate)
677 chip->info->ops->phylink_validate(chip, port, mask, state);
678
679 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
680 bitmap_and(state->advertising, state->advertising, mask,
681 __ETHTOOL_LINK_MODE_MASK_NBITS);
682
683 /* We can only operate at 2500BaseX or 1000BaseX. If requested
684 * to advertise both, only report advertising at 2500BaseX.
685 */
686 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700687}
688
689static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
690 struct phylink_link_state *state)
691{
692 struct mv88e6xxx_chip *chip = ds->priv;
693 int err;
694
695 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200696 if (chip->info->ops->port_link_state)
697 err = chip->info->ops->port_link_state(chip, port, state);
698 else
699 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700700 mutex_unlock(&chip->reg_lock);
701
702 return err;
703}
704
705static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
706 unsigned int mode,
707 const struct phylink_link_state *state)
708{
709 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200710 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700711
712 if (mode == MLO_AN_PHY)
713 return;
714
715 if (mode == MLO_AN_FIXED) {
716 link = LINK_FORCED_UP;
717 speed = state->speed;
718 duplex = state->duplex;
719 } else {
720 speed = SPEED_UNFORCED;
721 duplex = DUPLEX_UNFORCED;
722 link = LINK_UNFORCED;
723 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200724 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700725
726 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200727 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700728 state->interface);
729 mutex_unlock(&chip->reg_lock);
730
731 if (err && err != -EOPNOTSUPP)
732 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
733}
734
735static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
736{
737 struct mv88e6xxx_chip *chip = ds->priv;
738 int err;
739
740 mutex_lock(&chip->reg_lock);
741 err = chip->info->ops->port_set_link(chip, port, link);
742 mutex_unlock(&chip->reg_lock);
743
744 if (err)
745 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
746}
747
748static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
749 unsigned int mode,
750 phy_interface_t interface)
751{
752 if (mode == MLO_AN_FIXED)
753 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
754}
755
756static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
757 unsigned int mode, phy_interface_t interface,
758 struct phy_device *phydev)
759{
760 if (mode == MLO_AN_FIXED)
761 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
762}
763
Andrew Lunna605a0f2016-11-21 23:26:58 +0100764static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000765{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100766 if (!chip->info->ops->stats_snapshot)
767 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000768
Andrew Lunna605a0f2016-11-21 23:26:58 +0100769 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000770}
771
Andrew Lunne413e7e2015-04-02 04:06:38 +0200772static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100773 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
774 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
775 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
776 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
777 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
778 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
779 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
780 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
781 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
782 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
783 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
784 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
785 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
786 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
787 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
788 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
789 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
790 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
791 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
792 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
793 { "single", 4, 0x14, STATS_TYPE_BANK0, },
794 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
795 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
796 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
797 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
798 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
799 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
800 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
801 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
802 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
803 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
804 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
805 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
806 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
807 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
808 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
809 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
810 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
811 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
812 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
813 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
814 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
815 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
816 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
817 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
818 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
819 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
820 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
821 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
822 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
823 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
824 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
825 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
826 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
827 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
828 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
829 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
830 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
831 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200832};
833
Vivien Didelotfad09c72016-06-21 12:28:20 -0400834static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100835 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100836 int port, u16 bank1_select,
837 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200838{
Andrew Lunn80c46272015-06-20 18:42:30 +0200839 u32 low;
840 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100841 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200842 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200843 u64 value;
844
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100845 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100846 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200847 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
848 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800849 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200850
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200851 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100852 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200853 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
854 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800855 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200856 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200857 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100858 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100859 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100860 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100861 /* fall through */
862 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100863 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100864 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100865 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100866 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500867 break;
868 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800869 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200870 }
871 value = (((u64)high) << 16) | low;
872 return value;
873}
874
Andrew Lunn436fe172018-03-01 02:02:29 +0100875static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
876 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100877{
878 struct mv88e6xxx_hw_stat *stat;
879 int i, j;
880
881 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
882 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100883 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100884 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
885 ETH_GSTRING_LEN);
886 j++;
887 }
888 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100889
890 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100891}
892
Andrew Lunn436fe172018-03-01 02:02:29 +0100893static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
894 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100895{
Andrew Lunn436fe172018-03-01 02:02:29 +0100896 return mv88e6xxx_stats_get_strings(chip, data,
897 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100898}
899
Andrew Lunn436fe172018-03-01 02:02:29 +0100900static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
901 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100902{
Andrew Lunn436fe172018-03-01 02:02:29 +0100903 return mv88e6xxx_stats_get_strings(chip, data,
904 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100905}
906
Andrew Lunn65f60e42018-03-28 23:50:28 +0200907static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
908 "atu_member_violation",
909 "atu_miss_violation",
910 "atu_full_violation",
911 "vtu_member_violation",
912 "vtu_miss_violation",
913};
914
915static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
916{
917 unsigned int i;
918
919 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
920 strlcpy(data + i * ETH_GSTRING_LEN,
921 mv88e6xxx_atu_vtu_stats_strings[i],
922 ETH_GSTRING_LEN);
923}
924
Andrew Lunndfafe442016-11-21 23:27:02 +0100925static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700926 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100927{
Vivien Didelot04bed142016-08-31 18:06:13 -0400928 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100929 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100930
Florian Fainelli89f09042018-04-25 12:12:50 -0700931 if (stringset != ETH_SS_STATS)
932 return;
933
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100934 mutex_lock(&chip->reg_lock);
935
Andrew Lunndfafe442016-11-21 23:27:02 +0100936 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100937 count = chip->info->ops->stats_get_strings(chip, data);
938
939 if (chip->info->ops->serdes_get_strings) {
940 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200941 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100942 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100943
Andrew Lunn65f60e42018-03-28 23:50:28 +0200944 data += count * ETH_GSTRING_LEN;
945 mv88e6xxx_atu_vtu_get_strings(data);
946
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100947 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100948}
949
950static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
951 int types)
952{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100953 struct mv88e6xxx_hw_stat *stat;
954 int i, j;
955
956 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
957 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100958 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100959 j++;
960 }
961 return j;
962}
963
Andrew Lunndfafe442016-11-21 23:27:02 +0100964static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
965{
966 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
967 STATS_TYPE_PORT);
968}
969
970static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
971{
972 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
973 STATS_TYPE_BANK1);
974}
975
Florian Fainelli89f09042018-04-25 12:12:50 -0700976static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100977{
978 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100979 int serdes_count = 0;
980 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100981
Florian Fainelli89f09042018-04-25 12:12:50 -0700982 if (sset != ETH_SS_STATS)
983 return 0;
984
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100985 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100986 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100987 count = chip->info->ops->stats_get_sset_count(chip);
988 if (count < 0)
989 goto out;
990
991 if (chip->info->ops->serdes_get_sset_count)
992 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
993 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200994 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100995 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200996 goto out;
997 }
998 count += serdes_count;
999 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1000
Andrew Lunn436fe172018-03-01 02:02:29 +01001001out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001002 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001003
Andrew Lunn436fe172018-03-01 02:02:29 +01001004 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001005}
1006
Andrew Lunn436fe172018-03-01 02:02:29 +01001007static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1008 uint64_t *data, int types,
1009 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001010{
1011 struct mv88e6xxx_hw_stat *stat;
1012 int i, j;
1013
1014 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1015 stat = &mv88e6xxx_hw_stats[i];
1016 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001017 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001018 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1019 bank1_select,
1020 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001021 mutex_unlock(&chip->reg_lock);
1022
Andrew Lunn052f9472016-11-21 23:27:03 +01001023 j++;
1024 }
1025 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001026 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001027}
1028
Andrew Lunn436fe172018-03-01 02:02:29 +01001029static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1030 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001031{
1032 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001033 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001034 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001035}
1036
Andrew Lunn436fe172018-03-01 02:02:29 +01001037static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1038 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001039{
1040 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001041 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001042 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1043 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001044}
1045
Andrew Lunn436fe172018-03-01 02:02:29 +01001046static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1047 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001048{
1049 return mv88e6xxx_stats_get_stats(chip, port, data,
1050 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001051 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1052 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001053}
1054
Andrew Lunn65f60e42018-03-28 23:50:28 +02001055static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1056 uint64_t *data)
1057{
1058 *data++ = chip->ports[port].atu_member_violation;
1059 *data++ = chip->ports[port].atu_miss_violation;
1060 *data++ = chip->ports[port].atu_full_violation;
1061 *data++ = chip->ports[port].vtu_member_violation;
1062 *data++ = chip->ports[port].vtu_miss_violation;
1063}
1064
Andrew Lunn052f9472016-11-21 23:27:03 +01001065static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1066 uint64_t *data)
1067{
Andrew Lunn436fe172018-03-01 02:02:29 +01001068 int count = 0;
1069
Andrew Lunn052f9472016-11-21 23:27:03 +01001070 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001071 count = chip->info->ops->stats_get_stats(chip, port, data);
1072
Andrew Lunn65f60e42018-03-28 23:50:28 +02001073 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001074 if (chip->info->ops->serdes_get_stats) {
1075 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001076 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001077 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001078 data += count;
1079 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1080 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001081}
1082
Vivien Didelotf81ec902016-05-09 13:22:58 -04001083static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1084 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001085{
Vivien Didelot04bed142016-08-31 18:06:13 -04001086 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001087 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001088
Vivien Didelotfad09c72016-06-21 12:28:20 -04001089 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001090
Andrew Lunna605a0f2016-11-21 23:26:58 +01001091 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001092 mutex_unlock(&chip->reg_lock);
1093
1094 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001095 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001096
1097 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001098
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001099}
Ben Hutchings98e67302011-11-25 14:36:19 +00001100
Vivien Didelotf81ec902016-05-09 13:22:58 -04001101static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001102{
1103 return 32 * sizeof(u16);
1104}
1105
Vivien Didelotf81ec902016-05-09 13:22:58 -04001106static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1107 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001108{
Vivien Didelot04bed142016-08-31 18:06:13 -04001109 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001110 int err;
1111 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001112 u16 *p = _p;
1113 int i;
1114
1115 regs->version = 0;
1116
1117 memset(p, 0xff, 32 * sizeof(u16));
1118
Vivien Didelotfad09c72016-06-21 12:28:20 -04001119 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001120
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001121 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001122
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001123 err = mv88e6xxx_port_read(chip, port, i, &reg);
1124 if (!err)
1125 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001126 }
Vivien Didelot23062512016-05-09 13:22:45 -04001127
Vivien Didelotfad09c72016-06-21 12:28:20 -04001128 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001129}
1130
Vivien Didelot08f50062017-08-01 16:32:41 -04001131static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1132 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001133{
Vivien Didelot5480db62017-08-01 16:32:40 -04001134 /* Nothing to do on the port's MAC */
1135 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001136}
1137
Vivien Didelot08f50062017-08-01 16:32:41 -04001138static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1139 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001140{
Vivien Didelot5480db62017-08-01 16:32:40 -04001141 /* Nothing to do on the port's MAC */
1142 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001143}
1144
Vivien Didelote5887a22017-03-30 17:37:11 -04001145static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001146{
Vivien Didelote5887a22017-03-30 17:37:11 -04001147 struct dsa_switch *ds = NULL;
1148 struct net_device *br;
1149 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001150 int i;
1151
Vivien Didelote5887a22017-03-30 17:37:11 -04001152 if (dev < DSA_MAX_SWITCHES)
1153 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001154
Vivien Didelote5887a22017-03-30 17:37:11 -04001155 /* Prevent frames from unknown switch or port */
1156 if (!ds || port >= ds->num_ports)
1157 return 0;
1158
1159 /* Frames from DSA links and CPU ports can egress any local port */
1160 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1161 return mv88e6xxx_port_mask(chip);
1162
1163 br = ds->ports[port].bridge_dev;
1164 pvlan = 0;
1165
1166 /* Frames from user ports can egress any local DSA links and CPU ports,
1167 * as well as any local member of their bridge group.
1168 */
1169 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1170 if (dsa_is_cpu_port(chip->ds, i) ||
1171 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001172 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001173 pvlan |= BIT(i);
1174
1175 return pvlan;
1176}
1177
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001178static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001179{
1180 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001181
1182 /* prevent frames from going back out of the port they came in on */
1183 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001184
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001185 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001186}
1187
Vivien Didelotf81ec902016-05-09 13:22:58 -04001188static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1189 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001190{
Vivien Didelot04bed142016-08-31 18:06:13 -04001191 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001192 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001193
Vivien Didelotfad09c72016-06-21 12:28:20 -04001194 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001195 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001196 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001197
1198 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001199 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001200}
1201
Vivien Didelot93e18d62018-05-11 17:16:35 -04001202static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1203{
1204 int err;
1205
1206 if (chip->info->ops->ieee_pri_map) {
1207 err = chip->info->ops->ieee_pri_map(chip);
1208 if (err)
1209 return err;
1210 }
1211
1212 if (chip->info->ops->ip_pri_map) {
1213 err = chip->info->ops->ip_pri_map(chip);
1214 if (err)
1215 return err;
1216 }
1217
1218 return 0;
1219}
1220
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001221static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1222{
1223 int target, port;
1224 int err;
1225
1226 if (!chip->info->global2_addr)
1227 return 0;
1228
1229 /* Initialize the routing port to the 32 possible target devices */
1230 for (target = 0; target < 32; target++) {
1231 port = 0x1f;
1232 if (target < DSA_MAX_SWITCHES)
1233 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1234 port = chip->ds->rtable[target];
1235
1236 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1237 if (err)
1238 return err;
1239 }
1240
Vivien Didelot02317e62018-05-09 11:38:49 -04001241 if (chip->info->ops->set_cascade_port) {
1242 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1243 err = chip->info->ops->set_cascade_port(chip, port);
1244 if (err)
1245 return err;
1246 }
1247
Vivien Didelot23c98912018-05-09 11:38:50 -04001248 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1249 if (err)
1250 return err;
1251
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001252 return 0;
1253}
1254
Vivien Didelotb28f8722018-04-26 21:56:44 -04001255static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1256{
1257 /* Clear all trunk masks and mapping */
1258 if (chip->info->global2_addr)
1259 return mv88e6xxx_g2_trunk_clear(chip);
1260
1261 return 0;
1262}
1263
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001264static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1265{
1266 if (chip->info->ops->rmu_disable)
1267 return chip->info->ops->rmu_disable(chip);
1268
1269 return 0;
1270}
1271
Vivien Didelot9e907d72017-07-17 13:03:43 -04001272static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1273{
1274 if (chip->info->ops->pot_clear)
1275 return chip->info->ops->pot_clear(chip);
1276
1277 return 0;
1278}
1279
Vivien Didelot51c901a2017-07-17 13:03:41 -04001280static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1281{
1282 if (chip->info->ops->mgmt_rsvd2cpu)
1283 return chip->info->ops->mgmt_rsvd2cpu(chip);
1284
1285 return 0;
1286}
1287
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001288static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1289{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001290 int err;
1291
Vivien Didelotdaefc942017-03-11 16:12:54 -05001292 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1293 if (err)
1294 return err;
1295
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001296 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1297 if (err)
1298 return err;
1299
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001300 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1301}
1302
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001303static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1304{
1305 int port;
1306 int err;
1307
1308 if (!chip->info->ops->irl_init_all)
1309 return 0;
1310
1311 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1312 /* Disable ingress rate limiting by resetting all per port
1313 * ingress rate limit resources to their initial state.
1314 */
1315 err = chip->info->ops->irl_init_all(chip, port);
1316 if (err)
1317 return err;
1318 }
1319
1320 return 0;
1321}
1322
Vivien Didelot04a69a12017-10-13 14:18:05 -04001323static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1324{
1325 if (chip->info->ops->set_switch_mac) {
1326 u8 addr[ETH_ALEN];
1327
1328 eth_random_addr(addr);
1329
1330 return chip->info->ops->set_switch_mac(chip, addr);
1331 }
1332
1333 return 0;
1334}
1335
Vivien Didelot17a15942017-03-30 17:37:09 -04001336static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1337{
1338 u16 pvlan = 0;
1339
1340 if (!mv88e6xxx_has_pvt(chip))
1341 return -EOPNOTSUPP;
1342
1343 /* Skip the local source device, which uses in-chip port VLAN */
1344 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001345 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001346
1347 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1348}
1349
Vivien Didelot81228992017-03-30 17:37:08 -04001350static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1351{
Vivien Didelot17a15942017-03-30 17:37:09 -04001352 int dev, port;
1353 int err;
1354
Vivien Didelot81228992017-03-30 17:37:08 -04001355 if (!mv88e6xxx_has_pvt(chip))
1356 return 0;
1357
1358 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1359 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1360 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001361 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1362 if (err)
1363 return err;
1364
1365 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1366 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1367 err = mv88e6xxx_pvt_map(chip, dev, port);
1368 if (err)
1369 return err;
1370 }
1371 }
1372
1373 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001374}
1375
Vivien Didelot749efcb2016-09-22 16:49:24 -04001376static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1377{
1378 struct mv88e6xxx_chip *chip = ds->priv;
1379 int err;
1380
1381 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001382 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001383 mutex_unlock(&chip->reg_lock);
1384
1385 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001386 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001387}
1388
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001389static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1390{
1391 if (!chip->info->max_vid)
1392 return 0;
1393
1394 return mv88e6xxx_g1_vtu_flush(chip);
1395}
1396
Vivien Didelotf1394b782017-05-01 14:05:22 -04001397static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1398 struct mv88e6xxx_vtu_entry *entry)
1399{
1400 if (!chip->info->ops->vtu_getnext)
1401 return -EOPNOTSUPP;
1402
1403 return chip->info->ops->vtu_getnext(chip, entry);
1404}
1405
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001406static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1407 struct mv88e6xxx_vtu_entry *entry)
1408{
1409 if (!chip->info->ops->vtu_loadpurge)
1410 return -EOPNOTSUPP;
1411
1412 return chip->info->ops->vtu_loadpurge(chip, entry);
1413}
1414
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001415static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001416{
1417 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001418 struct mv88e6xxx_vtu_entry vlan = {
1419 .vid = chip->info->max_vid,
1420 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001421 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001422
1423 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1424
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001425 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001426 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001427 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001428 if (err)
1429 return err;
1430
1431 set_bit(*fid, fid_bitmap);
1432 }
1433
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001434 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001435 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001436 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001437 if (err)
1438 return err;
1439
1440 if (!vlan.valid)
1441 break;
1442
1443 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001444 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001445
1446 /* The reset value 0x000 is used to indicate that multiple address
1447 * databases are not needed. Return the next positive available.
1448 */
1449 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001450 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001451 return -ENOSPC;
1452
1453 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001454 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001455}
1456
Vivien Didelot567aa592017-05-01 14:05:25 -04001457static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1458 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001459{
1460 int err;
1461
1462 if (!vid)
1463 return -EINVAL;
1464
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001465 entry->vid = vid - 1;
1466 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001467
Vivien Didelotf1394b782017-05-01 14:05:22 -04001468 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001469 if (err)
1470 return err;
1471
Vivien Didelot567aa592017-05-01 14:05:25 -04001472 if (entry->vid == vid && entry->valid)
1473 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001474
Vivien Didelot567aa592017-05-01 14:05:25 -04001475 if (new) {
1476 int i;
1477
1478 /* Initialize a fresh VLAN entry */
1479 memset(entry, 0, sizeof(*entry));
1480 entry->valid = true;
1481 entry->vid = vid;
1482
Vivien Didelot553a7682017-06-07 18:12:16 -04001483 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001484 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001485 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001486 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001487
1488 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001489 }
1490
Vivien Didelot567aa592017-05-01 14:05:25 -04001491 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1492 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001493}
1494
Vivien Didelotda9c3592016-02-12 12:09:40 -05001495static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1496 u16 vid_begin, u16 vid_end)
1497{
Vivien Didelot04bed142016-08-31 18:06:13 -04001498 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001499 struct mv88e6xxx_vtu_entry vlan = {
1500 .vid = vid_begin - 1,
1501 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001502 int i, err;
1503
Andrew Lunndb06ae412017-09-25 23:32:20 +02001504 /* DSA and CPU ports have to be members of multiple vlans */
1505 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1506 return 0;
1507
Vivien Didelotda9c3592016-02-12 12:09:40 -05001508 if (!vid_begin)
1509 return -EOPNOTSUPP;
1510
Vivien Didelotfad09c72016-06-21 12:28:20 -04001511 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001512
Vivien Didelotda9c3592016-02-12 12:09:40 -05001513 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001514 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001515 if (err)
1516 goto unlock;
1517
1518 if (!vlan.valid)
1519 break;
1520
1521 if (vlan.vid > vid_end)
1522 break;
1523
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001524 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001525 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1526 continue;
1527
Andrew Lunncd886462017-11-09 22:29:53 +01001528 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001529 continue;
1530
Vivien Didelotbd00e052017-05-01 14:05:11 -04001531 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001532 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001533 continue;
1534
Vivien Didelotc8652c82017-10-16 11:12:19 -04001535 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001536 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001537 break; /* same bridge, check next VLAN */
1538
Vivien Didelotc8652c82017-10-16 11:12:19 -04001539 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001540 continue;
1541
Andrew Lunn743fcc22017-11-09 22:29:54 +01001542 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1543 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001544 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545 err = -EOPNOTSUPP;
1546 goto unlock;
1547 }
1548 } while (vlan.vid < vid_end);
1549
1550unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001551 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001552
1553 return err;
1554}
1555
Vivien Didelotf81ec902016-05-09 13:22:58 -04001556static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1557 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001558{
Vivien Didelot04bed142016-08-31 18:06:13 -04001559 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001560 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1561 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001562 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001563
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001564 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001565 return -EOPNOTSUPP;
1566
Vivien Didelotfad09c72016-06-21 12:28:20 -04001567 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001568 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001569 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001570
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001571 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001572}
1573
Vivien Didelot57d32312016-06-20 13:13:58 -04001574static int
1575mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001576 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001577{
Vivien Didelot04bed142016-08-31 18:06:13 -04001578 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001579 int err;
1580
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001581 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001582 return -EOPNOTSUPP;
1583
Vivien Didelotda9c3592016-02-12 12:09:40 -05001584 /* If the requested port doesn't belong to the same bridge as the VLAN
1585 * members, do not support it (yet) and fallback to software VLAN.
1586 */
1587 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1588 vlan->vid_end);
1589 if (err)
1590 return err;
1591
Vivien Didelot76e398a2015-11-01 12:33:55 -05001592 /* We don't need any dynamic resource from the kernel (yet),
1593 * so skip the prepare phase.
1594 */
1595 return 0;
1596}
1597
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001598static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1599 const unsigned char *addr, u16 vid,
1600 u8 state)
1601{
1602 struct mv88e6xxx_vtu_entry vlan;
1603 struct mv88e6xxx_atu_entry entry;
1604 int err;
1605
1606 /* Null VLAN ID corresponds to the port private database */
1607 if (vid == 0)
1608 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1609 else
1610 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1611 if (err)
1612 return err;
1613
1614 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1615 ether_addr_copy(entry.mac, addr);
1616 eth_addr_dec(entry.mac);
1617
1618 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1619 if (err)
1620 return err;
1621
1622 /* Initialize a fresh ATU entry if it isn't found */
1623 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1624 !ether_addr_equal(entry.mac, addr)) {
1625 memset(&entry, 0, sizeof(entry));
1626 ether_addr_copy(entry.mac, addr);
1627 }
1628
1629 /* Purge the ATU entry only if no port is using it anymore */
1630 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1631 entry.portvec &= ~BIT(port);
1632 if (!entry.portvec)
1633 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1634 } else {
1635 entry.portvec |= BIT(port);
1636 entry.state = state;
1637 }
1638
1639 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1640}
1641
Andrew Lunn87fa8862017-11-09 22:29:56 +01001642static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1643 u16 vid)
1644{
1645 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1646 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1647
1648 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1649}
1650
1651static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1652{
1653 int port;
1654 int err;
1655
1656 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1657 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1658 if (err)
1659 return err;
1660 }
1661
1662 return 0;
1663}
1664
Vivien Didelotfad09c72016-06-21 12:28:20 -04001665static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001666 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001667{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001668 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001669 int err;
1670
Vivien Didelot567aa592017-05-01 14:05:25 -04001671 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001672 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001673 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001674
Vivien Didelotc91498e2017-06-07 18:12:13 -04001675 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001676
Andrew Lunn87fa8862017-11-09 22:29:56 +01001677 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1678 if (err)
1679 return err;
1680
1681 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001682}
1683
Vivien Didelotf81ec902016-05-09 13:22:58 -04001684static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001685 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001686{
Vivien Didelot04bed142016-08-31 18:06:13 -04001687 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001688 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1689 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001690 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001691 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001692
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001693 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001694 return;
1695
Vivien Didelotc91498e2017-06-07 18:12:13 -04001696 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001697 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001698 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001699 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001700 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001701 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001702
Vivien Didelotfad09c72016-06-21 12:28:20 -04001703 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001704
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001705 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001706 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001707 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1708 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001709
Vivien Didelot77064f32016-11-04 03:23:30 +01001710 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001711 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1712 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001713
Vivien Didelotfad09c72016-06-21 12:28:20 -04001714 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001715}
1716
Vivien Didelotfad09c72016-06-21 12:28:20 -04001717static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001718 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001719{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001720 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001721 int i, err;
1722
Vivien Didelot567aa592017-05-01 14:05:25 -04001723 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001724 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001725 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001726
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001727 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001728 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001729 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001730
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001731 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001732
1733 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001734 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001735 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001736 if (vlan.member[i] !=
1737 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001738 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001739 break;
1740 }
1741 }
1742
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001743 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001744 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001745 return err;
1746
Vivien Didelote606ca32017-03-11 16:12:55 -05001747 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001748}
1749
Vivien Didelotf81ec902016-05-09 13:22:58 -04001750static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1751 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001752{
Vivien Didelot04bed142016-08-31 18:06:13 -04001753 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001754 u16 pvid, vid;
1755 int err = 0;
1756
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001757 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001758 return -EOPNOTSUPP;
1759
Vivien Didelotfad09c72016-06-21 12:28:20 -04001760 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001761
Vivien Didelot77064f32016-11-04 03:23:30 +01001762 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001763 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001764 goto unlock;
1765
Vivien Didelot76e398a2015-11-01 12:33:55 -05001766 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001767 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001768 if (err)
1769 goto unlock;
1770
1771 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001772 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001773 if (err)
1774 goto unlock;
1775 }
1776 }
1777
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001778unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001779 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001780
1781 return err;
1782}
1783
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001784static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1785 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001786{
Vivien Didelot04bed142016-08-31 18:06:13 -04001787 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001788 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001789
Vivien Didelotfad09c72016-06-21 12:28:20 -04001790 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001791 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1792 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001793 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001794
1795 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001796}
1797
Vivien Didelotf81ec902016-05-09 13:22:58 -04001798static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001799 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001800{
Vivien Didelot04bed142016-08-31 18:06:13 -04001801 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001802 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001803
Vivien Didelotfad09c72016-06-21 12:28:20 -04001804 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001805 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001806 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001807 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001808
Vivien Didelot83dabd12016-08-31 11:50:04 -04001809 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001810}
1811
Vivien Didelot83dabd12016-08-31 11:50:04 -04001812static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1813 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001814 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001815{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001816 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001817 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001818 int err;
1819
Vivien Didelot27c0e602017-06-15 12:14:01 -04001820 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001821 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001822
1823 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001824 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001825 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001826 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001827 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001828 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001829
Vivien Didelot27c0e602017-06-15 12:14:01 -04001830 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001831 break;
1832
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001833 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001834 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001835
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001836 if (!is_unicast_ether_addr(addr.mac))
1837 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001838
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001839 is_static = (addr.state ==
1840 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1841 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001842 if (err)
1843 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001844 } while (!is_broadcast_ether_addr(addr.mac));
1845
1846 return err;
1847}
1848
Vivien Didelot83dabd12016-08-31 11:50:04 -04001849static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001850 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001851{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001852 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001853 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001854 };
1855 u16 fid;
1856 int err;
1857
1858 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001859 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001860 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001861 mutex_unlock(&chip->reg_lock);
1862
Vivien Didelot83dabd12016-08-31 11:50:04 -04001863 if (err)
1864 return err;
1865
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001866 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001867 if (err)
1868 return err;
1869
1870 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001871 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001872 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001873 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001874 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001875 if (err)
1876 return err;
1877
1878 if (!vlan.valid)
1879 break;
1880
1881 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001882 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001883 if (err)
1884 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001885 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001886
1887 return err;
1888}
1889
Vivien Didelotf81ec902016-05-09 13:22:58 -04001890static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001891 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001892{
Vivien Didelot04bed142016-08-31 18:06:13 -04001893 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001894
Andrew Lunna61e5402018-02-15 14:38:35 +01001895 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001896}
1897
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001898static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1899 struct net_device *br)
1900{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001901 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001902 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001903 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001904 int err;
1905
1906 /* Remap the Port VLAN of each local bridge group member */
1907 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1908 if (chip->ds->ports[port].bridge_dev == br) {
1909 err = mv88e6xxx_port_vlan_map(chip, port);
1910 if (err)
1911 return err;
1912 }
1913 }
1914
Vivien Didelote96a6e02017-03-30 17:37:13 -04001915 if (!mv88e6xxx_has_pvt(chip))
1916 return 0;
1917
1918 /* Remap the Port VLAN of each cross-chip bridge group member */
1919 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1920 ds = chip->ds->dst->ds[dev];
1921 if (!ds)
1922 break;
1923
1924 for (port = 0; port < ds->num_ports; ++port) {
1925 if (ds->ports[port].bridge_dev == br) {
1926 err = mv88e6xxx_pvt_map(chip, dev, port);
1927 if (err)
1928 return err;
1929 }
1930 }
1931 }
1932
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001933 return 0;
1934}
1935
Vivien Didelotf81ec902016-05-09 13:22:58 -04001936static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001937 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001938{
Vivien Didelot04bed142016-08-31 18:06:13 -04001939 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001940 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001941
Vivien Didelotfad09c72016-06-21 12:28:20 -04001942 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001943 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001944 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001945
Vivien Didelot466dfa02016-02-26 13:16:05 -05001946 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001947}
1948
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001949static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1950 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001951{
Vivien Didelot04bed142016-08-31 18:06:13 -04001952 struct mv88e6xxx_chip *chip = ds->priv;
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 if (mv88e6xxx_bridge_map(chip, br) ||
1956 mv88e6xxx_port_vlan_map(chip, port))
1957 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001958 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001959}
1960
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001961static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1962 int port, struct net_device *br)
1963{
1964 struct mv88e6xxx_chip *chip = ds->priv;
1965 int err;
1966
1967 if (!mv88e6xxx_has_pvt(chip))
1968 return 0;
1969
1970 mutex_lock(&chip->reg_lock);
1971 err = mv88e6xxx_pvt_map(chip, dev, port);
1972 mutex_unlock(&chip->reg_lock);
1973
1974 return err;
1975}
1976
1977static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1978 int port, struct net_device *br)
1979{
1980 struct mv88e6xxx_chip *chip = ds->priv;
1981
1982 if (!mv88e6xxx_has_pvt(chip))
1983 return;
1984
1985 mutex_lock(&chip->reg_lock);
1986 if (mv88e6xxx_pvt_map(chip, dev, port))
1987 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1988 mutex_unlock(&chip->reg_lock);
1989}
1990
Vivien Didelot17e708b2016-12-05 17:30:27 -05001991static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1992{
1993 if (chip->info->ops->reset)
1994 return chip->info->ops->reset(chip);
1995
1996 return 0;
1997}
1998
Vivien Didelot309eca62016-12-05 17:30:26 -05001999static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2000{
2001 struct gpio_desc *gpiod = chip->reset;
2002
2003 /* If there is a GPIO connected to the reset pin, toggle it */
2004 if (gpiod) {
2005 gpiod_set_value_cansleep(gpiod, 1);
2006 usleep_range(10000, 20000);
2007 gpiod_set_value_cansleep(gpiod, 0);
2008 usleep_range(10000, 20000);
2009 }
2010}
2011
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002012static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2013{
2014 int i, err;
2015
2016 /* Set all ports to the Disabled state */
2017 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002018 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002019 if (err)
2020 return err;
2021 }
2022
2023 /* Wait for transmit queues to drain,
2024 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2025 */
2026 usleep_range(2000, 4000);
2027
2028 return 0;
2029}
2030
Vivien Didelotfad09c72016-06-21 12:28:20 -04002031static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002032{
Vivien Didelota935c052016-09-29 12:21:53 -04002033 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002034
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002035 err = mv88e6xxx_disable_ports(chip);
2036 if (err)
2037 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002038
Vivien Didelot309eca62016-12-05 17:30:26 -05002039 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002040
Vivien Didelot17e708b2016-12-05 17:30:27 -05002041 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002042}
2043
Vivien Didelot43145572017-03-11 16:12:59 -05002044static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002045 enum mv88e6xxx_frame_mode frame,
2046 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002047{
2048 int err;
2049
Vivien Didelot43145572017-03-11 16:12:59 -05002050 if (!chip->info->ops->port_set_frame_mode)
2051 return -EOPNOTSUPP;
2052
2053 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002054 if (err)
2055 return err;
2056
Vivien Didelot43145572017-03-11 16:12:59 -05002057 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2058 if (err)
2059 return err;
2060
2061 if (chip->info->ops->port_set_ether_type)
2062 return chip->info->ops->port_set_ether_type(chip, port, etype);
2063
2064 return 0;
2065}
2066
2067static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2068{
2069 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002070 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002071 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002072}
2073
2074static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2075{
2076 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002077 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002078 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002079}
2080
2081static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2082{
2083 return mv88e6xxx_set_port_mode(chip, port,
2084 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002085 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2086 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002087}
2088
2089static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2090{
2091 if (dsa_is_dsa_port(chip->ds, port))
2092 return mv88e6xxx_set_port_mode_dsa(chip, port);
2093
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002094 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002095 return mv88e6xxx_set_port_mode_normal(chip, port);
2096
2097 /* Setup CPU port mode depending on its supported tag format */
2098 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2099 return mv88e6xxx_set_port_mode_dsa(chip, port);
2100
2101 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2102 return mv88e6xxx_set_port_mode_edsa(chip, port);
2103
2104 return -EINVAL;
2105}
2106
Vivien Didelotea698f42017-03-11 16:12:50 -05002107static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2108{
2109 bool message = dsa_is_dsa_port(chip->ds, port);
2110
2111 return mv88e6xxx_port_set_message_port(chip, port, message);
2112}
2113
Vivien Didelot601aeed2017-03-11 16:13:00 -05002114static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2115{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002116 struct dsa_switch *ds = chip->ds;
2117 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002118
2119 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002120 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002121 if (chip->info->ops->port_set_egress_floods)
2122 return chip->info->ops->port_set_egress_floods(chip, port,
2123 flood, flood);
2124
2125 return 0;
2126}
2127
Andrew Lunn6d917822017-05-26 01:03:21 +02002128static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2129 bool on)
2130{
Vivien Didelot523a8902017-05-26 18:02:42 -04002131 if (chip->info->ops->serdes_power)
2132 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002133
Vivien Didelot523a8902017-05-26 18:02:42 -04002134 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002135}
2136
Vivien Didelotfa371c82017-12-05 15:34:10 -05002137static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2138{
2139 struct dsa_switch *ds = chip->ds;
2140 int upstream_port;
2141 int err;
2142
Vivien Didelot07073c72017-12-05 15:34:13 -05002143 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002144 if (chip->info->ops->port_set_upstream_port) {
2145 err = chip->info->ops->port_set_upstream_port(chip, port,
2146 upstream_port);
2147 if (err)
2148 return err;
2149 }
2150
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002151 if (port == upstream_port) {
2152 if (chip->info->ops->set_cpu_port) {
2153 err = chip->info->ops->set_cpu_port(chip,
2154 upstream_port);
2155 if (err)
2156 return err;
2157 }
2158
2159 if (chip->info->ops->set_egress_port) {
2160 err = chip->info->ops->set_egress_port(chip,
2161 upstream_port);
2162 if (err)
2163 return err;
2164 }
2165 }
2166
Vivien Didelotfa371c82017-12-05 15:34:10 -05002167 return 0;
2168}
2169
Vivien Didelotfad09c72016-06-21 12:28:20 -04002170static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002171{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002172 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002173 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002174 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002175
Vivien Didelotd78343d2016-11-04 03:23:36 +01002176 /* MAC Forcing register: don't force link, speed, duplex or flow control
2177 * state to any particular values on physical ports, but force the CPU
2178 * port and all DSA ports to their maximum bandwidth and full duplex.
2179 */
2180 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2181 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2182 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002183 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002184 PHY_INTERFACE_MODE_NA);
2185 else
2186 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2187 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002188 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002189 PHY_INTERFACE_MODE_NA);
2190 if (err)
2191 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002192
2193 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2194 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2195 * tunneling, determine priority by looking at 802.1p and IP
2196 * priority fields (IP prio has precedence), and set STP state
2197 * to Forwarding.
2198 *
2199 * If this is the CPU link, use DSA or EDSA tagging depending
2200 * on which tagging mode was configured.
2201 *
2202 * If this is a link to another switch, use DSA tagging mode.
2203 *
2204 * If this is the upstream port for this switch, enable
2205 * forwarding of unknown unicasts and multicasts.
2206 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002207 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2208 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2209 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2210 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002211 if (err)
2212 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002213
Vivien Didelot601aeed2017-03-11 16:13:00 -05002214 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002215 if (err)
2216 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002217
Vivien Didelot601aeed2017-03-11 16:13:00 -05002218 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002219 if (err)
2220 return err;
2221
Andrew Lunn04aca992017-05-26 01:03:24 +02002222 /* Enable the SERDES interface for DSA and CPU ports. Normal
2223 * ports SERDES are enabled when the port is enabled, thus
2224 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002225 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002226 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2227 err = mv88e6xxx_serdes_power(chip, port, true);
2228 if (err)
2229 return err;
2230 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002231
Vivien Didelot8efdda42015-08-13 12:52:23 -04002232 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002233 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002234 * untagged frames on this port, do a destination address lookup on all
2235 * received packets as usual, disable ARP mirroring and don't send a
2236 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002237 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002238 err = mv88e6xxx_port_set_map_da(chip, port);
2239 if (err)
2240 return err;
2241
Vivien Didelotfa371c82017-12-05 15:34:10 -05002242 err = mv88e6xxx_setup_upstream_port(chip, port);
2243 if (err)
2244 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002245
Andrew Lunna23b2962017-02-04 20:15:28 +01002246 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002247 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002248 if (err)
2249 return err;
2250
Vivien Didelotcd782652017-06-08 18:34:13 -04002251 if (chip->info->ops->port_set_jumbo_size) {
2252 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002253 if (err)
2254 return err;
2255 }
2256
Andrew Lunn54d792f2015-05-06 01:09:47 +02002257 /* Port Association Vector: when learning source addresses
2258 * of packets, add the address to the address database using
2259 * a port bitmap that has only the bit for this port set and
2260 * the other bits clear.
2261 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002262 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002263 /* Disable learning for CPU port */
2264 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002265 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002266
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002267 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2268 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002269 if (err)
2270 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002271
2272 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002273 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2274 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002275 if (err)
2276 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002277
Vivien Didelot08984322017-06-08 18:34:12 -04002278 if (chip->info->ops->port_pause_limit) {
2279 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002280 if (err)
2281 return err;
2282 }
2283
Vivien Didelotc8c94892017-03-11 16:13:01 -05002284 if (chip->info->ops->port_disable_learn_limit) {
2285 err = chip->info->ops->port_disable_learn_limit(chip, port);
2286 if (err)
2287 return err;
2288 }
2289
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002290 if (chip->info->ops->port_disable_pri_override) {
2291 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002292 if (err)
2293 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002294 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002295
Andrew Lunnef0a7312016-12-03 04:35:16 +01002296 if (chip->info->ops->port_tag_remap) {
2297 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002298 if (err)
2299 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002300 }
2301
Andrew Lunnef70b112016-12-03 04:45:18 +01002302 if (chip->info->ops->port_egress_rate_limiting) {
2303 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002304 if (err)
2305 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002306 }
2307
Vivien Didelotea698f42017-03-11 16:12:50 -05002308 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002309 if (err)
2310 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002311
Vivien Didelot207afda2016-04-14 14:42:09 -04002312 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002313 * database, and allow bidirectional communication between the
2314 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002315 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002316 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002317 if (err)
2318 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002319
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002320 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002321 if (err)
2322 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002323
2324 /* Default VLAN ID and priority: don't set a default VLAN
2325 * ID, and set the default packet priority to zero.
2326 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002327 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002328}
2329
Andrew Lunn04aca992017-05-26 01:03:24 +02002330static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2331 struct phy_device *phydev)
2332{
2333 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002334 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002335
2336 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002337 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunn04aca992017-05-26 01:03:24 +02002338 mutex_unlock(&chip->reg_lock);
2339
2340 return err;
2341}
2342
2343static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2344 struct phy_device *phydev)
2345{
2346 struct mv88e6xxx_chip *chip = ds->priv;
2347
2348 mutex_lock(&chip->reg_lock);
Vivien Didelot523a8902017-05-26 18:02:42 -04002349 if (mv88e6xxx_serdes_power(chip, port, false))
2350 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunn04aca992017-05-26 01:03:24 +02002351 mutex_unlock(&chip->reg_lock);
2352}
2353
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002354static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2355 unsigned int ageing_time)
2356{
Vivien Didelot04bed142016-08-31 18:06:13 -04002357 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002358 int err;
2359
2360 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002361 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002362 mutex_unlock(&chip->reg_lock);
2363
2364 return err;
2365}
2366
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002367static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002368{
2369 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002370
Andrew Lunnde2273872016-11-21 23:27:01 +01002371 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002372 if (chip->info->ops->stats_set_histogram) {
2373 err = chip->info->ops->stats_set_histogram(chip);
2374 if (err)
2375 return err;
2376 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002377
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002378 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002379}
2380
Vivien Didelotf81ec902016-05-09 13:22:58 -04002381static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002382{
Vivien Didelot04bed142016-08-31 18:06:13 -04002383 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002384 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002385 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002386 int i;
2387
Vivien Didelotfad09c72016-06-21 12:28:20 -04002388 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002389 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002390
Vivien Didelotfad09c72016-06-21 12:28:20 -04002391 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002392
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002393 /* Cache the cmode of each port. */
2394 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2395 if (chip->info->ops->port_get_cmode) {
2396 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2397 if (err)
2398 return err;
2399
2400 chip->ports[i].cmode = cmode;
2401 }
2402 }
2403
Vivien Didelot97299342016-07-18 20:45:30 -04002404 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002405 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002406 if (dsa_is_unused_port(ds, i))
2407 continue;
2408
Vivien Didelot97299342016-07-18 20:45:30 -04002409 err = mv88e6xxx_setup_port(chip, i);
2410 if (err)
2411 goto unlock;
2412 }
2413
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002414 err = mv88e6xxx_irl_setup(chip);
2415 if (err)
2416 goto unlock;
2417
Vivien Didelot04a69a12017-10-13 14:18:05 -04002418 err = mv88e6xxx_mac_setup(chip);
2419 if (err)
2420 goto unlock;
2421
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002422 err = mv88e6xxx_phy_setup(chip);
2423 if (err)
2424 goto unlock;
2425
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002426 err = mv88e6xxx_vtu_setup(chip);
2427 if (err)
2428 goto unlock;
2429
Vivien Didelot81228992017-03-30 17:37:08 -04002430 err = mv88e6xxx_pvt_setup(chip);
2431 if (err)
2432 goto unlock;
2433
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002434 err = mv88e6xxx_atu_setup(chip);
2435 if (err)
2436 goto unlock;
2437
Andrew Lunn87fa8862017-11-09 22:29:56 +01002438 err = mv88e6xxx_broadcast_setup(chip, 0);
2439 if (err)
2440 goto unlock;
2441
Vivien Didelot9e907d72017-07-17 13:03:43 -04002442 err = mv88e6xxx_pot_setup(chip);
2443 if (err)
2444 goto unlock;
2445
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002446 err = mv88e6xxx_rmu_setup(chip);
2447 if (err)
2448 goto unlock;
2449
Vivien Didelot51c901a2017-07-17 13:03:41 -04002450 err = mv88e6xxx_rsvd2cpu_setup(chip);
2451 if (err)
2452 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002453
Vivien Didelotb28f8722018-04-26 21:56:44 -04002454 err = mv88e6xxx_trunk_setup(chip);
2455 if (err)
2456 goto unlock;
2457
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002458 err = mv88e6xxx_devmap_setup(chip);
2459 if (err)
2460 goto unlock;
2461
Vivien Didelot93e18d62018-05-11 17:16:35 -04002462 err = mv88e6xxx_pri_setup(chip);
2463 if (err)
2464 goto unlock;
2465
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002466 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002467 if (chip->info->ptp_support) {
2468 err = mv88e6xxx_ptp_setup(chip);
2469 if (err)
2470 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002471
2472 err = mv88e6xxx_hwtstamp_setup(chip);
2473 if (err)
2474 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002475 }
2476
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002477 err = mv88e6xxx_stats_setup(chip);
2478 if (err)
2479 goto unlock;
2480
Vivien Didelot6b17e862015-08-13 12:52:18 -04002481unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002482 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002483
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002484 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002485}
2486
Vivien Didelote57e5e72016-08-15 17:19:00 -04002487static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002488{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002489 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2490 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002491 u16 val;
2492 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002493
Andrew Lunnee26a222017-01-24 14:53:48 +01002494 if (!chip->info->ops->phy_read)
2495 return -EOPNOTSUPP;
2496
Vivien Didelotfad09c72016-06-21 12:28:20 -04002497 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002498 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002499 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002500
Andrew Lunnda9f3302017-02-01 03:40:05 +01002501 if (reg == MII_PHYSID2) {
2502 /* Some internal PHYS don't have a model number. Use
2503 * the mv88e6390 family model number instead.
2504 */
2505 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002506 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002507 }
2508
Vivien Didelote57e5e72016-08-15 17:19:00 -04002509 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002510}
2511
Vivien Didelote57e5e72016-08-15 17:19:00 -04002512static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
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 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002517
Andrew Lunnee26a222017-01-24 14:53:48 +01002518 if (!chip->info->ops->phy_write)
2519 return -EOPNOTSUPP;
2520
Vivien Didelotfad09c72016-06-21 12:28:20 -04002521 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002522 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002523 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002524
2525 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002526}
2527
Vivien Didelotfad09c72016-06-21 12:28:20 -04002528static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002529 struct device_node *np,
2530 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002531{
2532 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002533 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002534 struct mii_bus *bus;
2535 int err;
2536
Andrew Lunn2510bab2018-02-22 01:51:49 +01002537 if (external) {
2538 mutex_lock(&chip->reg_lock);
2539 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2540 mutex_unlock(&chip->reg_lock);
2541
2542 if (err)
2543 return err;
2544 }
2545
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002546 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002547 if (!bus)
2548 return -ENOMEM;
2549
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002550 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002551 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002552 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002553 INIT_LIST_HEAD(&mdio_bus->list);
2554 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002555
Andrew Lunnb516d452016-06-04 21:17:06 +02002556 if (np) {
2557 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002558 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002559 } else {
2560 bus->name = "mv88e6xxx SMI";
2561 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2562 }
2563
2564 bus->read = mv88e6xxx_mdio_read;
2565 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002566 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002567
Andrew Lunn6f882842018-03-17 20:32:05 +01002568 if (!external) {
2569 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2570 if (err)
2571 return err;
2572 }
2573
Florian Fainelli00e798c2018-05-15 16:56:19 -07002574 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002575 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002576 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002577 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002578 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002579 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002580
2581 if (external)
2582 list_add_tail(&mdio_bus->list, &chip->mdios);
2583 else
2584 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002585
2586 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002587}
2588
Andrew Lunna3c53be52017-01-24 14:53:50 +01002589static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2590 { .compatible = "marvell,mv88e6xxx-mdio-external",
2591 .data = (void *)true },
2592 { },
2593};
2594
Andrew Lunn3126aee2017-12-07 01:05:57 +01002595static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2596
2597{
2598 struct mv88e6xxx_mdio_bus *mdio_bus;
2599 struct mii_bus *bus;
2600
2601 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2602 bus = mdio_bus->bus;
2603
Andrew Lunn6f882842018-03-17 20:32:05 +01002604 if (!mdio_bus->external)
2605 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2606
Andrew Lunn3126aee2017-12-07 01:05:57 +01002607 mdiobus_unregister(bus);
2608 }
2609}
2610
Andrew Lunna3c53be52017-01-24 14:53:50 +01002611static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2612 struct device_node *np)
2613{
2614 const struct of_device_id *match;
2615 struct device_node *child;
2616 int err;
2617
2618 /* Always register one mdio bus for the internal/default mdio
2619 * bus. This maybe represented in the device tree, but is
2620 * optional.
2621 */
2622 child = of_get_child_by_name(np, "mdio");
2623 err = mv88e6xxx_mdio_register(chip, child, false);
2624 if (err)
2625 return err;
2626
2627 /* Walk the device tree, and see if there are any other nodes
2628 * which say they are compatible with the external mdio
2629 * bus.
2630 */
2631 for_each_available_child_of_node(np, child) {
2632 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2633 if (match) {
2634 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002635 if (err) {
2636 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002637 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002638 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002639 }
2640 }
2641
2642 return 0;
2643}
2644
Vivien Didelot855b1932016-07-20 18:18:35 -04002645static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2646{
Vivien Didelot04bed142016-08-31 18:06:13 -04002647 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002648
2649 return chip->eeprom_len;
2650}
2651
Vivien Didelot855b1932016-07-20 18:18:35 -04002652static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2653 struct ethtool_eeprom *eeprom, u8 *data)
2654{
Vivien Didelot04bed142016-08-31 18:06:13 -04002655 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002656 int err;
2657
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002658 if (!chip->info->ops->get_eeprom)
2659 return -EOPNOTSUPP;
2660
Vivien Didelot855b1932016-07-20 18:18:35 -04002661 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002662 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002663 mutex_unlock(&chip->reg_lock);
2664
2665 if (err)
2666 return err;
2667
2668 eeprom->magic = 0xc3ec4951;
2669
2670 return 0;
2671}
2672
Vivien Didelot855b1932016-07-20 18:18:35 -04002673static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2674 struct ethtool_eeprom *eeprom, u8 *data)
2675{
Vivien Didelot04bed142016-08-31 18:06:13 -04002676 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002677 int err;
2678
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002679 if (!chip->info->ops->set_eeprom)
2680 return -EOPNOTSUPP;
2681
Vivien Didelot855b1932016-07-20 18:18:35 -04002682 if (eeprom->magic != 0xc3ec4951)
2683 return -EINVAL;
2684
2685 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002686 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002687 mutex_unlock(&chip->reg_lock);
2688
2689 return err;
2690}
2691
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002692static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002693 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002694 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2695 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002696 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002697 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002698 .phy_read = mv88e6185_phy_ppu_read,
2699 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002700 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002701 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002702 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002703 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002704 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002705 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002706 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002707 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002708 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002709 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002710 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002711 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002712 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002713 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002714 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002715 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2716 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002717 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002718 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2719 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002720 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002721 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002722 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002723 .ppu_enable = mv88e6185_g1_ppu_enable,
2724 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002725 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002726 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002727 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002728 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002729 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002730};
2731
2732static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002733 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002734 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2735 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002736 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002737 .phy_read = mv88e6185_phy_ppu_read,
2738 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002739 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002740 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002741 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002742 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002743 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002744 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002745 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002746 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002747 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002748 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002749 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2750 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002751 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002752 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002753 .ppu_enable = mv88e6185_g1_ppu_enable,
2754 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002755 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002756 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002757 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002758 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002759};
2760
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002761static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002762 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002763 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2764 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002765 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002766 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2767 .phy_read = mv88e6xxx_g2_smi_phy_read,
2768 .phy_write = mv88e6xxx_g2_smi_phy_write,
2769 .port_set_link = mv88e6xxx_port_set_link,
2770 .port_set_duplex = mv88e6xxx_port_set_duplex,
2771 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002772 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002773 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002774 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002775 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002776 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002777 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002778 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002779 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002780 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002781 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002782 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002783 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002784 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002785 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2786 .stats_get_strings = mv88e6095_stats_get_strings,
2787 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002788 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2789 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002790 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002791 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002792 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002793 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002794 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002795 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002796 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002797 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002798};
2799
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002800static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002801 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002802 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2803 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002804 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002805 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002806 .phy_read = mv88e6xxx_g2_smi_phy_read,
2807 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002808 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002809 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002810 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002811 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002812 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002813 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002814 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002815 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002816 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002817 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002818 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002819 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2820 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002821 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002822 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2823 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002824 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002825 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002826 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002827 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002828 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002829 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002830 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002831};
2832
2833static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002834 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002835 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2836 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002837 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002838 .phy_read = mv88e6185_phy_ppu_read,
2839 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002840 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002841 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002842 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002843 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002844 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002845 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002846 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002847 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002848 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002849 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002850 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002851 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002852 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002853 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002854 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002855 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002856 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2857 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002858 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002859 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2860 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002861 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002862 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002863 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002864 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002865 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002866 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002867 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002868 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002869 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002870};
2871
Vivien Didelot990e27b2017-03-28 13:50:32 -04002872static const struct mv88e6xxx_ops mv88e6141_ops = {
2873 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002874 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2875 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002876 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002877 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2878 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2879 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2880 .phy_read = mv88e6xxx_g2_smi_phy_read,
2881 .phy_write = mv88e6xxx_g2_smi_phy_write,
2882 .port_set_link = mv88e6xxx_port_set_link,
2883 .port_set_duplex = mv88e6xxx_port_set_duplex,
2884 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2885 .port_set_speed = mv88e6390_port_set_speed,
2886 .port_tag_remap = mv88e6095_port_tag_remap,
2887 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2888 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2889 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002890 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002891 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002892 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002893 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2894 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002895 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002896 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002897 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002898 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002899 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2900 .stats_get_strings = mv88e6320_stats_get_strings,
2901 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002902 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2903 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002904 .watchdog_ops = &mv88e6390_watchdog_ops,
2905 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002906 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002907 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002908 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002909 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002910 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002911 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02002912 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002913};
2914
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002915static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002916 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002917 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2918 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002919 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002920 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002921 .phy_read = mv88e6xxx_g2_smi_phy_read,
2922 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002923 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002924 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002925 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002926 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002927 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002928 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002929 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002930 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002931 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002932 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002933 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002934 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002935 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002936 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002937 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002938 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002939 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2940 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002941 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002942 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2943 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002944 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002945 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002946 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002947 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002948 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002949 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002950 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002951 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002952 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002953};
2954
2955static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002956 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002957 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2958 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002959 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002960 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002961 .phy_read = mv88e6165_phy_read,
2962 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002963 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002964 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002965 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002966 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002967 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002968 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002969 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002970 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002971 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002972 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2973 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002974 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002975 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2976 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002977 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002978 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002979 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002980 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002981 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002982 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002983 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002984 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002985 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002986};
2987
2988static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002989 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002990 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2991 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002992 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002993 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002994 .phy_read = mv88e6xxx_g2_smi_phy_read,
2995 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002996 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002997 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002998 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002999 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003000 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003001 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003002 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003003 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003004 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003005 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003006 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003007 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003008 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003009 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003010 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003011 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003012 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003013 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3014 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003015 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003016 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3017 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003018 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003019 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003020 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003021 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003022 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003023 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003024 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003025};
3026
3027static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003028 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003029 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3030 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003031 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003032 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3033 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003034 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003035 .phy_read = mv88e6xxx_g2_smi_phy_read,
3036 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003037 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003038 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003039 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003040 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003041 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003042 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003043 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003044 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003045 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003046 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003047 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003048 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003049 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003050 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003051 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003052 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003053 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003054 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3055 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003056 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003057 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3058 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003059 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003060 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003061 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003062 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003063 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003064 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003065 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003066 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003067 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003068 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003069};
3070
3071static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003072 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003073 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3074 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003075 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003076 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003077 .phy_read = mv88e6xxx_g2_smi_phy_read,
3078 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003079 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003080 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003081 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003082 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003083 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003084 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003085 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003086 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003087 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003088 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003089 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003090 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003091 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003092 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003093 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003094 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003095 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003096 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3097 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003098 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003099 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3100 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003101 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003102 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003103 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003104 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003105 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003106 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003107 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003108};
3109
3110static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003111 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003112 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3113 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003114 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003115 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3116 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003117 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003118 .phy_read = mv88e6xxx_g2_smi_phy_read,
3119 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003120 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003121 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003122 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003123 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003124 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003125 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003126 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003127 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003128 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003129 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003130 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003131 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003132 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003133 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003134 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003135 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003136 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003137 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3138 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003139 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003140 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3141 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003142 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003143 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003144 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003145 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003146 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003147 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003148 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003149 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003150 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003151 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003152};
3153
3154static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003155 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003156 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3157 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003158 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003159 .phy_read = mv88e6185_phy_ppu_read,
3160 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003161 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003162 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003163 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003164 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003165 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003166 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003167 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003168 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003169 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003170 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003171 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003172 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003173 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3174 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003175 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003176 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3177 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003178 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003179 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003180 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003181 .ppu_enable = mv88e6185_g1_ppu_enable,
3182 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003183 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003184 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003185 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003186 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003187};
3188
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003189static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003190 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003191 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003192 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3193 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003194 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3195 .phy_read = mv88e6xxx_g2_smi_phy_read,
3196 .phy_write = mv88e6xxx_g2_smi_phy_write,
3197 .port_set_link = mv88e6xxx_port_set_link,
3198 .port_set_duplex = mv88e6xxx_port_set_duplex,
3199 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3200 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003201 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003202 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003203 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003204 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003205 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003206 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003207 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003208 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003209 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003210 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003211 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003212 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3213 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003214 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003215 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3216 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003217 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003218 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003219 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003220 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003221 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003222 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3223 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003224 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003225 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003226 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003227};
3228
3229static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003230 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003231 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003232 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3233 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003234 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3235 .phy_read = mv88e6xxx_g2_smi_phy_read,
3236 .phy_write = mv88e6xxx_g2_smi_phy_write,
3237 .port_set_link = mv88e6xxx_port_set_link,
3238 .port_set_duplex = mv88e6xxx_port_set_duplex,
3239 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3240 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003241 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003242 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003243 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003244 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003245 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003246 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003247 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003248 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003249 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003250 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003251 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003252 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3253 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003254 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003255 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3256 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003257 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003258 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003259 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003260 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003261 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003262 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3263 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003264 .serdes_power = mv88e6390x_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003265 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003266 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003267};
3268
3269static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003270 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003271 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003272 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3273 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003274 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3275 .phy_read = mv88e6xxx_g2_smi_phy_read,
3276 .phy_write = mv88e6xxx_g2_smi_phy_write,
3277 .port_set_link = mv88e6xxx_port_set_link,
3278 .port_set_duplex = mv88e6xxx_port_set_duplex,
3279 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3280 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003281 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003282 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003283 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003284 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003285 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003286 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003287 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003288 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003289 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003290 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003291 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003292 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3293 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003294 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003295 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3296 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003297 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003298 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003299 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003300 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003301 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003302 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3303 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003304 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003305 .avb_ops = &mv88e6390_avb_ops,
3306 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003307 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003308};
3309
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003310static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003311 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003312 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3313 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003314 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003315 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3316 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003317 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003318 .phy_read = mv88e6xxx_g2_smi_phy_read,
3319 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003320 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003321 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003322 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003323 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003324 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003325 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003326 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003327 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003328 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003329 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003330 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003331 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003332 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003333 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003334 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003335 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003336 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003337 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3338 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003339 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003340 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3341 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003342 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003343 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003344 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003345 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003346 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003347 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003348 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003349 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003350 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003351 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003352 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003353 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003354};
3355
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003356static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003357 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003358 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003359 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3360 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003361 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3362 .phy_read = mv88e6xxx_g2_smi_phy_read,
3363 .phy_write = mv88e6xxx_g2_smi_phy_write,
3364 .port_set_link = mv88e6xxx_port_set_link,
3365 .port_set_duplex = mv88e6xxx_port_set_duplex,
3366 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3367 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003368 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003369 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003370 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003371 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003372 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003373 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003374 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003375 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003376 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003377 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003378 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003379 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003380 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3381 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003382 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003383 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3384 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003385 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003386 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003387 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003388 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003389 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003390 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3391 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003392 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003393 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003394 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003395 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003396 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003397};
3398
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003399static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003400 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003401 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3402 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003403 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003404 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3405 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003406 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003407 .phy_read = mv88e6xxx_g2_smi_phy_read,
3408 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003409 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003410 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003411 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003412 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003413 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003414 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003415 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003416 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003417 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003418 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003419 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003420 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003421 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003422 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003423 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003424 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003425 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3426 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003427 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003428 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3429 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003430 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003431 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003432 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003433 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003434 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003435 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003436 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003437 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003438 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003439};
3440
3441static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003442 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003443 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3444 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003445 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003446 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3447 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003448 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003449 .phy_read = mv88e6xxx_g2_smi_phy_read,
3450 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003451 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003452 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003453 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003454 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003455 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003456 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003457 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003458 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003459 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003460 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003461 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003462 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003463 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003464 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003465 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003466 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003467 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3468 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003469 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003470 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3471 .set_egress_port = mv88e6095_g1_set_egress_port,
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
Vivien Didelot16e329a2017-03-28 13:50:33 -04003481static const struct mv88e6xxx_ops mv88e6341_ops = {
3482 /* MV88E6XXX_FAMILY_6341 */
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 Didelot16e329a2017-03-28 13:50:33 -04003486 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3487 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3488 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3489 .phy_read = mv88e6xxx_g2_smi_phy_read,
3490 .phy_write = mv88e6xxx_g2_smi_phy_write,
3491 .port_set_link = mv88e6xxx_port_set_link,
3492 .port_set_duplex = mv88e6xxx_port_set_duplex,
3493 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3494 .port_set_speed = mv88e6390_port_set_speed,
3495 .port_tag_remap = mv88e6095_port_tag_remap,
3496 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3497 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3498 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003499 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003500 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003501 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003502 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3503 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003504 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003505 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003506 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003507 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003508 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3509 .stats_get_strings = mv88e6320_stats_get_strings,
3510 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003511 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3512 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003513 .watchdog_ops = &mv88e6390_watchdog_ops,
3514 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003515 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003516 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003517 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003518 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003519 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003520 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003521 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003522 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003523 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003524};
3525
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003526static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003527 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003528 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3529 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003530 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003531 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003532 .phy_read = mv88e6xxx_g2_smi_phy_read,
3533 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003534 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003535 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003536 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003537 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003538 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003539 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003540 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003541 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003542 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003543 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003544 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003545 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003546 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003547 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003548 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003549 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003550 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003551 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3552 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003553 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003554 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3555 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003556 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003557 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003558 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003559 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003560 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003561 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003562 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003563};
3564
3565static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003566 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003567 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3568 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003569 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003570 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003571 .phy_read = mv88e6xxx_g2_smi_phy_read,
3572 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003573 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003574 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003575 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003576 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003577 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003578 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003579 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003580 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003581 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003582 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003583 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003584 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003585 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003586 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003587 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003588 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003589 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003590 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3591 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003592 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003593 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3594 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003595 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003596 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003597 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003598 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003599 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003600 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003601 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003602 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003603 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003604};
3605
3606static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003607 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003608 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3609 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003610 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003611 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3612 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003613 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003614 .phy_read = mv88e6xxx_g2_smi_phy_read,
3615 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003616 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003617 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003618 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003619 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003620 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003621 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003622 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003623 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003624 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003625 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003626 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003627 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003628 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003629 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003630 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003631 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003632 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003633 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3634 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003635 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003636 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3637 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003638 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003639 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003640 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003641 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003642 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003643 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003644 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003645 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003646 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003647 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003648 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003649 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3650 .serdes_get_strings = mv88e6352_serdes_get_strings,
3651 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003652 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003653};
3654
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003655static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003656 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003657 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003658 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3659 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003660 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3661 .phy_read = mv88e6xxx_g2_smi_phy_read,
3662 .phy_write = mv88e6xxx_g2_smi_phy_write,
3663 .port_set_link = mv88e6xxx_port_set_link,
3664 .port_set_duplex = mv88e6xxx_port_set_duplex,
3665 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3666 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003667 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003668 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003669 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003670 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003671 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003672 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003673 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003674 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003675 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003676 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003677 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003678 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003679 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003680 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003681 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3682 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003683 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003684 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3685 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003686 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003687 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003688 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003689 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003690 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003691 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3692 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003693 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003694 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003695 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003696 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003697 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003698};
3699
3700static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003701 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003702 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003703 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3704 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003705 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3706 .phy_read = mv88e6xxx_g2_smi_phy_read,
3707 .phy_write = mv88e6xxx_g2_smi_phy_write,
3708 .port_set_link = mv88e6xxx_port_set_link,
3709 .port_set_duplex = mv88e6xxx_port_set_duplex,
3710 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3711 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003712 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003713 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003714 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003715 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003716 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003717 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003718 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003719 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003720 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003721 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003722 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003723 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003724 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003725 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003726 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3727 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003728 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003729 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3730 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003731 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003732 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003733 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003734 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003735 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003736 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3737 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003738 .serdes_power = mv88e6390x_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003739 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003740 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003741 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003742 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003743};
3744
Vivien Didelotf81ec902016-05-09 13:22:58 -04003745static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3746 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003747 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003748 .family = MV88E6XXX_FAMILY_6097,
3749 .name = "Marvell 88E6085",
3750 .num_databases = 4096,
3751 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003752 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003753 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003754 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003755 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003756 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003757 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003758 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003759 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003760 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003761 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003762 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003763 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003764 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003765 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003766 },
3767
3768 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003769 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003770 .family = MV88E6XXX_FAMILY_6095,
3771 .name = "Marvell 88E6095/88E6095F",
3772 .num_databases = 256,
3773 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003774 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003775 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003776 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003777 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003778 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003779 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003780 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003781 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003782 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003783 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003784 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003785 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003786 },
3787
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003788 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003789 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003790 .family = MV88E6XXX_FAMILY_6097,
3791 .name = "Marvell 88E6097/88E6097F",
3792 .num_databases = 4096,
3793 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003794 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003795 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003796 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003797 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003798 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003799 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003800 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003801 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003802 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003803 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003804 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003805 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003806 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003807 .ops = &mv88e6097_ops,
3808 },
3809
Vivien Didelotf81ec902016-05-09 13:22:58 -04003810 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003811 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003812 .family = MV88E6XXX_FAMILY_6165,
3813 .name = "Marvell 88E6123",
3814 .num_databases = 4096,
3815 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003816 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003817 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003818 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003819 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003820 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003821 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003822 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003823 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003824 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003825 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003826 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003827 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003828 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003829 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003830 },
3831
3832 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003833 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003834 .family = MV88E6XXX_FAMILY_6185,
3835 .name = "Marvell 88E6131",
3836 .num_databases = 256,
3837 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003838 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003839 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003840 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003841 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003842 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003843 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003844 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003845 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003846 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003847 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003848 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003849 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003850 },
3851
Vivien Didelot990e27b2017-03-28 13:50:32 -04003852 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003853 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003854 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003855 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003856 .num_databases = 4096,
3857 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003858 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003859 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003860 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003861 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003862 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003863 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003864 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003865 .age_time_coeff = 3750,
3866 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003867 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003868 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003869 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003870 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003871 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003872 .ops = &mv88e6141_ops,
3873 },
3874
Vivien Didelotf81ec902016-05-09 13:22:58 -04003875 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003876 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003877 .family = MV88E6XXX_FAMILY_6165,
3878 .name = "Marvell 88E6161",
3879 .num_databases = 4096,
3880 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003881 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003882 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003883 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003884 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003885 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003886 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003887 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003888 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003889 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003890 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003891 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003892 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003893 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003894 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003895 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003896 },
3897
3898 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003899 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003900 .family = MV88E6XXX_FAMILY_6165,
3901 .name = "Marvell 88E6165",
3902 .num_databases = 4096,
3903 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003904 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003905 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003906 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003907 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003908 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003909 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003910 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003911 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003912 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003913 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003914 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003915 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003916 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003917 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003918 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003919 },
3920
3921 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003922 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003923 .family = MV88E6XXX_FAMILY_6351,
3924 .name = "Marvell 88E6171",
3925 .num_databases = 4096,
3926 .num_ports = 7,
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 Lunn443d5a12016-12-03 04:35:18 +01003939 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003940 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003941 },
3942
3943 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003944 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003945 .family = MV88E6XXX_FAMILY_6352,
3946 .name = "Marvell 88E6172",
3947 .num_databases = 4096,
3948 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003949 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003950 .num_gpio = 15,
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_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003963 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003964 },
3965
3966 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003967 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003968 .family = MV88E6XXX_FAMILY_6351,
3969 .name = "Marvell 88E6175",
3970 .num_databases = 4096,
3971 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003972 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003973 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003974 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003975 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003976 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003977 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003978 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003979 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003980 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003981 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003982 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003983 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003984 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003985 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003986 },
3987
3988 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003989 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003990 .family = MV88E6XXX_FAMILY_6352,
3991 .name = "Marvell 88E6176",
3992 .num_databases = 4096,
3993 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003994 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003995 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003996 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003997 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003998 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003999 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004000 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004001 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004002 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004003 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004004 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004005 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004006 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004007 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004008 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004009 },
4010
4011 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004012 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004013 .family = MV88E6XXX_FAMILY_6185,
4014 .name = "Marvell 88E6185",
4015 .num_databases = 256,
4016 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004017 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004018 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004019 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004020 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004021 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004022 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004023 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004024 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004025 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004026 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004027 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004028 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004029 },
4030
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004031 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004032 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004033 .family = MV88E6XXX_FAMILY_6390,
4034 .name = "Marvell 88E6190",
4035 .num_databases = 4096,
4036 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004037 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004038 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004039 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004040 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004041 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004042 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004043 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004044 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004045 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004046 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004047 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004048 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004049 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004050 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004051 .ops = &mv88e6190_ops,
4052 },
4053
4054 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004055 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004056 .family = MV88E6XXX_FAMILY_6390,
4057 .name = "Marvell 88E6190X",
4058 .num_databases = 4096,
4059 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004060 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004061 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004062 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004063 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004064 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004065 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004066 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004067 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004068 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004069 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004070 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004071 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004072 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004073 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004074 .ops = &mv88e6190x_ops,
4075 },
4076
4077 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004078 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004079 .family = MV88E6XXX_FAMILY_6390,
4080 .name = "Marvell 88E6191",
4081 .num_databases = 4096,
4082 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004083 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004084 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004085 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004086 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004087 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004088 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004089 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004090 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004091 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004092 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004093 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004094 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004095 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004096 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004097 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004098 },
4099
Vivien Didelotf81ec902016-05-09 13:22:58 -04004100 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004101 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004102 .family = MV88E6XXX_FAMILY_6352,
4103 .name = "Marvell 88E6240",
4104 .num_databases = 4096,
4105 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004106 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004107 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004108 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004109 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004110 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004111 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004112 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004113 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004114 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004115 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004116 .atu_move_port_mask = 0xf,
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_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004120 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004121 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004122 },
4123
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004124 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004125 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004126 .family = MV88E6XXX_FAMILY_6390,
4127 .name = "Marvell 88E6290",
4128 .num_databases = 4096,
4129 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004130 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004131 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004132 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004133 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004134 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004135 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004136 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004137 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004138 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004139 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004140 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004141 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004142 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004143 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004144 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004145 .ops = &mv88e6290_ops,
4146 },
4147
Vivien Didelotf81ec902016-05-09 13:22:58 -04004148 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004149 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004150 .family = MV88E6XXX_FAMILY_6320,
4151 .name = "Marvell 88E6320",
4152 .num_databases = 4096,
4153 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004154 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004155 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004156 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004157 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004158 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004159 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004160 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004161 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004162 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004163 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004164 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004165 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004166 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004167 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004168 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004169 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004170 },
4171
4172 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004173 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004174 .family = MV88E6XXX_FAMILY_6320,
4175 .name = "Marvell 88E6321",
4176 .num_databases = 4096,
4177 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004178 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004179 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004180 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004181 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004182 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004183 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004184 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004185 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004186 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004187 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004188 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004189 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004190 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004191 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004192 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004193 },
4194
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004195 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004196 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004197 .family = MV88E6XXX_FAMILY_6341,
4198 .name = "Marvell 88E6341",
4199 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004200 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004201 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004202 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004203 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004204 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004205 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004206 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004207 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004208 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004209 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004210 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004211 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004212 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004213 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004214 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004215 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004216 .ops = &mv88e6341_ops,
4217 },
4218
Vivien Didelotf81ec902016-05-09 13:22:58 -04004219 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004220 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004221 .family = MV88E6XXX_FAMILY_6351,
4222 .name = "Marvell 88E6350",
4223 .num_databases = 4096,
4224 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004225 .num_internal_phys = 5,
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 = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004233 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004234 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004235 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004236 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004237 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004238 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004239 },
4240
4241 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004242 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004243 .family = MV88E6XXX_FAMILY_6351,
4244 .name = "Marvell 88E6351",
4245 .num_databases = 4096,
4246 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004247 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004248 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004249 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004250 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004251 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004252 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004253 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004254 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004255 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004256 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004257 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004258 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004259 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004260 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004261 },
4262
4263 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004264 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004265 .family = MV88E6XXX_FAMILY_6352,
4266 .name = "Marvell 88E6352",
4267 .num_databases = 4096,
4268 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004269 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004270 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004271 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004272 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004273 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004274 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004275 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004276 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004277 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004278 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004279 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004280 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004281 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004282 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004283 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004284 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004285 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004286 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004287 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004288 .family = MV88E6XXX_FAMILY_6390,
4289 .name = "Marvell 88E6390",
4290 .num_databases = 4096,
4291 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004292 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004293 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004294 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004295 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004296 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004297 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004298 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004299 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004300 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004301 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004302 .atu_move_port_mask = 0x1f,
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_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004306 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004307 .ops = &mv88e6390_ops,
4308 },
4309 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004310 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004311 .family = MV88E6XXX_FAMILY_6390,
4312 .name = "Marvell 88E6390X",
4313 .num_databases = 4096,
4314 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004315 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004316 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004317 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004318 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004319 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004320 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004321 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004322 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004323 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004324 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004325 .atu_move_port_mask = 0x1f,
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_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004329 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004330 .ops = &mv88e6390x_ops,
4331 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004332};
4333
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004334static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004335{
Vivien Didelota439c062016-04-17 13:23:58 -04004336 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004337
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004338 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4339 if (mv88e6xxx_table[i].prod_num == prod_num)
4340 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004341
Vivien Didelotb9b37712015-10-30 19:39:48 -04004342 return NULL;
4343}
4344
Vivien Didelotfad09c72016-06-21 12:28:20 -04004345static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004346{
4347 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004348 unsigned int prod_num, rev;
4349 u16 id;
4350 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004351
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004352 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004353 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004354 mutex_unlock(&chip->reg_lock);
4355 if (err)
4356 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004357
Vivien Didelot107fcc12017-06-12 12:37:36 -04004358 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4359 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004360
4361 info = mv88e6xxx_lookup_info(prod_num);
4362 if (!info)
4363 return -ENODEV;
4364
Vivien Didelotcaac8542016-06-20 13:14:09 -04004365 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004366 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004367
Vivien Didelotca070c12016-09-02 14:45:34 -04004368 err = mv88e6xxx_g2_require(chip);
4369 if (err)
4370 return err;
4371
Vivien Didelotfad09c72016-06-21 12:28:20 -04004372 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4373 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004374
4375 return 0;
4376}
4377
Vivien Didelotfad09c72016-06-21 12:28:20 -04004378static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004379{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004380 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004381
Vivien Didelotfad09c72016-06-21 12:28:20 -04004382 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4383 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004384 return NULL;
4385
Vivien Didelotfad09c72016-06-21 12:28:20 -04004386 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004387
Vivien Didelotfad09c72016-06-21 12:28:20 -04004388 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004389 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004390
Vivien Didelotfad09c72016-06-21 12:28:20 -04004391 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004392}
4393
Vivien Didelotfad09c72016-06-21 12:28:20 -04004394static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004395 struct mii_bus *bus, int sw_addr)
4396{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004397 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004398 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004399 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004400 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004401 else
4402 return -EINVAL;
4403
Vivien Didelotfad09c72016-06-21 12:28:20 -04004404 chip->bus = bus;
4405 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004406
4407 return 0;
4408}
4409
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004410static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4411 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004412{
Vivien Didelot04bed142016-08-31 18:06:13 -04004413 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004414
Andrew Lunn443d5a12016-12-03 04:35:18 +01004415 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004416}
4417
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004418#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004419static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4420 struct device *host_dev, int sw_addr,
4421 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004422{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004423 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004424 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004425 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004426
Vivien Didelota439c062016-04-17 13:23:58 -04004427 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004428 if (!bus)
4429 return NULL;
4430
Vivien Didelotfad09c72016-06-21 12:28:20 -04004431 chip = mv88e6xxx_alloc_chip(dsa_dev);
4432 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004433 return NULL;
4434
Vivien Didelotcaac8542016-06-20 13:14:09 -04004435 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004436 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004437
Vivien Didelotfad09c72016-06-21 12:28:20 -04004438 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004439 if (err)
4440 goto free;
4441
Vivien Didelotfad09c72016-06-21 12:28:20 -04004442 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004443 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004444 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004445
Andrew Lunndc30c352016-10-16 19:56:49 +02004446 mutex_lock(&chip->reg_lock);
4447 err = mv88e6xxx_switch_reset(chip);
4448 mutex_unlock(&chip->reg_lock);
4449 if (err)
4450 goto free;
4451
Vivien Didelote57e5e72016-08-15 17:19:00 -04004452 mv88e6xxx_phy_init(chip);
4453
Andrew Lunna3c53be52017-01-24 14:53:50 +01004454 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004455 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004456 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004457
Vivien Didelotfad09c72016-06-21 12:28:20 -04004458 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004459
Vivien Didelotfad09c72016-06-21 12:28:20 -04004460 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004461free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004462 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004463
4464 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004465}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004466#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004467
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004468static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004469 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004470{
4471 /* We don't need any dynamic resource from the kernel (yet),
4472 * so skip the prepare phase.
4473 */
4474
4475 return 0;
4476}
4477
4478static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004479 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004480{
Vivien Didelot04bed142016-08-31 18:06:13 -04004481 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004482
4483 mutex_lock(&chip->reg_lock);
4484 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004485 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004486 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4487 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004488 mutex_unlock(&chip->reg_lock);
4489}
4490
4491static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4492 const struct switchdev_obj_port_mdb *mdb)
4493{
Vivien Didelot04bed142016-08-31 18:06:13 -04004494 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004495 int err;
4496
4497 mutex_lock(&chip->reg_lock);
4498 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004499 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004500 mutex_unlock(&chip->reg_lock);
4501
4502 return err;
4503}
4504
Florian Fainellia82f67a2017-01-08 14:52:08 -08004505static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004506#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004507 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004508#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004509 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004510 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004511 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004512 .phylink_validate = mv88e6xxx_validate,
4513 .phylink_mac_link_state = mv88e6xxx_link_state,
4514 .phylink_mac_config = mv88e6xxx_mac_config,
4515 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4516 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004517 .get_strings = mv88e6xxx_get_strings,
4518 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4519 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004520 .port_enable = mv88e6xxx_port_enable,
4521 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004522 .get_mac_eee = mv88e6xxx_get_mac_eee,
4523 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004524 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004525 .get_eeprom = mv88e6xxx_get_eeprom,
4526 .set_eeprom = mv88e6xxx_set_eeprom,
4527 .get_regs_len = mv88e6xxx_get_regs_len,
4528 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004529 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004530 .port_bridge_join = mv88e6xxx_port_bridge_join,
4531 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4532 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004533 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004534 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4535 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4536 .port_vlan_add = mv88e6xxx_port_vlan_add,
4537 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004538 .port_fdb_add = mv88e6xxx_port_fdb_add,
4539 .port_fdb_del = mv88e6xxx_port_fdb_del,
4540 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004541 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4542 .port_mdb_add = mv88e6xxx_port_mdb_add,
4543 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004544 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4545 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004546 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4547 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4548 .port_txtstamp = mv88e6xxx_port_txtstamp,
4549 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4550 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004551};
4552
Florian Fainelliab3d4082017-01-08 14:52:07 -08004553static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4554 .ops = &mv88e6xxx_switch_ops,
4555};
4556
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004557static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004558{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004559 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004560 struct dsa_switch *ds;
4561
Vivien Didelot73b12042017-03-30 17:37:10 -04004562 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004563 if (!ds)
4564 return -ENOMEM;
4565
Vivien Didelotfad09c72016-06-21 12:28:20 -04004566 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004567 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004568 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004569 ds->ageing_time_min = chip->info->age_time_coeff;
4570 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004571
4572 dev_set_drvdata(dev, ds);
4573
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004574 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004575}
4576
Vivien Didelotfad09c72016-06-21 12:28:20 -04004577static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004578{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004579 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004580}
4581
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004582static const void *pdata_device_get_match_data(struct device *dev)
4583{
4584 const struct of_device_id *matches = dev->driver->of_match_table;
4585 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4586
4587 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4588 matches++) {
4589 if (!strcmp(pdata->compatible, matches->compatible))
4590 return matches->data;
4591 }
4592 return NULL;
4593}
4594
Vivien Didelot57d32312016-06-20 13:13:58 -04004595static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004596{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004597 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004598 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004599 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004600 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004601 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004602 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004603 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004604
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004605 if (!np && !pdata)
4606 return -EINVAL;
4607
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004608 if (np)
4609 compat_info = of_device_get_match_data(dev);
4610
4611 if (pdata) {
4612 compat_info = pdata_device_get_match_data(dev);
4613
4614 if (!pdata->netdev)
4615 return -EINVAL;
4616
4617 for (port = 0; port < DSA_MAX_PORTS; port++) {
4618 if (!(pdata->enabled_ports & (1 << port)))
4619 continue;
4620 if (strcmp(pdata->cd.port_names[port], "cpu"))
4621 continue;
4622 pdata->cd.netdev[port] = &pdata->netdev->dev;
4623 break;
4624 }
4625 }
4626
Vivien Didelotcaac8542016-06-20 13:14:09 -04004627 if (!compat_info)
4628 return -EINVAL;
4629
Vivien Didelotfad09c72016-06-21 12:28:20 -04004630 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004631 if (!chip) {
4632 err = -ENOMEM;
4633 goto out;
4634 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004635
Vivien Didelotfad09c72016-06-21 12:28:20 -04004636 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004637
Vivien Didelotfad09c72016-06-21 12:28:20 -04004638 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004639 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004640 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004641
Andrew Lunnb4308f02016-11-21 23:26:55 +01004642 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004643 if (IS_ERR(chip->reset)) {
4644 err = PTR_ERR(chip->reset);
4645 goto out;
4646 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004647
Vivien Didelotfad09c72016-06-21 12:28:20 -04004648 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004649 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004650 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004651
Vivien Didelote57e5e72016-08-15 17:19:00 -04004652 mv88e6xxx_phy_init(chip);
4653
Andrew Lunn00baabe2018-05-19 22:31:35 +02004654 if (chip->info->ops->get_eeprom) {
4655 if (np)
4656 of_property_read_u32(np, "eeprom-length",
4657 &chip->eeprom_len);
4658 else
4659 chip->eeprom_len = pdata->eeprom_len;
4660 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004661
Andrew Lunndc30c352016-10-16 19:56:49 +02004662 mutex_lock(&chip->reg_lock);
4663 err = mv88e6xxx_switch_reset(chip);
4664 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004665 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004666 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004667
Andrew Lunndc30c352016-10-16 19:56:49 +02004668 chip->irq = of_irq_get(np, 0);
4669 if (chip->irq == -EPROBE_DEFER) {
4670 err = chip->irq;
4671 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004672 }
4673
Andrew Lunn294d7112018-02-22 22:58:32 +01004674 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004675 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004676 * controllers
4677 */
4678 mutex_lock(&chip->reg_lock);
4679 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004680 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004681 else
4682 err = mv88e6xxx_irq_poll_setup(chip);
4683 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004684
Andrew Lunn294d7112018-02-22 22:58:32 +01004685 if (err)
4686 goto out;
4687
4688 if (chip->info->g2_irqs > 0) {
4689 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004690 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004691 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004692 }
4693
Andrew Lunn294d7112018-02-22 22:58:32 +01004694 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4695 if (err)
4696 goto out_g2_irq;
4697
4698 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4699 if (err)
4700 goto out_g1_atu_prob_irq;
4701
Andrew Lunna3c53be52017-01-24 14:53:50 +01004702 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004703 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004704 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004705
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004706 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004707 if (err)
4708 goto out_mdio;
4709
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004710 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004711
4712out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004713 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004714out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004715 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004716out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004717 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004718out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004719 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004720 mv88e6xxx_g2_irq_free(chip);
4721out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004722 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004723 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004724 else
4725 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004726out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004727 if (pdata)
4728 dev_put(pdata->netdev);
4729
Andrew Lunndc30c352016-10-16 19:56:49 +02004730 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004731}
4732
4733static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4734{
4735 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004736 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004737
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004738 if (chip->info->ptp_support) {
4739 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004740 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004741 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004742
Andrew Lunn930188c2016-08-22 16:01:03 +02004743 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004744 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004745 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004746
Andrew Lunn76f38f12018-03-17 20:21:09 +01004747 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4748 mv88e6xxx_g1_atu_prob_irq_free(chip);
4749
4750 if (chip->info->g2_irqs > 0)
4751 mv88e6xxx_g2_irq_free(chip);
4752
Andrew Lunn76f38f12018-03-17 20:21:09 +01004753 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004754 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004755 else
4756 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004757}
4758
4759static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004760 {
4761 .compatible = "marvell,mv88e6085",
4762 .data = &mv88e6xxx_table[MV88E6085],
4763 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004764 {
4765 .compatible = "marvell,mv88e6190",
4766 .data = &mv88e6xxx_table[MV88E6190],
4767 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004768 { /* sentinel */ },
4769};
4770
4771MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4772
4773static struct mdio_driver mv88e6xxx_driver = {
4774 .probe = mv88e6xxx_probe,
4775 .remove = mv88e6xxx_remove,
4776 .mdiodrv.driver = {
4777 .name = "mv88e6085",
4778 .of_match_table = mv88e6xxx_of_match,
4779 },
4780};
4781
Ben Hutchings98e67302011-11-25 14:36:19 +00004782static int __init mv88e6xxx_init(void)
4783{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004784 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004785 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004786}
4787module_init(mv88e6xxx_init);
4788
4789static void __exit mv88e6xxx_cleanup(void)
4790{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004791 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004792 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004793}
4794module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004795
4796MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4797MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4798MODULE_LICENSE("GPL");