blob: 1427541df31688eaeec2b5aa6b6ea3c5e5a9db2f [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;
Vivien Didelot552238b2016-05-09 13:22:49 -04002384 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002385 int i;
2386
Vivien Didelotfad09c72016-06-21 12:28:20 -04002387 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002388 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002389
Vivien Didelotfad09c72016-06-21 12:28:20 -04002390 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002391
Vivien Didelot97299342016-07-18 20:45:30 -04002392 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002393 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002394 if (dsa_is_unused_port(ds, i))
2395 continue;
2396
Vivien Didelot97299342016-07-18 20:45:30 -04002397 err = mv88e6xxx_setup_port(chip, i);
2398 if (err)
2399 goto unlock;
2400 }
2401
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002402 err = mv88e6xxx_irl_setup(chip);
2403 if (err)
2404 goto unlock;
2405
Vivien Didelot04a69a12017-10-13 14:18:05 -04002406 err = mv88e6xxx_mac_setup(chip);
2407 if (err)
2408 goto unlock;
2409
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002410 err = mv88e6xxx_phy_setup(chip);
2411 if (err)
2412 goto unlock;
2413
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002414 err = mv88e6xxx_vtu_setup(chip);
2415 if (err)
2416 goto unlock;
2417
Vivien Didelot81228992017-03-30 17:37:08 -04002418 err = mv88e6xxx_pvt_setup(chip);
2419 if (err)
2420 goto unlock;
2421
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002422 err = mv88e6xxx_atu_setup(chip);
2423 if (err)
2424 goto unlock;
2425
Andrew Lunn87fa8862017-11-09 22:29:56 +01002426 err = mv88e6xxx_broadcast_setup(chip, 0);
2427 if (err)
2428 goto unlock;
2429
Vivien Didelot9e907d72017-07-17 13:03:43 -04002430 err = mv88e6xxx_pot_setup(chip);
2431 if (err)
2432 goto unlock;
2433
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002434 err = mv88e6xxx_rmu_setup(chip);
2435 if (err)
2436 goto unlock;
2437
Vivien Didelot51c901a2017-07-17 13:03:41 -04002438 err = mv88e6xxx_rsvd2cpu_setup(chip);
2439 if (err)
2440 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002441
Vivien Didelotb28f8722018-04-26 21:56:44 -04002442 err = mv88e6xxx_trunk_setup(chip);
2443 if (err)
2444 goto unlock;
2445
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002446 err = mv88e6xxx_devmap_setup(chip);
2447 if (err)
2448 goto unlock;
2449
Vivien Didelot93e18d62018-05-11 17:16:35 -04002450 err = mv88e6xxx_pri_setup(chip);
2451 if (err)
2452 goto unlock;
2453
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002454 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002455 if (chip->info->ptp_support) {
2456 err = mv88e6xxx_ptp_setup(chip);
2457 if (err)
2458 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002459
2460 err = mv88e6xxx_hwtstamp_setup(chip);
2461 if (err)
2462 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002463 }
2464
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002465 err = mv88e6xxx_stats_setup(chip);
2466 if (err)
2467 goto unlock;
2468
Vivien Didelot6b17e862015-08-13 12:52:18 -04002469unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002470 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002471
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002472 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002473}
2474
Vivien Didelote57e5e72016-08-15 17:19:00 -04002475static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002476{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002477 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2478 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002479 u16 val;
2480 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002481
Andrew Lunnee26a222017-01-24 14:53:48 +01002482 if (!chip->info->ops->phy_read)
2483 return -EOPNOTSUPP;
2484
Vivien Didelotfad09c72016-06-21 12:28:20 -04002485 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002486 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002487 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002488
Andrew Lunnda9f3302017-02-01 03:40:05 +01002489 if (reg == MII_PHYSID2) {
2490 /* Some internal PHYS don't have a model number. Use
2491 * the mv88e6390 family model number instead.
2492 */
2493 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002494 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002495 }
2496
Vivien Didelote57e5e72016-08-15 17:19:00 -04002497 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002498}
2499
Vivien Didelote57e5e72016-08-15 17:19:00 -04002500static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002501{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002502 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2503 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002504 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002505
Andrew Lunnee26a222017-01-24 14:53:48 +01002506 if (!chip->info->ops->phy_write)
2507 return -EOPNOTSUPP;
2508
Vivien Didelotfad09c72016-06-21 12:28:20 -04002509 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002510 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002511 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002512
2513 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002514}
2515
Vivien Didelotfad09c72016-06-21 12:28:20 -04002516static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002517 struct device_node *np,
2518 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002519{
2520 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002521 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002522 struct mii_bus *bus;
2523 int err;
2524
Andrew Lunn2510bab2018-02-22 01:51:49 +01002525 if (external) {
2526 mutex_lock(&chip->reg_lock);
2527 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2528 mutex_unlock(&chip->reg_lock);
2529
2530 if (err)
2531 return err;
2532 }
2533
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002534 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002535 if (!bus)
2536 return -ENOMEM;
2537
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002538 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002539 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002540 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002541 INIT_LIST_HEAD(&mdio_bus->list);
2542 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002543
Andrew Lunnb516d452016-06-04 21:17:06 +02002544 if (np) {
2545 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002546 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002547 } else {
2548 bus->name = "mv88e6xxx SMI";
2549 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2550 }
2551
2552 bus->read = mv88e6xxx_mdio_read;
2553 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002554 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002555
Andrew Lunn6f882842018-03-17 20:32:05 +01002556 if (!external) {
2557 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2558 if (err)
2559 return err;
2560 }
2561
Florian Fainelli00e798c2018-05-15 16:56:19 -07002562 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002563 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002564 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002565 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002566 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002567 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002568
2569 if (external)
2570 list_add_tail(&mdio_bus->list, &chip->mdios);
2571 else
2572 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002573
2574 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002575}
2576
Andrew Lunna3c53be52017-01-24 14:53:50 +01002577static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2578 { .compatible = "marvell,mv88e6xxx-mdio-external",
2579 .data = (void *)true },
2580 { },
2581};
2582
Andrew Lunn3126aee2017-12-07 01:05:57 +01002583static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2584
2585{
2586 struct mv88e6xxx_mdio_bus *mdio_bus;
2587 struct mii_bus *bus;
2588
2589 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2590 bus = mdio_bus->bus;
2591
Andrew Lunn6f882842018-03-17 20:32:05 +01002592 if (!mdio_bus->external)
2593 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2594
Andrew Lunn3126aee2017-12-07 01:05:57 +01002595 mdiobus_unregister(bus);
2596 }
2597}
2598
Andrew Lunna3c53be52017-01-24 14:53:50 +01002599static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2600 struct device_node *np)
2601{
2602 const struct of_device_id *match;
2603 struct device_node *child;
2604 int err;
2605
2606 /* Always register one mdio bus for the internal/default mdio
2607 * bus. This maybe represented in the device tree, but is
2608 * optional.
2609 */
2610 child = of_get_child_by_name(np, "mdio");
2611 err = mv88e6xxx_mdio_register(chip, child, false);
2612 if (err)
2613 return err;
2614
2615 /* Walk the device tree, and see if there are any other nodes
2616 * which say they are compatible with the external mdio
2617 * bus.
2618 */
2619 for_each_available_child_of_node(np, child) {
2620 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2621 if (match) {
2622 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002623 if (err) {
2624 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002625 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002626 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002627 }
2628 }
2629
2630 return 0;
2631}
2632
Vivien Didelot855b1932016-07-20 18:18:35 -04002633static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2634{
Vivien Didelot04bed142016-08-31 18:06:13 -04002635 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002636
2637 return chip->eeprom_len;
2638}
2639
Vivien Didelot855b1932016-07-20 18:18:35 -04002640static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2641 struct ethtool_eeprom *eeprom, u8 *data)
2642{
Vivien Didelot04bed142016-08-31 18:06:13 -04002643 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002644 int err;
2645
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002646 if (!chip->info->ops->get_eeprom)
2647 return -EOPNOTSUPP;
2648
Vivien Didelot855b1932016-07-20 18:18:35 -04002649 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002650 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002651 mutex_unlock(&chip->reg_lock);
2652
2653 if (err)
2654 return err;
2655
2656 eeprom->magic = 0xc3ec4951;
2657
2658 return 0;
2659}
2660
Vivien Didelot855b1932016-07-20 18:18:35 -04002661static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2662 struct ethtool_eeprom *eeprom, u8 *data)
2663{
Vivien Didelot04bed142016-08-31 18:06:13 -04002664 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002665 int err;
2666
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002667 if (!chip->info->ops->set_eeprom)
2668 return -EOPNOTSUPP;
2669
Vivien Didelot855b1932016-07-20 18:18:35 -04002670 if (eeprom->magic != 0xc3ec4951)
2671 return -EINVAL;
2672
2673 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002674 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002675 mutex_unlock(&chip->reg_lock);
2676
2677 return err;
2678}
2679
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002680static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002681 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002682 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2683 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002684 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002685 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002686 .phy_read = mv88e6185_phy_ppu_read,
2687 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002688 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002689 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002690 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002691 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002692 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002693 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002694 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002695 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002696 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002697 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002698 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002699 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002700 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002701 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002702 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2703 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002704 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002705 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2706 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002707 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002708 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002709 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002710 .ppu_enable = mv88e6185_g1_ppu_enable,
2711 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002712 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002713 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002714 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002715 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002716 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002717};
2718
2719static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002720 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002721 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2722 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002723 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002724 .phy_read = mv88e6185_phy_ppu_read,
2725 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002726 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002727 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002728 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002729 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002730 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002731 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002732 .port_link_state = mv88e6185_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002733 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002734 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002735 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2736 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002737 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002738 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002739 .ppu_enable = mv88e6185_g1_ppu_enable,
2740 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002741 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002742 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002743 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002744 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002745};
2746
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002747static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002748 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002749 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2750 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002751 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002752 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2753 .phy_read = mv88e6xxx_g2_smi_phy_read,
2754 .phy_write = mv88e6xxx_g2_smi_phy_write,
2755 .port_set_link = mv88e6xxx_port_set_link,
2756 .port_set_duplex = mv88e6xxx_port_set_duplex,
2757 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002758 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002759 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002760 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002761 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002762 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002763 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002764 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002765 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002766 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002767 .port_link_state = mv88e6352_port_link_state,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002768 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002769 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002770 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2771 .stats_get_strings = mv88e6095_stats_get_strings,
2772 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002773 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2774 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002775 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002776 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002777 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002778 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002779 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002780 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002781 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002782 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002783};
2784
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002785static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002786 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002787 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2788 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002789 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002790 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002791 .phy_read = mv88e6xxx_g2_smi_phy_read,
2792 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002793 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002794 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002795 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002796 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002797 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002798 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002799 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002800 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002801 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002802 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002803 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2804 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002805 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002806 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2807 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002808 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002809 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002810 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002811 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002812 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002813 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002814 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002815};
2816
2817static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002818 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002819 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2820 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002821 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002822 .phy_read = mv88e6185_phy_ppu_read,
2823 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002824 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002825 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002826 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002827 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002828 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002829 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002830 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002831 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002832 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002833 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002834 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002835 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002836 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002837 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002838 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002839 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2840 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002841 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002842 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2843 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002844 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002845 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002846 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002847 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002848 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002849 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002850 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002851 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002852 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002853};
2854
Vivien Didelot990e27b2017-03-28 13:50:32 -04002855static const struct mv88e6xxx_ops mv88e6141_ops = {
2856 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002857 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2858 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002859 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002860 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2861 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2862 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2863 .phy_read = mv88e6xxx_g2_smi_phy_read,
2864 .phy_write = mv88e6xxx_g2_smi_phy_write,
2865 .port_set_link = mv88e6xxx_port_set_link,
2866 .port_set_duplex = mv88e6xxx_port_set_duplex,
2867 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2868 .port_set_speed = mv88e6390_port_set_speed,
2869 .port_tag_remap = mv88e6095_port_tag_remap,
2870 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2871 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2872 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002873 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002874 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002875 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002876 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2877 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002878 .port_link_state = mv88e6352_port_link_state,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002879 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002880 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002881 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2882 .stats_get_strings = mv88e6320_stats_get_strings,
2883 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002884 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2885 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002886 .watchdog_ops = &mv88e6390_watchdog_ops,
2887 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002888 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002889 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002890 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002891 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002892 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002893 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02002894 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002895};
2896
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002897static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002898 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002899 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2900 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002901 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002902 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002903 .phy_read = mv88e6xxx_g2_smi_phy_read,
2904 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002905 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002906 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002907 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002908 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002909 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002910 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002911 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002912 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002913 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002914 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002915 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002916 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002917 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002918 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002919 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002920 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2921 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002922 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002923 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2924 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002925 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002926 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002927 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002928 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002929 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002930 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002931 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002932 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002933 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002934};
2935
2936static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002937 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002938 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2939 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002940 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002941 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002942 .phy_read = mv88e6165_phy_read,
2943 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002944 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002945 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002946 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002947 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002948 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002949 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002950 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002951 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002952 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2953 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002954 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002955 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2956 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002957 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002958 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002959 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002960 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002961 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002962 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002963 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002964 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002965 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002966};
2967
2968static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002969 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002970 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2971 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002972 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002973 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002974 .phy_read = mv88e6xxx_g2_smi_phy_read,
2975 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002976 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002977 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01002978 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002979 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002980 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002981 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002982 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002983 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002984 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002985 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002986 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002987 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002988 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002989 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002990 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002991 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002992 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2993 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002994 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002995 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2996 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002997 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002998 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002999 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003000 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003001 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003002 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003003 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003004};
3005
3006static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003007 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003008 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3009 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003010 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003011 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3012 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003013 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003014 .phy_read = mv88e6xxx_g2_smi_phy_read,
3015 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003016 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003017 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003018 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003019 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003020 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003021 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003022 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003023 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003024 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003025 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003026 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003027 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003028 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003029 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003030 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003031 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003032 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3033 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003034 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003035 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3036 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003037 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003038 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003039 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003040 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003041 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003042 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003043 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003044 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003045 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003046 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003047};
3048
3049static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003050 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003051 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3052 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003053 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003054 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003055 .phy_read = mv88e6xxx_g2_smi_phy_read,
3056 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003057 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003058 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003059 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003060 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003061 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003062 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003063 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003064 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003065 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003066 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003067 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003068 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003069 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003070 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003071 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003072 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003073 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3074 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003075 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003076 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3077 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003078 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003079 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003080 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003081 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003082 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003083 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003084 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003085};
3086
3087static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003088 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003089 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3090 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003091 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003092 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3093 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003094 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003095 .phy_read = mv88e6xxx_g2_smi_phy_read,
3096 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003097 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003098 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003099 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003100 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003101 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003102 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003103 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003104 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003105 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003106 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003107 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003108 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003109 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003110 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003111 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003112 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003113 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3114 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003115 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003116 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3117 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003118 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003119 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003120 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003121 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003122 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003123 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003124 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003125 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003126 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003127 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003128};
3129
3130static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003131 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003132 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3133 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003134 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003135 .phy_read = mv88e6185_phy_ppu_read,
3136 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003137 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003138 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003139 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003140 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003141 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003142 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003143 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003144 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003145 .port_link_state = mv88e6185_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003146 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003147 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003148 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3149 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003150 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003151 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3152 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003153 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003154 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003155 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003156 .ppu_enable = mv88e6185_g1_ppu_enable,
3157 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003158 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003159 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003160 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003161 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003162};
3163
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003164static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003165 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003166 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003167 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3168 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003169 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3170 .phy_read = mv88e6xxx_g2_smi_phy_read,
3171 .phy_write = mv88e6xxx_g2_smi_phy_write,
3172 .port_set_link = mv88e6xxx_port_set_link,
3173 .port_set_duplex = mv88e6xxx_port_set_duplex,
3174 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3175 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003176 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003177 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003178 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003179 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003180 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003181 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003182 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003183 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn79523472016-11-21 23:27:00 +01003184 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003185 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003186 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3187 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003188 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003189 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3190 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003191 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003192 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003193 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003194 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003195 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003196 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3197 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003198 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003199 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003200 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003201};
3202
3203static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003204 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003205 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003206 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3207 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003208 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3209 .phy_read = mv88e6xxx_g2_smi_phy_read,
3210 .phy_write = mv88e6xxx_g2_smi_phy_write,
3211 .port_set_link = mv88e6xxx_port_set_link,
3212 .port_set_duplex = mv88e6xxx_port_set_duplex,
3213 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3214 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003215 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003216 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003217 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003218 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003219 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003220 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003221 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003222 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn79523472016-11-21 23:27:00 +01003223 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003224 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003225 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3226 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003227 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003228 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3229 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003230 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003231 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003232 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003233 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003234 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003235 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3236 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003237 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003238 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003239 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003240};
3241
3242static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003243 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003244 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003245 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3246 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003247 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3248 .phy_read = mv88e6xxx_g2_smi_phy_read,
3249 .phy_write = mv88e6xxx_g2_smi_phy_write,
3250 .port_set_link = mv88e6xxx_port_set_link,
3251 .port_set_duplex = mv88e6xxx_port_set_duplex,
3252 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3253 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003254 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003255 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003256 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003257 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003258 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003259 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003260 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003261 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn79523472016-11-21 23:27:00 +01003262 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003263 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003264 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3265 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003266 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003267 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3268 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003269 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003270 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003271 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003272 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003273 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003274 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3275 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003276 .serdes_power = mv88e6390_serdes_power,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003277 .avb_ops = &mv88e6390_avb_ops,
3278 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003279 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003280};
3281
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003282static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003283 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003284 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3285 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003286 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003287 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3288 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003289 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003290 .phy_read = mv88e6xxx_g2_smi_phy_read,
3291 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003292 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003293 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003294 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003295 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003296 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003297 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003298 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003299 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003300 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003301 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003302 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003303 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003304 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003305 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003306 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003307 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003308 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3309 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003310 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003311 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3312 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003313 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003314 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003315 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003316 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003317 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003318 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003319 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003320 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003321 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003322 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003323 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003324 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003325};
3326
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003327static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003328 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003329 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003330 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3331 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003332 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3333 .phy_read = mv88e6xxx_g2_smi_phy_read,
3334 .phy_write = mv88e6xxx_g2_smi_phy_write,
3335 .port_set_link = mv88e6xxx_port_set_link,
3336 .port_set_duplex = mv88e6xxx_port_set_duplex,
3337 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3338 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003339 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003340 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003341 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003342 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003343 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003344 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003345 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003346 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003347 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn79523472016-11-21 23:27:00 +01003348 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003349 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003350 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3351 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003352 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003353 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3354 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003355 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003356 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003357 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003358 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003359 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003360 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3361 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003362 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003363 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003364 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003365 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003366 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003367};
3368
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003369static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003370 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003371 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3372 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003373 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003374 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3375 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003376 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003377 .phy_read = mv88e6xxx_g2_smi_phy_read,
3378 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003379 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003380 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003381 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003382 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003383 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003384 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003385 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003386 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003387 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003388 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003389 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003390 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003391 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003392 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003393 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003394 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3395 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003396 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003397 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3398 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003399 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003400 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003401 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003402 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003403 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003404 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003405 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003406 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003407 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003408};
3409
3410static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003411 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003412 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3413 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003414 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003415 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3416 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003417 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003418 .phy_read = mv88e6xxx_g2_smi_phy_read,
3419 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003420 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003421 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003422 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003423 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003424 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003425 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003426 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003427 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003428 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003429 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003430 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003431 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003432 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003433 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003434 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003435 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3436 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003437 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003438 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3439 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003440 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003441 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003442 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003443 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003444 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003445 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003446 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003447};
3448
Vivien Didelot16e329a2017-03-28 13:50:33 -04003449static const struct mv88e6xxx_ops mv88e6341_ops = {
3450 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003451 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3452 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003453 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003454 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3455 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3456 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3457 .phy_read = mv88e6xxx_g2_smi_phy_read,
3458 .phy_write = mv88e6xxx_g2_smi_phy_write,
3459 .port_set_link = mv88e6xxx_port_set_link,
3460 .port_set_duplex = mv88e6xxx_port_set_duplex,
3461 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3462 .port_set_speed = mv88e6390_port_set_speed,
3463 .port_tag_remap = mv88e6095_port_tag_remap,
3464 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3465 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3466 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003467 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003468 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003469 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003470 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3471 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003472 .port_link_state = mv88e6352_port_link_state,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003473 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003474 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003475 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3476 .stats_get_strings = mv88e6320_stats_get_strings,
3477 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003478 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3479 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003480 .watchdog_ops = &mv88e6390_watchdog_ops,
3481 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003482 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003483 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003484 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003485 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003486 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003487 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003488 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003489 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003490 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003491};
3492
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003493static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003494 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003495 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3496 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003497 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003498 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003499 .phy_read = mv88e6xxx_g2_smi_phy_read,
3500 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003501 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003502 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003503 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003504 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003505 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003506 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003507 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003508 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003509 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003510 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003511 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003512 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003513 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003514 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003515 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003516 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003517 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3518 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003519 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003520 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3521 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003522 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003523 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003524 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003525 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003526 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003527 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003528 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003529};
3530
3531static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003532 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003533 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3534 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003535 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003536 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003537 .phy_read = mv88e6xxx_g2_smi_phy_read,
3538 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003539 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003540 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003541 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003542 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003543 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003544 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003545 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003546 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003547 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003548 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003549 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003550 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003551 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003552 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003553 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003554 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003555 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3556 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003557 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003558 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3559 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003560 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003561 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003562 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003563 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003564 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003565 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003566 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003567 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003568 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003569};
3570
3571static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003572 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003573 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3574 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003575 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003576 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3577 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003578 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003579 .phy_read = mv88e6xxx_g2_smi_phy_read,
3580 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003581 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003582 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003583 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003584 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003585 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003586 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003587 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003588 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003589 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003590 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003591 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003592 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003593 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003594 .port_link_state = mv88e6352_port_link_state,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003595 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003596 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003597 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3598 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003599 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003600 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3601 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003602 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003603 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003604 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003605 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003606 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003607 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003608 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003609 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003610 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003611 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003612 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003613 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3614 .serdes_get_strings = mv88e6352_serdes_get_strings,
3615 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003616 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003617};
3618
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003619static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003620 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003621 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003622 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3623 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003624 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3625 .phy_read = mv88e6xxx_g2_smi_phy_read,
3626 .phy_write = mv88e6xxx_g2_smi_phy_write,
3627 .port_set_link = mv88e6xxx_port_set_link,
3628 .port_set_duplex = mv88e6xxx_port_set_duplex,
3629 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3630 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003631 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003632 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003633 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003634 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003635 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003636 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003637 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003638 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003639 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003640 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003641 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn79523472016-11-21 23:27:00 +01003642 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003643 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003644 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3645 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003646 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003647 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3648 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003649 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003650 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003651 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003652 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003653 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003654 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3655 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003656 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003657 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003658 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003659 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003660 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003661};
3662
3663static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003664 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003665 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003666 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3667 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003668 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3669 .phy_read = mv88e6xxx_g2_smi_phy_read,
3670 .phy_write = mv88e6xxx_g2_smi_phy_write,
3671 .port_set_link = mv88e6xxx_port_set_link,
3672 .port_set_duplex = mv88e6xxx_port_set_duplex,
3673 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3674 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003675 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003676 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003677 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003678 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003679 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003680 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003681 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003682 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003683 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003684 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003685 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn79523472016-11-21 23:27:00 +01003686 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003687 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003688 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3689 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003690 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003691 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3692 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003693 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003694 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003695 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003696 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003697 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003698 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3699 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003700 .serdes_power = mv88e6390_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003701 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003702 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003703 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003704 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003705};
3706
Vivien Didelotf81ec902016-05-09 13:22:58 -04003707static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3708 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003709 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003710 .family = MV88E6XXX_FAMILY_6097,
3711 .name = "Marvell 88E6085",
3712 .num_databases = 4096,
3713 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003714 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003715 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003716 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003717 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003718 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003719 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003720 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003721 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003722 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003723 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003724 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003725 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003726 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003727 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003728 },
3729
3730 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003731 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003732 .family = MV88E6XXX_FAMILY_6095,
3733 .name = "Marvell 88E6095/88E6095F",
3734 .num_databases = 256,
3735 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003736 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003737 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003738 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003739 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003740 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003741 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003742 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003743 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003744 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003745 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003746 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003747 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003748 },
3749
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003750 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003751 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003752 .family = MV88E6XXX_FAMILY_6097,
3753 .name = "Marvell 88E6097/88E6097F",
3754 .num_databases = 4096,
3755 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003756 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003757 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003758 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003759 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003760 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003761 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003762 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003763 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003764 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003765 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003766 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003767 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003768 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003769 .ops = &mv88e6097_ops,
3770 },
3771
Vivien Didelotf81ec902016-05-09 13:22:58 -04003772 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003773 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003774 .family = MV88E6XXX_FAMILY_6165,
3775 .name = "Marvell 88E6123",
3776 .num_databases = 4096,
3777 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003778 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003779 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003780 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003781 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003782 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003783 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003784 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003785 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003786 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003787 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003788 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003789 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003790 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003791 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003792 },
3793
3794 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003795 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003796 .family = MV88E6XXX_FAMILY_6185,
3797 .name = "Marvell 88E6131",
3798 .num_databases = 256,
3799 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003800 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003801 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003802 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003803 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003804 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003805 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003806 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003807 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003808 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003809 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003810 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003811 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003812 },
3813
Vivien Didelot990e27b2017-03-28 13:50:32 -04003814 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003815 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003816 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003817 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003818 .num_databases = 4096,
3819 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003820 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003821 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003822 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003823 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003824 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003825 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003826 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003827 .age_time_coeff = 3750,
3828 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003829 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003830 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003831 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003832 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003833 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003834 .ops = &mv88e6141_ops,
3835 },
3836
Vivien Didelotf81ec902016-05-09 13:22:58 -04003837 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003838 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003839 .family = MV88E6XXX_FAMILY_6165,
3840 .name = "Marvell 88E6161",
3841 .num_databases = 4096,
3842 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003843 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003844 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003845 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003846 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003847 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003848 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003849 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003850 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003851 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003852 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003853 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003854 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003855 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003856 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003857 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003858 },
3859
3860 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003861 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003862 .family = MV88E6XXX_FAMILY_6165,
3863 .name = "Marvell 88E6165",
3864 .num_databases = 4096,
3865 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003866 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003867 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003868 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003869 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003870 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003871 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003872 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003873 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003874 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003875 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003876 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003877 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003878 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003879 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003880 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003881 },
3882
3883 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003884 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003885 .family = MV88E6XXX_FAMILY_6351,
3886 .name = "Marvell 88E6171",
3887 .num_databases = 4096,
3888 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003889 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003890 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003891 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003892 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003893 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003894 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003895 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003896 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003897 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003898 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003899 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003900 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003901 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003902 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003903 },
3904
3905 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003906 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003907 .family = MV88E6XXX_FAMILY_6352,
3908 .name = "Marvell 88E6172",
3909 .num_databases = 4096,
3910 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003911 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003912 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003913 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003914 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003915 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003916 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003917 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003918 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003919 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003920 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003921 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003922 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003923 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003924 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003925 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003926 },
3927
3928 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003929 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003930 .family = MV88E6XXX_FAMILY_6351,
3931 .name = "Marvell 88E6175",
3932 .num_databases = 4096,
3933 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003934 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003935 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003936 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003937 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003938 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003939 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003940 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003941 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003942 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003943 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003944 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003945 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003946 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003947 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003948 },
3949
3950 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003951 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003952 .family = MV88E6XXX_FAMILY_6352,
3953 .name = "Marvell 88E6176",
3954 .num_databases = 4096,
3955 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003956 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003957 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003958 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003959 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003960 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003961 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003962 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003963 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003964 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003965 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003966 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003967 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003968 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003969 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003970 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003971 },
3972
3973 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003974 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003975 .family = MV88E6XXX_FAMILY_6185,
3976 .name = "Marvell 88E6185",
3977 .num_databases = 256,
3978 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003979 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003980 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003981 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003982 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003983 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003984 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003985 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003986 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003987 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003988 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003989 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003990 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003991 },
3992
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003993 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003994 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003995 .family = MV88E6XXX_FAMILY_6390,
3996 .name = "Marvell 88E6190",
3997 .num_databases = 4096,
3998 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01003999 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004000 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004001 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004002 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004003 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004004 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004005 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004006 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004007 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004008 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004009 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004010 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004011 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004012 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004013 .ops = &mv88e6190_ops,
4014 },
4015
4016 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004017 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004018 .family = MV88E6XXX_FAMILY_6390,
4019 .name = "Marvell 88E6190X",
4020 .num_databases = 4096,
4021 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004022 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004023 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004024 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004025 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004026 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004027 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004028 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004029 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004030 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004031 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004032 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004033 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004034 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004035 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004036 .ops = &mv88e6190x_ops,
4037 },
4038
4039 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004040 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004041 .family = MV88E6XXX_FAMILY_6390,
4042 .name = "Marvell 88E6191",
4043 .num_databases = 4096,
4044 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004045 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004046 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004047 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004048 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004049 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004050 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004051 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004052 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004053 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004054 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004055 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004056 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004057 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004058 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004059 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004060 },
4061
Vivien Didelotf81ec902016-05-09 13:22:58 -04004062 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004063 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004064 .family = MV88E6XXX_FAMILY_6352,
4065 .name = "Marvell 88E6240",
4066 .num_databases = 4096,
4067 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004068 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004069 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004070 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004071 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004072 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004073 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004074 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004075 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004076 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004077 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004078 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004079 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004080 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004081 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004082 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004083 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004084 },
4085
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004086 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004087 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004088 .family = MV88E6XXX_FAMILY_6390,
4089 .name = "Marvell 88E6290",
4090 .num_databases = 4096,
4091 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004092 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004093 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004094 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004095 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004096 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004097 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004098 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004099 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004100 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004101 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004102 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004103 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004104 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004105 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004106 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004107 .ops = &mv88e6290_ops,
4108 },
4109
Vivien Didelotf81ec902016-05-09 13:22:58 -04004110 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004111 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004112 .family = MV88E6XXX_FAMILY_6320,
4113 .name = "Marvell 88E6320",
4114 .num_databases = 4096,
4115 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004116 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004117 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004118 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004119 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004120 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004121 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004122 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004123 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004124 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004125 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004126 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004127 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004128 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004129 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004130 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004131 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004132 },
4133
4134 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004135 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004136 .family = MV88E6XXX_FAMILY_6320,
4137 .name = "Marvell 88E6321",
4138 .num_databases = 4096,
4139 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004140 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004141 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004142 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004143 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004144 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004145 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004146 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004147 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004148 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004149 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004150 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004151 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004152 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004153 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004154 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004155 },
4156
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004157 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004158 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004159 .family = MV88E6XXX_FAMILY_6341,
4160 .name = "Marvell 88E6341",
4161 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004162 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004163 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004164 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004165 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004166 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004167 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004168 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004169 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004170 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004171 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004172 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004173 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004174 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004175 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004176 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004177 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004178 .ops = &mv88e6341_ops,
4179 },
4180
Vivien Didelotf81ec902016-05-09 13:22:58 -04004181 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004182 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004183 .family = MV88E6XXX_FAMILY_6351,
4184 .name = "Marvell 88E6350",
4185 .num_databases = 4096,
4186 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004187 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004188 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004189 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004190 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004191 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004192 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004193 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004194 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004195 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004196 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004197 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004198 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004199 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004200 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004201 },
4202
4203 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004204 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004205 .family = MV88E6XXX_FAMILY_6351,
4206 .name = "Marvell 88E6351",
4207 .num_databases = 4096,
4208 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004209 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004210 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004211 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004212 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004213 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004214 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004215 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004216 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004217 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004218 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004219 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004220 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004221 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004222 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004223 },
4224
4225 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004226 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004227 .family = MV88E6XXX_FAMILY_6352,
4228 .name = "Marvell 88E6352",
4229 .num_databases = 4096,
4230 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004231 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004232 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004233 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004234 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004235 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004236 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004237 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004238 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004239 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004240 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004241 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004242 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004243 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004244 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004245 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004246 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004247 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004248 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004249 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004250 .family = MV88E6XXX_FAMILY_6390,
4251 .name = "Marvell 88E6390",
4252 .num_databases = 4096,
4253 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004254 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004255 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004256 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004257 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004258 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004259 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004260 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004261 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004262 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004263 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004264 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004265 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004266 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004267 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004268 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004269 .ops = &mv88e6390_ops,
4270 },
4271 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004272 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004273 .family = MV88E6XXX_FAMILY_6390,
4274 .name = "Marvell 88E6390X",
4275 .num_databases = 4096,
4276 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004277 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004278 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004279 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004280 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004281 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004282 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004283 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004284 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004285 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004286 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004287 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004288 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004289 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004290 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004291 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004292 .ops = &mv88e6390x_ops,
4293 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004294};
4295
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004296static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004297{
Vivien Didelota439c062016-04-17 13:23:58 -04004298 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004299
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004300 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4301 if (mv88e6xxx_table[i].prod_num == prod_num)
4302 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004303
Vivien Didelotb9b37712015-10-30 19:39:48 -04004304 return NULL;
4305}
4306
Vivien Didelotfad09c72016-06-21 12:28:20 -04004307static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004308{
4309 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004310 unsigned int prod_num, rev;
4311 u16 id;
4312 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004313
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004314 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004315 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004316 mutex_unlock(&chip->reg_lock);
4317 if (err)
4318 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004319
Vivien Didelot107fcc12017-06-12 12:37:36 -04004320 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4321 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004322
4323 info = mv88e6xxx_lookup_info(prod_num);
4324 if (!info)
4325 return -ENODEV;
4326
Vivien Didelotcaac8542016-06-20 13:14:09 -04004327 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004328 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004329
Vivien Didelotca070c12016-09-02 14:45:34 -04004330 err = mv88e6xxx_g2_require(chip);
4331 if (err)
4332 return err;
4333
Vivien Didelotfad09c72016-06-21 12:28:20 -04004334 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4335 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004336
4337 return 0;
4338}
4339
Vivien Didelotfad09c72016-06-21 12:28:20 -04004340static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004341{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004342 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004343
Vivien Didelotfad09c72016-06-21 12:28:20 -04004344 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4345 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004346 return NULL;
4347
Vivien Didelotfad09c72016-06-21 12:28:20 -04004348 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004349
Vivien Didelotfad09c72016-06-21 12:28:20 -04004350 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004351 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004352
Vivien Didelotfad09c72016-06-21 12:28:20 -04004353 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004354}
4355
Vivien Didelotfad09c72016-06-21 12:28:20 -04004356static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004357 struct mii_bus *bus, int sw_addr)
4358{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004359 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004360 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004361 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004362 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004363 else
4364 return -EINVAL;
4365
Vivien Didelotfad09c72016-06-21 12:28:20 -04004366 chip->bus = bus;
4367 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004368
4369 return 0;
4370}
4371
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004372static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4373 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004374{
Vivien Didelot04bed142016-08-31 18:06:13 -04004375 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004376
Andrew Lunn443d5a12016-12-03 04:35:18 +01004377 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004378}
4379
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004380#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004381static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4382 struct device *host_dev, int sw_addr,
4383 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004384{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004385 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004386 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004387 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004388
Vivien Didelota439c062016-04-17 13:23:58 -04004389 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004390 if (!bus)
4391 return NULL;
4392
Vivien Didelotfad09c72016-06-21 12:28:20 -04004393 chip = mv88e6xxx_alloc_chip(dsa_dev);
4394 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004395 return NULL;
4396
Vivien Didelotcaac8542016-06-20 13:14:09 -04004397 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004398 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004399
Vivien Didelotfad09c72016-06-21 12:28:20 -04004400 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004401 if (err)
4402 goto free;
4403
Vivien Didelotfad09c72016-06-21 12:28:20 -04004404 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004405 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004406 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004407
Andrew Lunndc30c352016-10-16 19:56:49 +02004408 mutex_lock(&chip->reg_lock);
4409 err = mv88e6xxx_switch_reset(chip);
4410 mutex_unlock(&chip->reg_lock);
4411 if (err)
4412 goto free;
4413
Vivien Didelote57e5e72016-08-15 17:19:00 -04004414 mv88e6xxx_phy_init(chip);
4415
Andrew Lunna3c53be52017-01-24 14:53:50 +01004416 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004417 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004418 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004419
Vivien Didelotfad09c72016-06-21 12:28:20 -04004420 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004421
Vivien Didelotfad09c72016-06-21 12:28:20 -04004422 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004423free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004424 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004425
4426 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004427}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004428#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004429
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004430static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004431 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004432{
4433 /* We don't need any dynamic resource from the kernel (yet),
4434 * so skip the prepare phase.
4435 */
4436
4437 return 0;
4438}
4439
4440static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004441 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004442{
Vivien Didelot04bed142016-08-31 18:06:13 -04004443 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004444
4445 mutex_lock(&chip->reg_lock);
4446 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004447 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004448 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4449 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004450 mutex_unlock(&chip->reg_lock);
4451}
4452
4453static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4454 const struct switchdev_obj_port_mdb *mdb)
4455{
Vivien Didelot04bed142016-08-31 18:06:13 -04004456 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004457 int err;
4458
4459 mutex_lock(&chip->reg_lock);
4460 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004461 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004462 mutex_unlock(&chip->reg_lock);
4463
4464 return err;
4465}
4466
Florian Fainellia82f67a2017-01-08 14:52:08 -08004467static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004468#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004469 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004470#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004471 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004472 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004473 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004474 .phylink_validate = mv88e6xxx_validate,
4475 .phylink_mac_link_state = mv88e6xxx_link_state,
4476 .phylink_mac_config = mv88e6xxx_mac_config,
4477 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4478 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004479 .get_strings = mv88e6xxx_get_strings,
4480 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4481 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004482 .port_enable = mv88e6xxx_port_enable,
4483 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004484 .get_mac_eee = mv88e6xxx_get_mac_eee,
4485 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004486 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004487 .get_eeprom = mv88e6xxx_get_eeprom,
4488 .set_eeprom = mv88e6xxx_set_eeprom,
4489 .get_regs_len = mv88e6xxx_get_regs_len,
4490 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004491 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004492 .port_bridge_join = mv88e6xxx_port_bridge_join,
4493 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4494 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004495 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004496 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4497 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4498 .port_vlan_add = mv88e6xxx_port_vlan_add,
4499 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004500 .port_fdb_add = mv88e6xxx_port_fdb_add,
4501 .port_fdb_del = mv88e6xxx_port_fdb_del,
4502 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004503 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4504 .port_mdb_add = mv88e6xxx_port_mdb_add,
4505 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004506 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4507 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004508 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4509 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4510 .port_txtstamp = mv88e6xxx_port_txtstamp,
4511 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4512 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004513};
4514
Florian Fainelliab3d4082017-01-08 14:52:07 -08004515static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4516 .ops = &mv88e6xxx_switch_ops,
4517};
4518
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004519static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004520{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004521 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004522 struct dsa_switch *ds;
4523
Vivien Didelot73b12042017-03-30 17:37:10 -04004524 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004525 if (!ds)
4526 return -ENOMEM;
4527
Vivien Didelotfad09c72016-06-21 12:28:20 -04004528 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004529 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004530 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004531 ds->ageing_time_min = chip->info->age_time_coeff;
4532 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004533
4534 dev_set_drvdata(dev, ds);
4535
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004536 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004537}
4538
Vivien Didelotfad09c72016-06-21 12:28:20 -04004539static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004540{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004541 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004542}
4543
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004544static const void *pdata_device_get_match_data(struct device *dev)
4545{
4546 const struct of_device_id *matches = dev->driver->of_match_table;
4547 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4548
4549 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4550 matches++) {
4551 if (!strcmp(pdata->compatible, matches->compatible))
4552 return matches->data;
4553 }
4554 return NULL;
4555}
4556
Vivien Didelot57d32312016-06-20 13:13:58 -04004557static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004558{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004559 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004560 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004561 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004562 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004563 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004564 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004565 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004566
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004567 if (!np && !pdata)
4568 return -EINVAL;
4569
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004570 if (np)
4571 compat_info = of_device_get_match_data(dev);
4572
4573 if (pdata) {
4574 compat_info = pdata_device_get_match_data(dev);
4575
4576 if (!pdata->netdev)
4577 return -EINVAL;
4578
4579 for (port = 0; port < DSA_MAX_PORTS; port++) {
4580 if (!(pdata->enabled_ports & (1 << port)))
4581 continue;
4582 if (strcmp(pdata->cd.port_names[port], "cpu"))
4583 continue;
4584 pdata->cd.netdev[port] = &pdata->netdev->dev;
4585 break;
4586 }
4587 }
4588
Vivien Didelotcaac8542016-06-20 13:14:09 -04004589 if (!compat_info)
4590 return -EINVAL;
4591
Vivien Didelotfad09c72016-06-21 12:28:20 -04004592 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004593 if (!chip) {
4594 err = -ENOMEM;
4595 goto out;
4596 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004597
Vivien Didelotfad09c72016-06-21 12:28:20 -04004598 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004599
Vivien Didelotfad09c72016-06-21 12:28:20 -04004600 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004601 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004602 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004603
Andrew Lunnb4308f02016-11-21 23:26:55 +01004604 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004605 if (IS_ERR(chip->reset)) {
4606 err = PTR_ERR(chip->reset);
4607 goto out;
4608 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004609
Vivien Didelotfad09c72016-06-21 12:28:20 -04004610 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004611 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004612 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004613
Vivien Didelote57e5e72016-08-15 17:19:00 -04004614 mv88e6xxx_phy_init(chip);
4615
Andrew Lunn00baabe2018-05-19 22:31:35 +02004616 if (chip->info->ops->get_eeprom) {
4617 if (np)
4618 of_property_read_u32(np, "eeprom-length",
4619 &chip->eeprom_len);
4620 else
4621 chip->eeprom_len = pdata->eeprom_len;
4622 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004623
Andrew Lunndc30c352016-10-16 19:56:49 +02004624 mutex_lock(&chip->reg_lock);
4625 err = mv88e6xxx_switch_reset(chip);
4626 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004627 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004628 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004629
Andrew Lunndc30c352016-10-16 19:56:49 +02004630 chip->irq = of_irq_get(np, 0);
4631 if (chip->irq == -EPROBE_DEFER) {
4632 err = chip->irq;
4633 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004634 }
4635
Andrew Lunn294d7112018-02-22 22:58:32 +01004636 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004637 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004638 * controllers
4639 */
4640 mutex_lock(&chip->reg_lock);
4641 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004642 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004643 else
4644 err = mv88e6xxx_irq_poll_setup(chip);
4645 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004646
Andrew Lunn294d7112018-02-22 22:58:32 +01004647 if (err)
4648 goto out;
4649
4650 if (chip->info->g2_irqs > 0) {
4651 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004652 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004653 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004654 }
4655
Andrew Lunn294d7112018-02-22 22:58:32 +01004656 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4657 if (err)
4658 goto out_g2_irq;
4659
4660 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4661 if (err)
4662 goto out_g1_atu_prob_irq;
4663
Andrew Lunna3c53be52017-01-24 14:53:50 +01004664 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004665 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004666 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004667
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004668 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004669 if (err)
4670 goto out_mdio;
4671
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004672 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004673
4674out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004675 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004676out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004677 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004678out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004679 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004680out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004681 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004682 mv88e6xxx_g2_irq_free(chip);
4683out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004684 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004685 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004686 else
4687 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004688out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004689 if (pdata)
4690 dev_put(pdata->netdev);
4691
Andrew Lunndc30c352016-10-16 19:56:49 +02004692 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004693}
4694
4695static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4696{
4697 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004698 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004699
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004700 if (chip->info->ptp_support) {
4701 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004702 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004703 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004704
Andrew Lunn930188c2016-08-22 16:01:03 +02004705 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004706 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004707 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004708
Andrew Lunn76f38f12018-03-17 20:21:09 +01004709 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4710 mv88e6xxx_g1_atu_prob_irq_free(chip);
4711
4712 if (chip->info->g2_irqs > 0)
4713 mv88e6xxx_g2_irq_free(chip);
4714
Andrew Lunn76f38f12018-03-17 20:21:09 +01004715 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004716 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004717 else
4718 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004719}
4720
4721static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004722 {
4723 .compatible = "marvell,mv88e6085",
4724 .data = &mv88e6xxx_table[MV88E6085],
4725 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004726 {
4727 .compatible = "marvell,mv88e6190",
4728 .data = &mv88e6xxx_table[MV88E6190],
4729 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004730 { /* sentinel */ },
4731};
4732
4733MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4734
4735static struct mdio_driver mv88e6xxx_driver = {
4736 .probe = mv88e6xxx_probe,
4737 .remove = mv88e6xxx_remove,
4738 .mdiodrv.driver = {
4739 .name = "mv88e6085",
4740 .of_match_table = mv88e6xxx_of_match,
4741 },
4742};
4743
Ben Hutchings98e67302011-11-25 14:36:19 +00004744static int __init mv88e6xxx_init(void)
4745{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004746 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004747 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004748}
4749module_init(mv88e6xxx_init);
4750
4751static void __exit mv88e6xxx_cleanup(void)
4752{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004753 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004754 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004755}
4756module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004757
4758MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4759MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4760MODULE_LICENSE("GPL");