blob: 0f749d1ef53bc4362747c032a3a0e691ee31e548 [file] [log] [blame]
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04002 * Marvell 88e6xxx Ethernet switch single-chip support
3 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00004 * Copyright (c) 2008 Marvell Semiconductor
5 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
7 *
Vivien Didelot4333d612017-03-28 15:10:36 -04008 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
9 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
10 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
Barry Grussling19b2f972013-01-08 16:05:54 +000017#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070018#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020019#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070020#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020021#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000024#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000025#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020026#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000027#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040028#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020029#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020030#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020031#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000032#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010033#include <linux/gpio/consumer.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000034#include <linux/phy.h>
Russell Kingc9a23562018-05-10 13:17:35 -070035#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000036#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040037
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040038#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040039#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040040#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010041#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020042#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010043#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010044#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020045#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000046
Vivien Didelotfad09c72016-06-21 12:28:20 -040047static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048{
Vivien Didelotfad09c72016-06-21 12:28:20 -040049 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
50 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040051 dump_stack();
52 }
53}
54
Vivien Didelot914b32f2016-06-20 13:14:11 -040055/* The switch ADDR[4:1] configuration pins define the chip SMI device address
56 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
57 *
58 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
59 * is the only device connected to the SMI master. In this mode it responds to
60 * all 32 possible SMI addresses, and thus maps directly the internal devices.
61 *
62 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
63 * multiple devices to share the SMI interface. In this mode it responds to only
64 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000065 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040066
Vivien Didelotfad09c72016-06-21 12:28:20 -040067static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040068 int addr, int reg, u16 *val)
69{
Vivien Didelotfad09c72016-06-21 12:28:20 -040070 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040071 return -EOPNOTSUPP;
72
Vivien Didelotfad09c72016-06-21 12:28:20 -040073 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040074}
75
Vivien Didelotfad09c72016-06-21 12:28:20 -040076static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040077 int addr, int reg, u16 val)
78{
Vivien Didelotfad09c72016-06-21 12:28:20 -040079 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040080 return -EOPNOTSUPP;
81
Vivien Didelotfad09c72016-06-21 12:28:20 -040082 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040083}
84
Vivien Didelotfad09c72016-06-21 12:28:20 -040085static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040086 int addr, int reg, u16 *val)
87{
88 int ret;
89
Vivien Didelotfad09c72016-06-21 12:28:20 -040090 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040091 if (ret < 0)
92 return ret;
93
94 *val = ret & 0xffff;
95
96 return 0;
97}
98
Vivien Didelotfad09c72016-06-21 12:28:20 -040099static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400100 int addr, int reg, u16 val)
101{
102 int ret;
103
Vivien Didelotfad09c72016-06-21 12:28:20 -0400104 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400105 if (ret < 0)
106 return ret;
107
108 return 0;
109}
110
Vivien Didelotc08026a2016-09-29 12:21:59 -0400111static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400112 .read = mv88e6xxx_smi_single_chip_read,
113 .write = mv88e6xxx_smi_single_chip_write,
114};
115
Vivien Didelotfad09c72016-06-21 12:28:20 -0400116static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000117{
118 int ret;
119 int i;
120
121 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400122 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000123 if (ret < 0)
124 return ret;
125
Andrew Lunncca8b132015-04-02 04:06:39 +0200126 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000127 return 0;
128 }
129
130 return -ETIMEDOUT;
131}
132
Vivien Didelotfad09c72016-06-21 12:28:20 -0400133static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400134 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000135{
136 int ret;
137
Barry Grussling3675c8d2013-01-08 16:05:53 +0000138 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400139 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000140 if (ret < 0)
141 return ret;
142
Barry Grussling3675c8d2013-01-08 16:05:53 +0000143 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400144 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200145 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000146 if (ret < 0)
147 return ret;
148
Barry Grussling3675c8d2013-01-08 16:05:53 +0000149 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400150 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000151 if (ret < 0)
152 return ret;
153
Barry Grussling3675c8d2013-01-08 16:05:53 +0000154 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400155 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000156 if (ret < 0)
157 return ret;
158
Vivien Didelot914b32f2016-06-20 13:14:11 -0400159 *val = ret & 0xffff;
160
161 return 0;
162}
163
Vivien Didelotfad09c72016-06-21 12:28:20 -0400164static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400165 int addr, int reg, u16 val)
166{
167 int ret;
168
169 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400170 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400171 if (ret < 0)
172 return ret;
173
174 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400175 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400176 if (ret < 0)
177 return ret;
178
179 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400180 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400181 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
182 if (ret < 0)
183 return ret;
184
185 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400186 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400187 if (ret < 0)
188 return ret;
189
190 return 0;
191}
192
Vivien Didelotc08026a2016-09-29 12:21:59 -0400193static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400194 .read = mv88e6xxx_smi_multi_chip_read,
195 .write = mv88e6xxx_smi_multi_chip_write,
196};
197
Vivien Didelotec561272016-09-02 14:45:33 -0400198int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400199{
200 int err;
201
Vivien Didelotfad09c72016-06-21 12:28:20 -0400202 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400203
Vivien Didelotfad09c72016-06-21 12:28:20 -0400204 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400205 if (err)
206 return err;
207
Vivien Didelotfad09c72016-06-21 12:28:20 -0400208 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400209 addr, reg, *val);
210
211 return 0;
212}
213
Vivien Didelotec561272016-09-02 14:45:33 -0400214int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400215{
216 int err;
217
Vivien Didelotfad09c72016-06-21 12:28:20 -0400218 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400219
Vivien Didelotfad09c72016-06-21 12:28:20 -0400220 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400221 if (err)
222 return err;
223
Vivien Didelotfad09c72016-06-21 12:28:20 -0400224 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400225 addr, reg, val);
226
227 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000228}
229
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200230struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100231{
232 struct mv88e6xxx_mdio_bus *mdio_bus;
233
234 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
235 list);
236 if (!mdio_bus)
237 return NULL;
238
239 return mdio_bus->bus;
240}
241
Andrew Lunndc30c352016-10-16 19:56:49 +0200242static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
243{
244 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
245 unsigned int n = d->hwirq;
246
247 chip->g1_irq.masked |= (1 << n);
248}
249
250static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
251{
252 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
253 unsigned int n = d->hwirq;
254
255 chip->g1_irq.masked &= ~(1 << n);
256}
257
Andrew Lunn294d7112018-02-22 22:58:32 +0100258static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200259{
Andrew Lunndc30c352016-10-16 19:56:49 +0200260 unsigned int nhandled = 0;
261 unsigned int sub_irq;
262 unsigned int n;
263 u16 reg;
264 int err;
265
266 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400267 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200268 mutex_unlock(&chip->reg_lock);
269
270 if (err)
271 goto out;
272
273 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
274 if (reg & (1 << n)) {
275 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
276 handle_nested_irq(sub_irq);
277 ++nhandled;
278 }
279 }
280out:
281 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
282}
283
Andrew Lunn294d7112018-02-22 22:58:32 +0100284static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
285{
286 struct mv88e6xxx_chip *chip = dev_id;
287
288 return mv88e6xxx_g1_irq_thread_work(chip);
289}
290
Andrew Lunndc30c352016-10-16 19:56:49 +0200291static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
292{
293 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
294
295 mutex_lock(&chip->reg_lock);
296}
297
298static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
299{
300 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
301 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
302 u16 reg;
303 int err;
304
Vivien Didelotd77f4322017-06-15 12:14:03 -0400305 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200306 if (err)
307 goto out;
308
309 reg &= ~mask;
310 reg |= (~chip->g1_irq.masked & mask);
311
Vivien Didelotd77f4322017-06-15 12:14:03 -0400312 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200313 if (err)
314 goto out;
315
316out:
317 mutex_unlock(&chip->reg_lock);
318}
319
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530320static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200321 .name = "mv88e6xxx-g1",
322 .irq_mask = mv88e6xxx_g1_irq_mask,
323 .irq_unmask = mv88e6xxx_g1_irq_unmask,
324 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
325 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
326};
327
328static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
329 unsigned int irq,
330 irq_hw_number_t hwirq)
331{
332 struct mv88e6xxx_chip *chip = d->host_data;
333
334 irq_set_chip_data(irq, d->host_data);
335 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
336 irq_set_noprobe(irq);
337
338 return 0;
339}
340
341static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
342 .map = mv88e6xxx_g1_irq_domain_map,
343 .xlate = irq_domain_xlate_twocell,
344};
345
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200346/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100347static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200348{
349 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100350 u16 mask;
351
Vivien Didelotd77f4322017-06-15 12:14:03 -0400352 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100353 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400354 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100355
Andreas Färber5edef2f2016-11-27 23:26:28 +0100356 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100357 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200358 irq_dispose_mapping(virq);
359 }
360
Andrew Lunna3db3d32016-11-20 20:14:14 +0100361 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200362}
363
Andrew Lunn294d7112018-02-22 22:58:32 +0100364static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
365{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200366 /*
367 * free_irq must be called without reg_lock taken because the irq
368 * handler takes this lock, too.
369 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100370 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200371
372 mutex_lock(&chip->reg_lock);
373 mv88e6xxx_g1_irq_free_common(chip);
374 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100375}
376
377static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200378{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100379 int err, irq, virq;
380 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200381
382 chip->g1_irq.nirqs = chip->info->g1_irqs;
383 chip->g1_irq.domain = irq_domain_add_simple(
384 NULL, chip->g1_irq.nirqs, 0,
385 &mv88e6xxx_g1_irq_domain_ops, chip);
386 if (!chip->g1_irq.domain)
387 return -ENOMEM;
388
389 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
390 irq_create_mapping(chip->g1_irq.domain, irq);
391
392 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
393 chip->g1_irq.masked = ~0;
394
Vivien Didelotd77f4322017-06-15 12:14:03 -0400395 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200396 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100397 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200398
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100399 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200400
Vivien Didelotd77f4322017-06-15 12:14:03 -0400401 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200402 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100403 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200404
405 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400406 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200407 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100408 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200409
Andrew Lunndc30c352016-10-16 19:56:49 +0200410 return 0;
411
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100412out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100413 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400414 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100415
416out_mapping:
417 for (irq = 0; irq < 16; irq++) {
418 virq = irq_find_mapping(chip->g1_irq.domain, irq);
419 irq_dispose_mapping(virq);
420 }
421
422 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200423
424 return err;
425}
426
Andrew Lunn294d7112018-02-22 22:58:32 +0100427static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
428{
429 int err;
430
431 err = mv88e6xxx_g1_irq_setup_common(chip);
432 if (err)
433 return err;
434
435 err = request_threaded_irq(chip->irq, NULL,
436 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200437 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100438 dev_name(chip->dev), chip);
439 if (err)
440 mv88e6xxx_g1_irq_free_common(chip);
441
442 return err;
443}
444
445static void mv88e6xxx_irq_poll(struct kthread_work *work)
446{
447 struct mv88e6xxx_chip *chip = container_of(work,
448 struct mv88e6xxx_chip,
449 irq_poll_work.work);
450 mv88e6xxx_g1_irq_thread_work(chip);
451
452 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
453 msecs_to_jiffies(100));
454}
455
456static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
457{
458 int err;
459
460 err = mv88e6xxx_g1_irq_setup_common(chip);
461 if (err)
462 return err;
463
464 kthread_init_delayed_work(&chip->irq_poll_work,
465 mv88e6xxx_irq_poll);
466
467 chip->kworker = kthread_create_worker(0, dev_name(chip->dev));
468 if (IS_ERR(chip->kworker))
469 return PTR_ERR(chip->kworker);
470
471 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
472 msecs_to_jiffies(100));
473
474 return 0;
475}
476
477static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
478{
479 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
480 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200481
482 mutex_lock(&chip->reg_lock);
483 mv88e6xxx_g1_irq_free_common(chip);
484 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100485}
486
Vivien Didelotec561272016-09-02 14:45:33 -0400487int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400488{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200489 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400490
Andrew Lunn6441e6692016-08-19 00:01:55 +0200491 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400492 u16 val;
493 int err;
494
495 err = mv88e6xxx_read(chip, addr, reg, &val);
496 if (err)
497 return err;
498
499 if (!(val & mask))
500 return 0;
501
502 usleep_range(1000, 2000);
503 }
504
Andrew Lunn30853552016-08-19 00:01:57 +0200505 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400506 return -ETIMEDOUT;
507}
508
Vivien Didelotf22ab642016-07-18 20:45:31 -0400509/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400510int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400511{
512 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200513 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400514
515 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200516 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
517 if (err)
518 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400519
520 /* Set the Update bit to trigger a write operation */
521 val = BIT(15) | update;
522
523 return mv88e6xxx_write(chip, addr, reg, val);
524}
525
Vivien Didelotd78343d2016-11-04 03:23:36 +0100526static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
Andrew Lunn54186b92018-08-09 15:38:37 +0200527 int link, int speed, int duplex, int pause,
Vivien Didelotd78343d2016-11-04 03:23:36 +0100528 phy_interface_t mode)
529{
530 int err;
531
532 if (!chip->info->ops->port_set_link)
533 return 0;
534
535 /* Port's MAC control must not be changed unless the link is down */
536 err = chip->info->ops->port_set_link(chip, port, 0);
537 if (err)
538 return err;
539
540 if (chip->info->ops->port_set_speed) {
541 err = chip->info->ops->port_set_speed(chip, port, speed);
542 if (err && err != -EOPNOTSUPP)
543 goto restore_link;
544 }
545
Andrew Lunn54186b92018-08-09 15:38:37 +0200546 if (chip->info->ops->port_set_pause) {
547 err = chip->info->ops->port_set_pause(chip, port, pause);
548 if (err)
549 goto restore_link;
550 }
551
Vivien Didelotd78343d2016-11-04 03:23:36 +0100552 if (chip->info->ops->port_set_duplex) {
553 err = chip->info->ops->port_set_duplex(chip, port, duplex);
554 if (err && err != -EOPNOTSUPP)
555 goto restore_link;
556 }
557
558 if (chip->info->ops->port_set_rgmii_delay) {
559 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
560 if (err && err != -EOPNOTSUPP)
561 goto restore_link;
562 }
563
Andrew Lunnf39908d2017-02-04 20:02:50 +0100564 if (chip->info->ops->port_set_cmode) {
565 err = chip->info->ops->port_set_cmode(chip, port, mode);
566 if (err && err != -EOPNOTSUPP)
567 goto restore_link;
568 }
569
Vivien Didelotd78343d2016-11-04 03:23:36 +0100570 err = 0;
571restore_link:
572 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400573 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100574
575 return err;
576}
577
Marek Vasutd700ec42018-09-12 00:15:24 +0200578static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
579{
580 struct mv88e6xxx_chip *chip = ds->priv;
581
582 return port < chip->info->num_internal_phys;
583}
584
Andrew Lunndea87022015-08-31 15:56:47 +0200585/* We expect the switch to perform auto negotiation if there is a real
586 * phy. However, in the case of a fixed link phy, we force the port
587 * settings from the fixed link settings.
588 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400589static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
590 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200591{
Vivien Didelot04bed142016-08-31 18:06:13 -0400592 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200593 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200594
Marek Vasutd700ec42018-09-12 00:15:24 +0200595 if (!phy_is_pseudo_fixed_link(phydev) &&
596 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200597 return;
598
Vivien Didelotfad09c72016-06-21 12:28:20 -0400599 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100600 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200601 phydev->duplex, phydev->pause,
602 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400603 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100604
605 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400606 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200607}
608
Russell King6c422e32018-08-09 15:38:39 +0200609static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
610 unsigned long *mask,
611 struct phylink_link_state *state)
612{
613 if (!phy_interface_mode_is_8023z(state->interface)) {
614 /* 10M and 100M are only supported in non-802.3z mode */
615 phylink_set(mask, 10baseT_Half);
616 phylink_set(mask, 10baseT_Full);
617 phylink_set(mask, 100baseT_Half);
618 phylink_set(mask, 100baseT_Full);
619 }
620}
621
622static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
623 unsigned long *mask,
624 struct phylink_link_state *state)
625{
626 /* FIXME: if the port is in 1000Base-X mode, then it only supports
627 * 1000M FD speeds. In this case, CMODE will indicate 5.
628 */
629 phylink_set(mask, 1000baseT_Full);
630 phylink_set(mask, 1000baseX_Full);
631
632 mv88e6065_phylink_validate(chip, port, mask, state);
633}
634
635static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
636 unsigned long *mask,
637 struct phylink_link_state *state)
638{
639 /* No ethtool bits for 200Mbps */
640 phylink_set(mask, 1000baseT_Full);
641 phylink_set(mask, 1000baseX_Full);
642
643 mv88e6065_phylink_validate(chip, port, mask, state);
644}
645
646static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
647 unsigned long *mask,
648 struct phylink_link_state *state)
649{
650 if (port >= 9)
651 phylink_set(mask, 2500baseX_Full);
652
653 /* No ethtool bits for 200Mbps */
654 phylink_set(mask, 1000baseT_Full);
655 phylink_set(mask, 1000baseX_Full);
656
657 mv88e6065_phylink_validate(chip, port, mask, state);
658}
659
660static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
661 unsigned long *mask,
662 struct phylink_link_state *state)
663{
664 if (port >= 9) {
665 phylink_set(mask, 10000baseT_Full);
666 phylink_set(mask, 10000baseKR_Full);
667 }
668
669 mv88e6390_phylink_validate(chip, port, mask, state);
670}
671
Russell Kingc9a23562018-05-10 13:17:35 -0700672static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
673 unsigned long *supported,
674 struct phylink_link_state *state)
675{
Russell King6c422e32018-08-09 15:38:39 +0200676 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
677 struct mv88e6xxx_chip *chip = ds->priv;
678
679 /* Allow all the expected bits */
680 phylink_set(mask, Autoneg);
681 phylink_set(mask, Pause);
682 phylink_set_port_modes(mask);
683
684 if (chip->info->ops->phylink_validate)
685 chip->info->ops->phylink_validate(chip, port, mask, state);
686
687 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
688 bitmap_and(state->advertising, state->advertising, mask,
689 __ETHTOOL_LINK_MODE_MASK_NBITS);
690
691 /* We can only operate at 2500BaseX or 1000BaseX. If requested
692 * to advertise both, only report advertising at 2500BaseX.
693 */
694 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700695}
696
697static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
698 struct phylink_link_state *state)
699{
700 struct mv88e6xxx_chip *chip = ds->priv;
701 int err;
702
703 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200704 if (chip->info->ops->port_link_state)
705 err = chip->info->ops->port_link_state(chip, port, state);
706 else
707 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700708 mutex_unlock(&chip->reg_lock);
709
710 return err;
711}
712
713static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
714 unsigned int mode,
715 const struct phylink_link_state *state)
716{
717 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200718 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700719
Marek Vasutd700ec42018-09-12 00:15:24 +0200720 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700721 return;
722
723 if (mode == MLO_AN_FIXED) {
724 link = LINK_FORCED_UP;
725 speed = state->speed;
726 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200727 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
728 link = state->link;
729 speed = state->speed;
730 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700731 } else {
732 speed = SPEED_UNFORCED;
733 duplex = DUPLEX_UNFORCED;
734 link = LINK_UNFORCED;
735 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200736 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700737
738 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200739 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700740 state->interface);
741 mutex_unlock(&chip->reg_lock);
742
743 if (err && err != -EOPNOTSUPP)
744 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
745}
746
747static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
748{
749 struct mv88e6xxx_chip *chip = ds->priv;
750 int err;
751
752 mutex_lock(&chip->reg_lock);
753 err = chip->info->ops->port_set_link(chip, port, link);
754 mutex_unlock(&chip->reg_lock);
755
756 if (err)
757 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
758}
759
760static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
761 unsigned int mode,
762 phy_interface_t interface)
763{
764 if (mode == MLO_AN_FIXED)
765 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
766}
767
768static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
769 unsigned int mode, phy_interface_t interface,
770 struct phy_device *phydev)
771{
772 if (mode == MLO_AN_FIXED)
773 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
774}
775
Andrew Lunna605a0f2016-11-21 23:26:58 +0100776static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000777{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100778 if (!chip->info->ops->stats_snapshot)
779 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000780
Andrew Lunna605a0f2016-11-21 23:26:58 +0100781 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000782}
783
Andrew Lunne413e7e2015-04-02 04:06:38 +0200784static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100785 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
786 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
787 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
788 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
789 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
790 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
791 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
792 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
793 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
794 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
795 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
796 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
797 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
798 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
799 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
800 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
801 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
802 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
803 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
804 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
805 { "single", 4, 0x14, STATS_TYPE_BANK0, },
806 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
807 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
808 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
809 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
810 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
811 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
812 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
813 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
814 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
815 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
816 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
817 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
818 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
819 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
820 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
821 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
822 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
823 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
824 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
825 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
826 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
827 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
828 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
829 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
830 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
831 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
832 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
833 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
834 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
835 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
836 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
837 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
838 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
839 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
840 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
841 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
842 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
843 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200844};
845
Vivien Didelotfad09c72016-06-21 12:28:20 -0400846static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100847 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100848 int port, u16 bank1_select,
849 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200850{
Andrew Lunn80c46272015-06-20 18:42:30 +0200851 u32 low;
852 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100853 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200854 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200855 u64 value;
856
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100857 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100858 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200859 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
860 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800861 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200862
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200863 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100864 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200865 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
866 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800867 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200868 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200869 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100870 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100871 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100872 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100873 /* fall through */
874 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100875 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100876 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100877 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100878 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500879 break;
880 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800881 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200882 }
883 value = (((u64)high) << 16) | low;
884 return value;
885}
886
Andrew Lunn436fe172018-03-01 02:02:29 +0100887static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
888 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100889{
890 struct mv88e6xxx_hw_stat *stat;
891 int i, j;
892
893 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
894 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100895 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100896 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
897 ETH_GSTRING_LEN);
898 j++;
899 }
900 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100901
902 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100903}
904
Andrew Lunn436fe172018-03-01 02:02:29 +0100905static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
906 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100907{
Andrew Lunn436fe172018-03-01 02:02:29 +0100908 return mv88e6xxx_stats_get_strings(chip, data,
909 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100910}
911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
913 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100914{
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 return mv88e6xxx_stats_get_strings(chip, data,
916 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100917}
918
Andrew Lunn65f60e42018-03-28 23:50:28 +0200919static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
920 "atu_member_violation",
921 "atu_miss_violation",
922 "atu_full_violation",
923 "vtu_member_violation",
924 "vtu_miss_violation",
925};
926
927static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
928{
929 unsigned int i;
930
931 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
932 strlcpy(data + i * ETH_GSTRING_LEN,
933 mv88e6xxx_atu_vtu_stats_strings[i],
934 ETH_GSTRING_LEN);
935}
936
Andrew Lunndfafe442016-11-21 23:27:02 +0100937static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700938 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100939{
Vivien Didelot04bed142016-08-31 18:06:13 -0400940 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100941 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100942
Florian Fainelli89f09042018-04-25 12:12:50 -0700943 if (stringset != ETH_SS_STATS)
944 return;
945
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100946 mutex_lock(&chip->reg_lock);
947
Andrew Lunndfafe442016-11-21 23:27:02 +0100948 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100949 count = chip->info->ops->stats_get_strings(chip, data);
950
951 if (chip->info->ops->serdes_get_strings) {
952 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200953 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100954 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100955
Andrew Lunn65f60e42018-03-28 23:50:28 +0200956 data += count * ETH_GSTRING_LEN;
957 mv88e6xxx_atu_vtu_get_strings(data);
958
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100959 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100960}
961
962static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
963 int types)
964{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100965 struct mv88e6xxx_hw_stat *stat;
966 int i, j;
967
968 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
969 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100970 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100971 j++;
972 }
973 return j;
974}
975
Andrew Lunndfafe442016-11-21 23:27:02 +0100976static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
977{
978 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
979 STATS_TYPE_PORT);
980}
981
982static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
983{
984 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
985 STATS_TYPE_BANK1);
986}
987
Florian Fainelli89f09042018-04-25 12:12:50 -0700988static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100989{
990 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100991 int serdes_count = 0;
992 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100993
Florian Fainelli89f09042018-04-25 12:12:50 -0700994 if (sset != ETH_SS_STATS)
995 return 0;
996
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100997 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100998 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100999 count = chip->info->ops->stats_get_sset_count(chip);
1000 if (count < 0)
1001 goto out;
1002
1003 if (chip->info->ops->serdes_get_sset_count)
1004 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1005 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001006 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001007 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001008 goto out;
1009 }
1010 count += serdes_count;
1011 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1012
Andrew Lunn436fe172018-03-01 02:02:29 +01001013out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001014 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001015
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001017}
1018
Andrew Lunn436fe172018-03-01 02:02:29 +01001019static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1020 uint64_t *data, int types,
1021 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001022{
1023 struct mv88e6xxx_hw_stat *stat;
1024 int i, j;
1025
1026 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1027 stat = &mv88e6xxx_hw_stats[i];
1028 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001029 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001030 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1031 bank1_select,
1032 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001033 mutex_unlock(&chip->reg_lock);
1034
Andrew Lunn052f9472016-11-21 23:27:03 +01001035 j++;
1036 }
1037 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001038 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001039}
1040
Andrew Lunn436fe172018-03-01 02:02:29 +01001041static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1042 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001043{
1044 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001045 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001046 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001047}
1048
Andrew Lunn436fe172018-03-01 02:02:29 +01001049static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1050 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001051{
1052 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001053 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001054 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1055 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001056}
1057
Andrew Lunn436fe172018-03-01 02:02:29 +01001058static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1059 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001060{
1061 return mv88e6xxx_stats_get_stats(chip, port, data,
1062 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001063 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1064 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001065}
1066
Andrew Lunn65f60e42018-03-28 23:50:28 +02001067static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1068 uint64_t *data)
1069{
1070 *data++ = chip->ports[port].atu_member_violation;
1071 *data++ = chip->ports[port].atu_miss_violation;
1072 *data++ = chip->ports[port].atu_full_violation;
1073 *data++ = chip->ports[port].vtu_member_violation;
1074 *data++ = chip->ports[port].vtu_miss_violation;
1075}
1076
Andrew Lunn052f9472016-11-21 23:27:03 +01001077static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1078 uint64_t *data)
1079{
Andrew Lunn436fe172018-03-01 02:02:29 +01001080 int count = 0;
1081
Andrew Lunn052f9472016-11-21 23:27:03 +01001082 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001083 count = chip->info->ops->stats_get_stats(chip, port, data);
1084
Andrew Lunn65f60e42018-03-28 23:50:28 +02001085 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001086 if (chip->info->ops->serdes_get_stats) {
1087 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001088 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001089 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001090 data += count;
1091 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1092 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001093}
1094
Vivien Didelotf81ec902016-05-09 13:22:58 -04001095static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1096 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001097{
Vivien Didelot04bed142016-08-31 18:06:13 -04001098 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001099 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001100
Vivien Didelotfad09c72016-06-21 12:28:20 -04001101 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001102
Andrew Lunna605a0f2016-11-21 23:26:58 +01001103 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001104 mutex_unlock(&chip->reg_lock);
1105
1106 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001107 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001108
1109 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001110
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001111}
Ben Hutchings98e67302011-11-25 14:36:19 +00001112
Vivien Didelotf81ec902016-05-09 13:22:58 -04001113static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001114{
1115 return 32 * sizeof(u16);
1116}
1117
Vivien Didelotf81ec902016-05-09 13:22:58 -04001118static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1119 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001120{
Vivien Didelot04bed142016-08-31 18:06:13 -04001121 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001122 int err;
1123 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001124 u16 *p = _p;
1125 int i;
1126
1127 regs->version = 0;
1128
1129 memset(p, 0xff, 32 * sizeof(u16));
1130
Vivien Didelotfad09c72016-06-21 12:28:20 -04001131 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001132
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001133 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001134
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001135 err = mv88e6xxx_port_read(chip, port, i, &reg);
1136 if (!err)
1137 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138 }
Vivien Didelot23062512016-05-09 13:22:45 -04001139
Vivien Didelotfad09c72016-06-21 12:28:20 -04001140 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001141}
1142
Vivien Didelot08f50062017-08-01 16:32:41 -04001143static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1144 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001145{
Vivien Didelot5480db62017-08-01 16:32:40 -04001146 /* Nothing to do on the port's MAC */
1147 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001148}
1149
Vivien Didelot08f50062017-08-01 16:32:41 -04001150static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1151 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001152{
Vivien Didelot5480db62017-08-01 16:32:40 -04001153 /* Nothing to do on the port's MAC */
1154 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001155}
1156
Vivien Didelote5887a22017-03-30 17:37:11 -04001157static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001158{
Vivien Didelote5887a22017-03-30 17:37:11 -04001159 struct dsa_switch *ds = NULL;
1160 struct net_device *br;
1161 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001162 int i;
1163
Vivien Didelote5887a22017-03-30 17:37:11 -04001164 if (dev < DSA_MAX_SWITCHES)
1165 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001166
Vivien Didelote5887a22017-03-30 17:37:11 -04001167 /* Prevent frames from unknown switch or port */
1168 if (!ds || port >= ds->num_ports)
1169 return 0;
1170
1171 /* Frames from DSA links and CPU ports can egress any local port */
1172 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1173 return mv88e6xxx_port_mask(chip);
1174
1175 br = ds->ports[port].bridge_dev;
1176 pvlan = 0;
1177
1178 /* Frames from user ports can egress any local DSA links and CPU ports,
1179 * as well as any local member of their bridge group.
1180 */
1181 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1182 if (dsa_is_cpu_port(chip->ds, i) ||
1183 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001184 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001185 pvlan |= BIT(i);
1186
1187 return pvlan;
1188}
1189
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001190static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001191{
1192 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001193
1194 /* prevent frames from going back out of the port they came in on */
1195 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001196
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001197 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001198}
1199
Vivien Didelotf81ec902016-05-09 13:22:58 -04001200static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1201 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001202{
Vivien Didelot04bed142016-08-31 18:06:13 -04001203 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001204 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001205
Vivien Didelotfad09c72016-06-21 12:28:20 -04001206 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001207 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001208 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001209
1210 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001211 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001212}
1213
Vivien Didelot93e18d62018-05-11 17:16:35 -04001214static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1215{
1216 int err;
1217
1218 if (chip->info->ops->ieee_pri_map) {
1219 err = chip->info->ops->ieee_pri_map(chip);
1220 if (err)
1221 return err;
1222 }
1223
1224 if (chip->info->ops->ip_pri_map) {
1225 err = chip->info->ops->ip_pri_map(chip);
1226 if (err)
1227 return err;
1228 }
1229
1230 return 0;
1231}
1232
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001233static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1234{
1235 int target, port;
1236 int err;
1237
1238 if (!chip->info->global2_addr)
1239 return 0;
1240
1241 /* Initialize the routing port to the 32 possible target devices */
1242 for (target = 0; target < 32; target++) {
1243 port = 0x1f;
1244 if (target < DSA_MAX_SWITCHES)
1245 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1246 port = chip->ds->rtable[target];
1247
1248 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1249 if (err)
1250 return err;
1251 }
1252
Vivien Didelot02317e62018-05-09 11:38:49 -04001253 if (chip->info->ops->set_cascade_port) {
1254 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1255 err = chip->info->ops->set_cascade_port(chip, port);
1256 if (err)
1257 return err;
1258 }
1259
Vivien Didelot23c98912018-05-09 11:38:50 -04001260 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1261 if (err)
1262 return err;
1263
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001264 return 0;
1265}
1266
Vivien Didelotb28f8722018-04-26 21:56:44 -04001267static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1268{
1269 /* Clear all trunk masks and mapping */
1270 if (chip->info->global2_addr)
1271 return mv88e6xxx_g2_trunk_clear(chip);
1272
1273 return 0;
1274}
1275
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001276static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1277{
1278 if (chip->info->ops->rmu_disable)
1279 return chip->info->ops->rmu_disable(chip);
1280
1281 return 0;
1282}
1283
Vivien Didelot9e907d72017-07-17 13:03:43 -04001284static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1285{
1286 if (chip->info->ops->pot_clear)
1287 return chip->info->ops->pot_clear(chip);
1288
1289 return 0;
1290}
1291
Vivien Didelot51c901a2017-07-17 13:03:41 -04001292static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1293{
1294 if (chip->info->ops->mgmt_rsvd2cpu)
1295 return chip->info->ops->mgmt_rsvd2cpu(chip);
1296
1297 return 0;
1298}
1299
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001300static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1301{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001302 int err;
1303
Vivien Didelotdaefc942017-03-11 16:12:54 -05001304 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1305 if (err)
1306 return err;
1307
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001308 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1309 if (err)
1310 return err;
1311
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001312 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1313}
1314
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001315static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1316{
1317 int port;
1318 int err;
1319
1320 if (!chip->info->ops->irl_init_all)
1321 return 0;
1322
1323 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1324 /* Disable ingress rate limiting by resetting all per port
1325 * ingress rate limit resources to their initial state.
1326 */
1327 err = chip->info->ops->irl_init_all(chip, port);
1328 if (err)
1329 return err;
1330 }
1331
1332 return 0;
1333}
1334
Vivien Didelot04a69a12017-10-13 14:18:05 -04001335static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1336{
1337 if (chip->info->ops->set_switch_mac) {
1338 u8 addr[ETH_ALEN];
1339
1340 eth_random_addr(addr);
1341
1342 return chip->info->ops->set_switch_mac(chip, addr);
1343 }
1344
1345 return 0;
1346}
1347
Vivien Didelot17a15942017-03-30 17:37:09 -04001348static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1349{
1350 u16 pvlan = 0;
1351
1352 if (!mv88e6xxx_has_pvt(chip))
1353 return -EOPNOTSUPP;
1354
1355 /* Skip the local source device, which uses in-chip port VLAN */
1356 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001357 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001358
1359 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1360}
1361
Vivien Didelot81228992017-03-30 17:37:08 -04001362static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1363{
Vivien Didelot17a15942017-03-30 17:37:09 -04001364 int dev, port;
1365 int err;
1366
Vivien Didelot81228992017-03-30 17:37:08 -04001367 if (!mv88e6xxx_has_pvt(chip))
1368 return 0;
1369
1370 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1371 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1372 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001373 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1374 if (err)
1375 return err;
1376
1377 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1378 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1379 err = mv88e6xxx_pvt_map(chip, dev, port);
1380 if (err)
1381 return err;
1382 }
1383 }
1384
1385 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001386}
1387
Vivien Didelot749efcb2016-09-22 16:49:24 -04001388static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1389{
1390 struct mv88e6xxx_chip *chip = ds->priv;
1391 int err;
1392
1393 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001394 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001395 mutex_unlock(&chip->reg_lock);
1396
1397 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001398 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001399}
1400
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001401static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1402{
1403 if (!chip->info->max_vid)
1404 return 0;
1405
1406 return mv88e6xxx_g1_vtu_flush(chip);
1407}
1408
Vivien Didelotf1394b782017-05-01 14:05:22 -04001409static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1410 struct mv88e6xxx_vtu_entry *entry)
1411{
1412 if (!chip->info->ops->vtu_getnext)
1413 return -EOPNOTSUPP;
1414
1415 return chip->info->ops->vtu_getnext(chip, entry);
1416}
1417
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001418static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1419 struct mv88e6xxx_vtu_entry *entry)
1420{
1421 if (!chip->info->ops->vtu_loadpurge)
1422 return -EOPNOTSUPP;
1423
1424 return chip->info->ops->vtu_loadpurge(chip, entry);
1425}
1426
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001427static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001428{
1429 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001430 struct mv88e6xxx_vtu_entry vlan = {
1431 .vid = chip->info->max_vid,
1432 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001433 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001434
1435 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1436
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001437 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001438 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001439 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001440 if (err)
1441 return err;
1442
1443 set_bit(*fid, fid_bitmap);
1444 }
1445
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001446 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001447 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001448 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001449 if (err)
1450 return err;
1451
1452 if (!vlan.valid)
1453 break;
1454
1455 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001456 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001457
1458 /* The reset value 0x000 is used to indicate that multiple address
1459 * databases are not needed. Return the next positive available.
1460 */
1461 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001462 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001463 return -ENOSPC;
1464
1465 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001466 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001467}
1468
Vivien Didelot567aa592017-05-01 14:05:25 -04001469static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1470 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001471{
1472 int err;
1473
1474 if (!vid)
1475 return -EINVAL;
1476
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001477 entry->vid = vid - 1;
1478 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001479
Vivien Didelotf1394b782017-05-01 14:05:22 -04001480 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001481 if (err)
1482 return err;
1483
Vivien Didelot567aa592017-05-01 14:05:25 -04001484 if (entry->vid == vid && entry->valid)
1485 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001486
Vivien Didelot567aa592017-05-01 14:05:25 -04001487 if (new) {
1488 int i;
1489
1490 /* Initialize a fresh VLAN entry */
1491 memset(entry, 0, sizeof(*entry));
1492 entry->valid = true;
1493 entry->vid = vid;
1494
Vivien Didelot553a7682017-06-07 18:12:16 -04001495 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001496 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001497 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001498 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001499
1500 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001501 }
1502
Vivien Didelot567aa592017-05-01 14:05:25 -04001503 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1504 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001505}
1506
Vivien Didelotda9c3592016-02-12 12:09:40 -05001507static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1508 u16 vid_begin, u16 vid_end)
1509{
Vivien Didelot04bed142016-08-31 18:06:13 -04001510 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001511 struct mv88e6xxx_vtu_entry vlan = {
1512 .vid = vid_begin - 1,
1513 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001514 int i, err;
1515
Andrew Lunndb06ae412017-09-25 23:32:20 +02001516 /* DSA and CPU ports have to be members of multiple vlans */
1517 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1518 return 0;
1519
Vivien Didelotda9c3592016-02-12 12:09:40 -05001520 if (!vid_begin)
1521 return -EOPNOTSUPP;
1522
Vivien Didelotfad09c72016-06-21 12:28:20 -04001523 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001524
Vivien Didelotda9c3592016-02-12 12:09:40 -05001525 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001526 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001527 if (err)
1528 goto unlock;
1529
1530 if (!vlan.valid)
1531 break;
1532
1533 if (vlan.vid > vid_end)
1534 break;
1535
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001536 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001537 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1538 continue;
1539
Andrew Lunncd886462017-11-09 22:29:53 +01001540 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001541 continue;
1542
Vivien Didelotbd00e052017-05-01 14:05:11 -04001543 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001544 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545 continue;
1546
Vivien Didelotc8652c82017-10-16 11:12:19 -04001547 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001548 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001549 break; /* same bridge, check next VLAN */
1550
Vivien Didelotc8652c82017-10-16 11:12:19 -04001551 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001552 continue;
1553
Andrew Lunn743fcc22017-11-09 22:29:54 +01001554 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1555 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001556 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001557 err = -EOPNOTSUPP;
1558 goto unlock;
1559 }
1560 } while (vlan.vid < vid_end);
1561
1562unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001563 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001564
1565 return err;
1566}
1567
Vivien Didelotf81ec902016-05-09 13:22:58 -04001568static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1569 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001570{
Vivien Didelot04bed142016-08-31 18:06:13 -04001571 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001572 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1573 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001574 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001575
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001576 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001577 return -EOPNOTSUPP;
1578
Vivien Didelotfad09c72016-06-21 12:28:20 -04001579 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001580 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001581 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001582
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001583 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001584}
1585
Vivien Didelot57d32312016-06-20 13:13:58 -04001586static int
1587mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001588 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001589{
Vivien Didelot04bed142016-08-31 18:06:13 -04001590 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001591 int err;
1592
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001593 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001594 return -EOPNOTSUPP;
1595
Vivien Didelotda9c3592016-02-12 12:09:40 -05001596 /* If the requested port doesn't belong to the same bridge as the VLAN
1597 * members, do not support it (yet) and fallback to software VLAN.
1598 */
1599 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1600 vlan->vid_end);
1601 if (err)
1602 return err;
1603
Vivien Didelot76e398a2015-11-01 12:33:55 -05001604 /* We don't need any dynamic resource from the kernel (yet),
1605 * so skip the prepare phase.
1606 */
1607 return 0;
1608}
1609
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001610static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1611 const unsigned char *addr, u16 vid,
1612 u8 state)
1613{
1614 struct mv88e6xxx_vtu_entry vlan;
1615 struct mv88e6xxx_atu_entry entry;
1616 int err;
1617
1618 /* Null VLAN ID corresponds to the port private database */
1619 if (vid == 0)
1620 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1621 else
1622 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1623 if (err)
1624 return err;
1625
1626 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1627 ether_addr_copy(entry.mac, addr);
1628 eth_addr_dec(entry.mac);
1629
1630 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1631 if (err)
1632 return err;
1633
1634 /* Initialize a fresh ATU entry if it isn't found */
1635 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1636 !ether_addr_equal(entry.mac, addr)) {
1637 memset(&entry, 0, sizeof(entry));
1638 ether_addr_copy(entry.mac, addr);
1639 }
1640
1641 /* Purge the ATU entry only if no port is using it anymore */
1642 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1643 entry.portvec &= ~BIT(port);
1644 if (!entry.portvec)
1645 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1646 } else {
1647 entry.portvec |= BIT(port);
1648 entry.state = state;
1649 }
1650
1651 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1652}
1653
Andrew Lunn87fa8862017-11-09 22:29:56 +01001654static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1655 u16 vid)
1656{
1657 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1658 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1659
1660 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1661}
1662
1663static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1664{
1665 int port;
1666 int err;
1667
1668 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1669 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1670 if (err)
1671 return err;
1672 }
1673
1674 return 0;
1675}
1676
Vivien Didelotfad09c72016-06-21 12:28:20 -04001677static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001678 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001679{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001680 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001681 int err;
1682
Vivien Didelot567aa592017-05-01 14:05:25 -04001683 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001684 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001685 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001686
Vivien Didelotc91498e2017-06-07 18:12:13 -04001687 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001688
Andrew Lunn87fa8862017-11-09 22:29:56 +01001689 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1690 if (err)
1691 return err;
1692
1693 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001694}
1695
Vivien Didelotf81ec902016-05-09 13:22:58 -04001696static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001697 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001698{
Vivien Didelot04bed142016-08-31 18:06:13 -04001699 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001700 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1701 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001702 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001703 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001704
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001705 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001706 return;
1707
Vivien Didelotc91498e2017-06-07 18:12:13 -04001708 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001709 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001710 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001711 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001712 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001713 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001714
Vivien Didelotfad09c72016-06-21 12:28:20 -04001715 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001716
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001717 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001718 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001719 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1720 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001721
Vivien Didelot77064f32016-11-04 03:23:30 +01001722 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001723 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1724 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001725
Vivien Didelotfad09c72016-06-21 12:28:20 -04001726 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001727}
1728
Vivien Didelotfad09c72016-06-21 12:28:20 -04001729static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001730 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001731{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001732 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001733 int i, err;
1734
Vivien Didelot567aa592017-05-01 14:05:25 -04001735 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001736 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001737 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001738
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001739 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001740 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001741 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001742
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001743 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001744
1745 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001746 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001747 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001748 if (vlan.member[i] !=
1749 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001750 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001751 break;
1752 }
1753 }
1754
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001755 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001756 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001757 return err;
1758
Vivien Didelote606ca32017-03-11 16:12:55 -05001759 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001760}
1761
Vivien Didelotf81ec902016-05-09 13:22:58 -04001762static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1763 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001764{
Vivien Didelot04bed142016-08-31 18:06:13 -04001765 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001766 u16 pvid, vid;
1767 int err = 0;
1768
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001769 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001770 return -EOPNOTSUPP;
1771
Vivien Didelotfad09c72016-06-21 12:28:20 -04001772 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001773
Vivien Didelot77064f32016-11-04 03:23:30 +01001774 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001775 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001776 goto unlock;
1777
Vivien Didelot76e398a2015-11-01 12:33:55 -05001778 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001779 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001780 if (err)
1781 goto unlock;
1782
1783 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001784 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001785 if (err)
1786 goto unlock;
1787 }
1788 }
1789
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001790unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001791 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001792
1793 return err;
1794}
1795
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001796static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1797 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001798{
Vivien Didelot04bed142016-08-31 18:06:13 -04001799 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001800 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001801
Vivien Didelotfad09c72016-06-21 12:28:20 -04001802 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001803 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1804 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001805 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001806
1807 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001808}
1809
Vivien Didelotf81ec902016-05-09 13:22:58 -04001810static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001811 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001812{
Vivien Didelot04bed142016-08-31 18:06:13 -04001813 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001814 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001815
Vivien Didelotfad09c72016-06-21 12:28:20 -04001816 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001817 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001818 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001819 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001820
Vivien Didelot83dabd12016-08-31 11:50:04 -04001821 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001822}
1823
Vivien Didelot83dabd12016-08-31 11:50:04 -04001824static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1825 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001826 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001827{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001828 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001829 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001830 int err;
1831
Vivien Didelot27c0e602017-06-15 12:14:01 -04001832 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001833 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001834
1835 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001836 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001837 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001838 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001839 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001840 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001841
Vivien Didelot27c0e602017-06-15 12:14:01 -04001842 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001843 break;
1844
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001845 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001846 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001847
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001848 if (!is_unicast_ether_addr(addr.mac))
1849 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001850
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001851 is_static = (addr.state ==
1852 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1853 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001854 if (err)
1855 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001856 } while (!is_broadcast_ether_addr(addr.mac));
1857
1858 return err;
1859}
1860
Vivien Didelot83dabd12016-08-31 11:50:04 -04001861static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001862 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001863{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001864 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001865 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001866 };
1867 u16 fid;
1868 int err;
1869
1870 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001871 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001872 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001873 mutex_unlock(&chip->reg_lock);
1874
Vivien Didelot83dabd12016-08-31 11:50:04 -04001875 if (err)
1876 return err;
1877
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001878 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001879 if (err)
1880 return err;
1881
1882 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001883 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001884 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001885 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001886 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001887 if (err)
1888 return err;
1889
1890 if (!vlan.valid)
1891 break;
1892
1893 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001894 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001895 if (err)
1896 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001897 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001898
1899 return err;
1900}
1901
Vivien Didelotf81ec902016-05-09 13:22:58 -04001902static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001903 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001904{
Vivien Didelot04bed142016-08-31 18:06:13 -04001905 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001906
Andrew Lunna61e5402018-02-15 14:38:35 +01001907 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001908}
1909
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001910static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1911 struct net_device *br)
1912{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001913 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001914 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001915 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001916 int err;
1917
1918 /* Remap the Port VLAN of each local bridge group member */
1919 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1920 if (chip->ds->ports[port].bridge_dev == br) {
1921 err = mv88e6xxx_port_vlan_map(chip, port);
1922 if (err)
1923 return err;
1924 }
1925 }
1926
Vivien Didelote96a6e02017-03-30 17:37:13 -04001927 if (!mv88e6xxx_has_pvt(chip))
1928 return 0;
1929
1930 /* Remap the Port VLAN of each cross-chip bridge group member */
1931 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1932 ds = chip->ds->dst->ds[dev];
1933 if (!ds)
1934 break;
1935
1936 for (port = 0; port < ds->num_ports; ++port) {
1937 if (ds->ports[port].bridge_dev == br) {
1938 err = mv88e6xxx_pvt_map(chip, dev, port);
1939 if (err)
1940 return err;
1941 }
1942 }
1943 }
1944
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001945 return 0;
1946}
1947
Vivien Didelotf81ec902016-05-09 13:22:58 -04001948static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001949 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001950{
Vivien Didelot04bed142016-08-31 18:06:13 -04001951 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001952 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001953
Vivien Didelotfad09c72016-06-21 12:28:20 -04001954 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001955 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001956 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001957
Vivien Didelot466dfa02016-02-26 13:16:05 -05001958 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001959}
1960
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001961static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1962 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001963{
Vivien Didelot04bed142016-08-31 18:06:13 -04001964 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001965
Vivien Didelotfad09c72016-06-21 12:28:20 -04001966 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001967 if (mv88e6xxx_bridge_map(chip, br) ||
1968 mv88e6xxx_port_vlan_map(chip, port))
1969 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001970 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001971}
1972
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001973static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1974 int port, struct net_device *br)
1975{
1976 struct mv88e6xxx_chip *chip = ds->priv;
1977 int err;
1978
1979 if (!mv88e6xxx_has_pvt(chip))
1980 return 0;
1981
1982 mutex_lock(&chip->reg_lock);
1983 err = mv88e6xxx_pvt_map(chip, dev, port);
1984 mutex_unlock(&chip->reg_lock);
1985
1986 return err;
1987}
1988
1989static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1990 int port, struct net_device *br)
1991{
1992 struct mv88e6xxx_chip *chip = ds->priv;
1993
1994 if (!mv88e6xxx_has_pvt(chip))
1995 return;
1996
1997 mutex_lock(&chip->reg_lock);
1998 if (mv88e6xxx_pvt_map(chip, dev, port))
1999 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2000 mutex_unlock(&chip->reg_lock);
2001}
2002
Vivien Didelot17e708b2016-12-05 17:30:27 -05002003static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2004{
2005 if (chip->info->ops->reset)
2006 return chip->info->ops->reset(chip);
2007
2008 return 0;
2009}
2010
Vivien Didelot309eca62016-12-05 17:30:26 -05002011static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2012{
2013 struct gpio_desc *gpiod = chip->reset;
2014
2015 /* If there is a GPIO connected to the reset pin, toggle it */
2016 if (gpiod) {
2017 gpiod_set_value_cansleep(gpiod, 1);
2018 usleep_range(10000, 20000);
2019 gpiod_set_value_cansleep(gpiod, 0);
2020 usleep_range(10000, 20000);
2021 }
2022}
2023
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002024static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2025{
2026 int i, err;
2027
2028 /* Set all ports to the Disabled state */
2029 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002030 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002031 if (err)
2032 return err;
2033 }
2034
2035 /* Wait for transmit queues to drain,
2036 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2037 */
2038 usleep_range(2000, 4000);
2039
2040 return 0;
2041}
2042
Vivien Didelotfad09c72016-06-21 12:28:20 -04002043static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002044{
Vivien Didelota935c052016-09-29 12:21:53 -04002045 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002046
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002047 err = mv88e6xxx_disable_ports(chip);
2048 if (err)
2049 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002050
Vivien Didelot309eca62016-12-05 17:30:26 -05002051 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002052
Vivien Didelot17e708b2016-12-05 17:30:27 -05002053 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002054}
2055
Vivien Didelot43145572017-03-11 16:12:59 -05002056static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002057 enum mv88e6xxx_frame_mode frame,
2058 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002059{
2060 int err;
2061
Vivien Didelot43145572017-03-11 16:12:59 -05002062 if (!chip->info->ops->port_set_frame_mode)
2063 return -EOPNOTSUPP;
2064
2065 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002066 if (err)
2067 return err;
2068
Vivien Didelot43145572017-03-11 16:12:59 -05002069 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2070 if (err)
2071 return err;
2072
2073 if (chip->info->ops->port_set_ether_type)
2074 return chip->info->ops->port_set_ether_type(chip, port, etype);
2075
2076 return 0;
2077}
2078
2079static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2080{
2081 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002082 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002083 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002084}
2085
2086static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2087{
2088 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002089 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002090 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002091}
2092
2093static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2094{
2095 return mv88e6xxx_set_port_mode(chip, port,
2096 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002097 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2098 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002099}
2100
2101static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2102{
2103 if (dsa_is_dsa_port(chip->ds, port))
2104 return mv88e6xxx_set_port_mode_dsa(chip, port);
2105
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002106 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002107 return mv88e6xxx_set_port_mode_normal(chip, port);
2108
2109 /* Setup CPU port mode depending on its supported tag format */
2110 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2111 return mv88e6xxx_set_port_mode_dsa(chip, port);
2112
2113 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2114 return mv88e6xxx_set_port_mode_edsa(chip, port);
2115
2116 return -EINVAL;
2117}
2118
Vivien Didelotea698f42017-03-11 16:12:50 -05002119static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2120{
2121 bool message = dsa_is_dsa_port(chip->ds, port);
2122
2123 return mv88e6xxx_port_set_message_port(chip, port, message);
2124}
2125
Vivien Didelot601aeed2017-03-11 16:13:00 -05002126static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2127{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002128 struct dsa_switch *ds = chip->ds;
2129 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002130
2131 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002132 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002133 if (chip->info->ops->port_set_egress_floods)
2134 return chip->info->ops->port_set_egress_floods(chip, port,
2135 flood, flood);
2136
2137 return 0;
2138}
2139
Andrew Lunn6d917822017-05-26 01:03:21 +02002140static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2141 bool on)
2142{
Vivien Didelot523a8902017-05-26 18:02:42 -04002143 if (chip->info->ops->serdes_power)
2144 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002145
Vivien Didelot523a8902017-05-26 18:02:42 -04002146 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002147}
2148
Vivien Didelotfa371c82017-12-05 15:34:10 -05002149static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2150{
2151 struct dsa_switch *ds = chip->ds;
2152 int upstream_port;
2153 int err;
2154
Vivien Didelot07073c72017-12-05 15:34:13 -05002155 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002156 if (chip->info->ops->port_set_upstream_port) {
2157 err = chip->info->ops->port_set_upstream_port(chip, port,
2158 upstream_port);
2159 if (err)
2160 return err;
2161 }
2162
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002163 if (port == upstream_port) {
2164 if (chip->info->ops->set_cpu_port) {
2165 err = chip->info->ops->set_cpu_port(chip,
2166 upstream_port);
2167 if (err)
2168 return err;
2169 }
2170
2171 if (chip->info->ops->set_egress_port) {
2172 err = chip->info->ops->set_egress_port(chip,
2173 upstream_port);
2174 if (err)
2175 return err;
2176 }
2177 }
2178
Vivien Didelotfa371c82017-12-05 15:34:10 -05002179 return 0;
2180}
2181
Vivien Didelotfad09c72016-06-21 12:28:20 -04002182static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002183{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002184 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002185 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002186 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002187
Andrew Lunn7b898462018-08-09 15:38:47 +02002188 chip->ports[port].chip = chip;
2189 chip->ports[port].port = port;
2190
Vivien Didelotd78343d2016-11-04 03:23:36 +01002191 /* MAC Forcing register: don't force link, speed, duplex or flow control
2192 * state to any particular values on physical ports, but force the CPU
2193 * port and all DSA ports to their maximum bandwidth and full duplex.
2194 */
2195 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2196 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2197 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002198 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002199 PHY_INTERFACE_MODE_NA);
2200 else
2201 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2202 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002203 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002204 PHY_INTERFACE_MODE_NA);
2205 if (err)
2206 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002207
2208 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2209 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2210 * tunneling, determine priority by looking at 802.1p and IP
2211 * priority fields (IP prio has precedence), and set STP state
2212 * to Forwarding.
2213 *
2214 * If this is the CPU link, use DSA or EDSA tagging depending
2215 * on which tagging mode was configured.
2216 *
2217 * If this is a link to another switch, use DSA tagging mode.
2218 *
2219 * If this is the upstream port for this switch, enable
2220 * forwarding of unknown unicasts and multicasts.
2221 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002222 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2223 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2224 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2225 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002226 if (err)
2227 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002228
Vivien Didelot601aeed2017-03-11 16:13:00 -05002229 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002230 if (err)
2231 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002232
Vivien Didelot601aeed2017-03-11 16:13:00 -05002233 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002234 if (err)
2235 return err;
2236
Andrew Lunn04aca992017-05-26 01:03:24 +02002237 /* Enable the SERDES interface for DSA and CPU ports. Normal
2238 * ports SERDES are enabled when the port is enabled, thus
2239 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002240 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002241 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2242 err = mv88e6xxx_serdes_power(chip, port, true);
2243 if (err)
2244 return err;
2245 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002246
Vivien Didelot8efdda42015-08-13 12:52:23 -04002247 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002248 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002249 * untagged frames on this port, do a destination address lookup on all
2250 * received packets as usual, disable ARP mirroring and don't send a
2251 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002252 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002253 err = mv88e6xxx_port_set_map_da(chip, port);
2254 if (err)
2255 return err;
2256
Vivien Didelotfa371c82017-12-05 15:34:10 -05002257 err = mv88e6xxx_setup_upstream_port(chip, port);
2258 if (err)
2259 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002260
Andrew Lunna23b2962017-02-04 20:15:28 +01002261 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002262 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002263 if (err)
2264 return err;
2265
Vivien Didelotcd782652017-06-08 18:34:13 -04002266 if (chip->info->ops->port_set_jumbo_size) {
2267 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002268 if (err)
2269 return err;
2270 }
2271
Andrew Lunn54d792f2015-05-06 01:09:47 +02002272 /* Port Association Vector: when learning source addresses
2273 * of packets, add the address to the address database using
2274 * a port bitmap that has only the bit for this port set and
2275 * the other bits clear.
2276 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002277 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002278 /* Disable learning for CPU port */
2279 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002280 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002281
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002282 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2283 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002284 if (err)
2285 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002286
2287 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002288 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2289 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002290 if (err)
2291 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002292
Vivien Didelot08984322017-06-08 18:34:12 -04002293 if (chip->info->ops->port_pause_limit) {
2294 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002295 if (err)
2296 return err;
2297 }
2298
Vivien Didelotc8c94892017-03-11 16:13:01 -05002299 if (chip->info->ops->port_disable_learn_limit) {
2300 err = chip->info->ops->port_disable_learn_limit(chip, port);
2301 if (err)
2302 return err;
2303 }
2304
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002305 if (chip->info->ops->port_disable_pri_override) {
2306 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002307 if (err)
2308 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002309 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002310
Andrew Lunnef0a7312016-12-03 04:35:16 +01002311 if (chip->info->ops->port_tag_remap) {
2312 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002313 if (err)
2314 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002315 }
2316
Andrew Lunnef70b112016-12-03 04:45:18 +01002317 if (chip->info->ops->port_egress_rate_limiting) {
2318 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002319 if (err)
2320 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002321 }
2322
Vivien Didelotea698f42017-03-11 16:12:50 -05002323 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002324 if (err)
2325 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002326
Vivien Didelot207afda2016-04-14 14:42:09 -04002327 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002328 * database, and allow bidirectional communication between the
2329 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002330 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002331 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002332 if (err)
2333 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002334
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002335 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002336 if (err)
2337 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002338
2339 /* Default VLAN ID and priority: don't set a default VLAN
2340 * ID, and set the default packet priority to zero.
2341 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002342 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002343}
2344
Andrew Lunn04aca992017-05-26 01:03:24 +02002345static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2346 struct phy_device *phydev)
2347{
2348 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002349 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002350
2351 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002352
Vivien Didelot523a8902017-05-26 18:02:42 -04002353 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002354
2355 if (!err && chip->info->ops->serdes_irq_setup)
2356 err = chip->info->ops->serdes_irq_setup(chip, port);
2357
Andrew Lunn04aca992017-05-26 01:03:24 +02002358 mutex_unlock(&chip->reg_lock);
2359
2360 return err;
2361}
2362
2363static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2364 struct phy_device *phydev)
2365{
2366 struct mv88e6xxx_chip *chip = ds->priv;
2367
2368 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002369
2370 if (chip->info->ops->serdes_irq_free)
2371 chip->info->ops->serdes_irq_free(chip, port);
2372
Vivien Didelot523a8902017-05-26 18:02:42 -04002373 if (mv88e6xxx_serdes_power(chip, port, false))
2374 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002375
Andrew Lunn04aca992017-05-26 01:03:24 +02002376 mutex_unlock(&chip->reg_lock);
2377}
2378
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002379static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2380 unsigned int ageing_time)
2381{
Vivien Didelot04bed142016-08-31 18:06:13 -04002382 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002383 int err;
2384
2385 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002386 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002387 mutex_unlock(&chip->reg_lock);
2388
2389 return err;
2390}
2391
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002392static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002393{
2394 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002395
Andrew Lunnde2273872016-11-21 23:27:01 +01002396 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002397 if (chip->info->ops->stats_set_histogram) {
2398 err = chip->info->ops->stats_set_histogram(chip);
2399 if (err)
2400 return err;
2401 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002402
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002403 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002404}
2405
Vivien Didelotf81ec902016-05-09 13:22:58 -04002406static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002407{
Vivien Didelot04bed142016-08-31 18:06:13 -04002408 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002409 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002410 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002411 int i;
2412
Vivien Didelotfad09c72016-06-21 12:28:20 -04002413 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002414 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002415
Vivien Didelotfad09c72016-06-21 12:28:20 -04002416 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002417
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002418 /* Cache the cmode of each port. */
2419 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2420 if (chip->info->ops->port_get_cmode) {
2421 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2422 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002423 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002424
2425 chip->ports[i].cmode = cmode;
2426 }
2427 }
2428
Vivien Didelot97299342016-07-18 20:45:30 -04002429 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002430 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002431 if (dsa_is_unused_port(ds, i))
2432 continue;
2433
Vivien Didelot97299342016-07-18 20:45:30 -04002434 err = mv88e6xxx_setup_port(chip, i);
2435 if (err)
2436 goto unlock;
2437 }
2438
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002439 err = mv88e6xxx_irl_setup(chip);
2440 if (err)
2441 goto unlock;
2442
Vivien Didelot04a69a12017-10-13 14:18:05 -04002443 err = mv88e6xxx_mac_setup(chip);
2444 if (err)
2445 goto unlock;
2446
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002447 err = mv88e6xxx_phy_setup(chip);
2448 if (err)
2449 goto unlock;
2450
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002451 err = mv88e6xxx_vtu_setup(chip);
2452 if (err)
2453 goto unlock;
2454
Vivien Didelot81228992017-03-30 17:37:08 -04002455 err = mv88e6xxx_pvt_setup(chip);
2456 if (err)
2457 goto unlock;
2458
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002459 err = mv88e6xxx_atu_setup(chip);
2460 if (err)
2461 goto unlock;
2462
Andrew Lunn87fa8862017-11-09 22:29:56 +01002463 err = mv88e6xxx_broadcast_setup(chip, 0);
2464 if (err)
2465 goto unlock;
2466
Vivien Didelot9e907d72017-07-17 13:03:43 -04002467 err = mv88e6xxx_pot_setup(chip);
2468 if (err)
2469 goto unlock;
2470
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002471 err = mv88e6xxx_rmu_setup(chip);
2472 if (err)
2473 goto unlock;
2474
Vivien Didelot51c901a2017-07-17 13:03:41 -04002475 err = mv88e6xxx_rsvd2cpu_setup(chip);
2476 if (err)
2477 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002478
Vivien Didelotb28f8722018-04-26 21:56:44 -04002479 err = mv88e6xxx_trunk_setup(chip);
2480 if (err)
2481 goto unlock;
2482
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002483 err = mv88e6xxx_devmap_setup(chip);
2484 if (err)
2485 goto unlock;
2486
Vivien Didelot93e18d62018-05-11 17:16:35 -04002487 err = mv88e6xxx_pri_setup(chip);
2488 if (err)
2489 goto unlock;
2490
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002491 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002492 if (chip->info->ptp_support) {
2493 err = mv88e6xxx_ptp_setup(chip);
2494 if (err)
2495 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002496
2497 err = mv88e6xxx_hwtstamp_setup(chip);
2498 if (err)
2499 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002500 }
2501
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002502 err = mv88e6xxx_stats_setup(chip);
2503 if (err)
2504 goto unlock;
2505
Vivien Didelot6b17e862015-08-13 12:52:18 -04002506unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002507 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002508
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002509 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002510}
2511
Vivien Didelote57e5e72016-08-15 17:19:00 -04002512static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002513{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002514 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2515 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002516 u16 val;
2517 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002518
Andrew Lunnee26a222017-01-24 14:53:48 +01002519 if (!chip->info->ops->phy_read)
2520 return -EOPNOTSUPP;
2521
Vivien Didelotfad09c72016-06-21 12:28:20 -04002522 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002523 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002524 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002525
Andrew Lunnda9f3302017-02-01 03:40:05 +01002526 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002527 /* Some internal PHYs don't have a model number. */
2528 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2529 /* Then there is the 6165 family. It gets is
2530 * PHYs correct. But it can also have two
2531 * SERDES interfaces in the PHY address
2532 * space. And these don't have a model
2533 * number. But they are not PHYs, so we don't
2534 * want to give them something a PHY driver
2535 * will recognise.
2536 *
2537 * Use the mv88e6390 family model number
2538 * instead, for anything which really could be
2539 * a PHY,
2540 */
2541 if (!(val & 0x3f0))
2542 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002543 }
2544
Vivien Didelote57e5e72016-08-15 17:19:00 -04002545 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002546}
2547
Vivien Didelote57e5e72016-08-15 17:19:00 -04002548static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002549{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002550 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2551 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002552 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002553
Andrew Lunnee26a222017-01-24 14:53:48 +01002554 if (!chip->info->ops->phy_write)
2555 return -EOPNOTSUPP;
2556
Vivien Didelotfad09c72016-06-21 12:28:20 -04002557 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002558 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002559 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002560
2561 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002562}
2563
Vivien Didelotfad09c72016-06-21 12:28:20 -04002564static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002565 struct device_node *np,
2566 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002567{
2568 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002569 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002570 struct mii_bus *bus;
2571 int err;
2572
Andrew Lunn2510bab2018-02-22 01:51:49 +01002573 if (external) {
2574 mutex_lock(&chip->reg_lock);
2575 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2576 mutex_unlock(&chip->reg_lock);
2577
2578 if (err)
2579 return err;
2580 }
2581
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002582 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002583 if (!bus)
2584 return -ENOMEM;
2585
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002586 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002587 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002588 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002589 INIT_LIST_HEAD(&mdio_bus->list);
2590 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002591
Andrew Lunnb516d452016-06-04 21:17:06 +02002592 if (np) {
2593 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002594 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002595 } else {
2596 bus->name = "mv88e6xxx SMI";
2597 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2598 }
2599
2600 bus->read = mv88e6xxx_mdio_read;
2601 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002602 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002603
Andrew Lunn6f882842018-03-17 20:32:05 +01002604 if (!external) {
2605 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2606 if (err)
2607 return err;
2608 }
2609
Florian Fainelli00e798c2018-05-15 16:56:19 -07002610 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002611 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002612 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002613 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002614 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002615 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002616
2617 if (external)
2618 list_add_tail(&mdio_bus->list, &chip->mdios);
2619 else
2620 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002621
2622 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002623}
2624
Andrew Lunna3c53be52017-01-24 14:53:50 +01002625static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2626 { .compatible = "marvell,mv88e6xxx-mdio-external",
2627 .data = (void *)true },
2628 { },
2629};
2630
Andrew Lunn3126aee2017-12-07 01:05:57 +01002631static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2632
2633{
2634 struct mv88e6xxx_mdio_bus *mdio_bus;
2635 struct mii_bus *bus;
2636
2637 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2638 bus = mdio_bus->bus;
2639
Andrew Lunn6f882842018-03-17 20:32:05 +01002640 if (!mdio_bus->external)
2641 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2642
Andrew Lunn3126aee2017-12-07 01:05:57 +01002643 mdiobus_unregister(bus);
2644 }
2645}
2646
Andrew Lunna3c53be52017-01-24 14:53:50 +01002647static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2648 struct device_node *np)
2649{
2650 const struct of_device_id *match;
2651 struct device_node *child;
2652 int err;
2653
2654 /* Always register one mdio bus for the internal/default mdio
2655 * bus. This maybe represented in the device tree, but is
2656 * optional.
2657 */
2658 child = of_get_child_by_name(np, "mdio");
2659 err = mv88e6xxx_mdio_register(chip, child, false);
2660 if (err)
2661 return err;
2662
2663 /* Walk the device tree, and see if there are any other nodes
2664 * which say they are compatible with the external mdio
2665 * bus.
2666 */
2667 for_each_available_child_of_node(np, child) {
2668 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2669 if (match) {
2670 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002671 if (err) {
2672 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002673 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002674 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002675 }
2676 }
2677
2678 return 0;
2679}
2680
Vivien Didelot855b1932016-07-20 18:18:35 -04002681static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2682{
Vivien Didelot04bed142016-08-31 18:06:13 -04002683 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002684
2685 return chip->eeprom_len;
2686}
2687
Vivien Didelot855b1932016-07-20 18:18:35 -04002688static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2689 struct ethtool_eeprom *eeprom, u8 *data)
2690{
Vivien Didelot04bed142016-08-31 18:06:13 -04002691 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002692 int err;
2693
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002694 if (!chip->info->ops->get_eeprom)
2695 return -EOPNOTSUPP;
2696
Vivien Didelot855b1932016-07-20 18:18:35 -04002697 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002698 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002699 mutex_unlock(&chip->reg_lock);
2700
2701 if (err)
2702 return err;
2703
2704 eeprom->magic = 0xc3ec4951;
2705
2706 return 0;
2707}
2708
Vivien Didelot855b1932016-07-20 18:18:35 -04002709static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2710 struct ethtool_eeprom *eeprom, u8 *data)
2711{
Vivien Didelot04bed142016-08-31 18:06:13 -04002712 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002713 int err;
2714
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002715 if (!chip->info->ops->set_eeprom)
2716 return -EOPNOTSUPP;
2717
Vivien Didelot855b1932016-07-20 18:18:35 -04002718 if (eeprom->magic != 0xc3ec4951)
2719 return -EINVAL;
2720
2721 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002722 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002723 mutex_unlock(&chip->reg_lock);
2724
2725 return err;
2726}
2727
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002728static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002729 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002730 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2731 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002732 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002733 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002734 .phy_read = mv88e6185_phy_ppu_read,
2735 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002736 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002737 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002738 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002739 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002740 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002741 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002742 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002743 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002744 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002745 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002746 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002747 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002748 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002749 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002750 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002751 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2752 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002753 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002754 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2755 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002756 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002757 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002758 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002759 .ppu_enable = mv88e6185_g1_ppu_enable,
2760 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002761 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002762 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002763 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002764 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002765 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002766};
2767
2768static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002769 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002770 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2771 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002772 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002773 .phy_read = mv88e6185_phy_ppu_read,
2774 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002775 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002776 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002777 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002778 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002779 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002780 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002781 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002782 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002783 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002784 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002785 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2786 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002787 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002788 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002789 .ppu_enable = mv88e6185_g1_ppu_enable,
2790 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002791 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002792 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002793 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002794 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002795};
2796
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002797static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002798 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002799 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2800 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002801 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002802 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2803 .phy_read = mv88e6xxx_g2_smi_phy_read,
2804 .phy_write = mv88e6xxx_g2_smi_phy_write,
2805 .port_set_link = mv88e6xxx_port_set_link,
2806 .port_set_duplex = mv88e6xxx_port_set_duplex,
2807 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002808 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002809 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002810 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002811 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002812 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002813 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002814 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002815 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002816 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002817 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002818 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002819 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002820 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002821 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2822 .stats_get_strings = mv88e6095_stats_get_strings,
2823 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002824 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2825 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002826 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002827 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002828 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002829 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002830 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002831 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002832 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002833 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002834};
2835
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002836static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002837 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002838 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2839 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002840 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002841 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002842 .phy_read = mv88e6xxx_g2_smi_phy_read,
2843 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002844 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002845 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002846 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002847 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002848 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002849 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002850 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002851 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002852 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002853 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002854 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002855 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2856 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002857 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002858 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2859 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002860 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002861 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002862 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002863 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002864 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002865 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002866 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002867};
2868
2869static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002870 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002871 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2872 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002873 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002874 .phy_read = mv88e6185_phy_ppu_read,
2875 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002876 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002877 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002878 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002879 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002880 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002881 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002882 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002883 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002884 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002885 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002886 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002887 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002888 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002889 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002890 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002891 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002892 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2893 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002894 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002895 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2896 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002897 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002898 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002899 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002900 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002901 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002902 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002903 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002904 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002905 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002906};
2907
Vivien Didelot990e27b2017-03-28 13:50:32 -04002908static const struct mv88e6xxx_ops mv88e6141_ops = {
2909 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002910 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2911 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002912 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002913 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2914 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2915 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2916 .phy_read = mv88e6xxx_g2_smi_phy_read,
2917 .phy_write = mv88e6xxx_g2_smi_phy_write,
2918 .port_set_link = mv88e6xxx_port_set_link,
2919 .port_set_duplex = mv88e6xxx_port_set_duplex,
2920 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002921 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002922 .port_tag_remap = mv88e6095_port_tag_remap,
2923 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2924 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2925 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002926 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002927 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002928 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002929 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2930 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002931 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002932 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002933 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002934 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002935 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2936 .stats_get_strings = mv88e6320_stats_get_strings,
2937 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002938 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2939 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002940 .watchdog_ops = &mv88e6390_watchdog_ops,
2941 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002942 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002943 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002944 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002945 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002946 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002947 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02002948 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002949};
2950
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002951static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002952 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002953 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2954 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002955 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002956 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002957 .phy_read = mv88e6xxx_g2_smi_phy_read,
2958 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002959 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002960 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002961 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002962 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002963 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002964 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002965 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002966 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002967 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002968 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002969 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002970 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002971 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002972 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002973 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002974 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002975 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2976 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002977 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002978 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2979 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002980 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002981 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002982 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002983 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002984 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002985 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002986 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002987 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002988 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002989};
2990
2991static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002992 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002993 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2994 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002995 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002996 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002997 .phy_read = mv88e6165_phy_read,
2998 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002999 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003000 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003001 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003002 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003003 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003004 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003005 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003006 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003007 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003008 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3009 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003010 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003011 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3012 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003013 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003014 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003015 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003016 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003017 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003018 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003019 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003020 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003021 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003022};
3023
3024static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003025 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003026 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3027 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003028 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003029 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003030 .phy_read = mv88e6xxx_g2_smi_phy_read,
3031 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003032 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003033 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003034 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003035 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003036 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003037 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003038 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003039 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003040 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003041 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003042 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003043 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003044 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003045 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003046 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003047 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003048 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003049 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3050 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003051 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003052 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3053 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003054 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003055 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003056 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003057 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003058 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003059 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003060 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003061};
3062
3063static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003064 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003065 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3066 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003067 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003068 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3069 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003070 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003071 .phy_read = mv88e6xxx_g2_smi_phy_read,
3072 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003073 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003074 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003075 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003076 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003077 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003078 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003079 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003080 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003081 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003082 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003083 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003084 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003085 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003086 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003087 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003088 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003089 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003090 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3091 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003092 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003093 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3094 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003095 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003096 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003097 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003098 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003099 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003100 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003101 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003102 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003103 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003104 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003105};
3106
3107static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003108 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003109 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3110 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003111 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003112 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003113 .phy_read = mv88e6xxx_g2_smi_phy_read,
3114 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003115 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003116 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003117 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003118 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003119 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003120 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003121 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003122 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003123 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003124 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003125 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003126 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003127 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003128 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003129 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003130 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003131 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003132 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3133 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003134 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003135 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3136 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003137 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003138 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003139 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003140 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003141 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003142 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003143 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003144};
3145
3146static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003147 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003148 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3149 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003150 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003151 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3152 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003153 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003154 .phy_read = mv88e6xxx_g2_smi_phy_read,
3155 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003156 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003157 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003158 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003159 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003160 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003161 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003162 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003163 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003164 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003165 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003166 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003167 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003168 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003169 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003170 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003171 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003172 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003173 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3174 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003175 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003176 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3177 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003178 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003179 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003180 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003181 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003182 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003183 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003184 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003185 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003186 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3187 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003188 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003189 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003190};
3191
3192static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003193 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003194 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3195 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003196 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003197 .phy_read = mv88e6185_phy_ppu_read,
3198 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003199 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003200 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003201 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003202 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003203 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003204 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003205 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003206 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003207 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003208 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003209 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003210 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003211 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3212 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003213 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003214 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3215 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003216 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003217 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003218 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003219 .ppu_enable = mv88e6185_g1_ppu_enable,
3220 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003221 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003222 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003223 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003224 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003225};
3226
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003227static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003228 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003229 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003230 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3231 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003232 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3233 .phy_read = mv88e6xxx_g2_smi_phy_read,
3234 .phy_write = mv88e6xxx_g2_smi_phy_write,
3235 .port_set_link = mv88e6xxx_port_set_link,
3236 .port_set_duplex = mv88e6xxx_port_set_duplex,
3237 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3238 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003239 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003240 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003241 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003242 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003243 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003244 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003245 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003246 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003247 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003248 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003249 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003250 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003251 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3252 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003253 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003254 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3255 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003256 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003257 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003258 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003259 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003260 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003261 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3262 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003263 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003264 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3265 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003266 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003267 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003268};
3269
3270static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003271 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003272 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003273 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3274 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003275 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3276 .phy_read = mv88e6xxx_g2_smi_phy_read,
3277 .phy_write = mv88e6xxx_g2_smi_phy_write,
3278 .port_set_link = mv88e6xxx_port_set_link,
3279 .port_set_duplex = mv88e6xxx_port_set_duplex,
3280 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3281 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003282 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003283 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003284 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003285 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003286 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003287 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003288 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003289 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003290 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003291 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003292 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003293 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003294 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3295 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003296 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003297 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3298 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003299 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003300 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003301 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003302 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003303 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003304 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3305 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003306 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003307 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3308 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003309 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003310 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003311};
3312
3313static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003314 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003315 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003316 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3317 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003318 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3319 .phy_read = mv88e6xxx_g2_smi_phy_read,
3320 .phy_write = mv88e6xxx_g2_smi_phy_write,
3321 .port_set_link = mv88e6xxx_port_set_link,
3322 .port_set_duplex = mv88e6xxx_port_set_duplex,
3323 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3324 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003325 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003326 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003327 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003328 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003329 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003330 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003331 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003332 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003333 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003334 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003335 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003336 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003337 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3338 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003339 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003340 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3341 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003342 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003343 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003344 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003345 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003346 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003347 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3348 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003349 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003350 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3351 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003352 .avb_ops = &mv88e6390_avb_ops,
3353 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003354 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003355};
3356
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003357static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003358 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003359 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3360 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003361 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003362 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3363 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003364 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003365 .phy_read = mv88e6xxx_g2_smi_phy_read,
3366 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003367 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003368 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003369 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003370 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003371 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003372 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003373 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003374 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003375 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003376 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003377 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003378 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003379 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003380 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003381 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003382 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003383 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003384 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3385 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003386 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003387 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3388 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003389 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003390 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003391 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003392 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003393 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003394 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003395 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003396 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003397 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3398 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003399 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003400 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003401 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003402 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003403};
3404
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003405static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003406 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003407 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003408 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3409 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003410 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3411 .phy_read = mv88e6xxx_g2_smi_phy_read,
3412 .phy_write = mv88e6xxx_g2_smi_phy_write,
3413 .port_set_link = mv88e6xxx_port_set_link,
3414 .port_set_duplex = mv88e6xxx_port_set_duplex,
3415 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3416 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003417 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003418 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003419 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003420 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003421 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003422 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003423 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003424 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003425 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003426 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003427 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003428 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003429 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3430 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003431 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003432 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3433 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003434 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003435 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003436 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003437 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003438 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003439 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3440 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003441 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003442 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3443 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003444 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003445 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003446 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003447 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003448};
3449
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003450static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003451 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003452 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3453 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003454 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003455 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3456 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003457 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003458 .phy_read = mv88e6xxx_g2_smi_phy_read,
3459 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003460 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003461 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003462 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003463 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003464 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003465 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003466 .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,
Andrew Lunnef70b112016-12-03 04:45:18 +01003468 .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 Didelotc8c94892017-03-11 16:13:01 -05003470 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003471 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003472 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003473 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003474 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003475 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003476 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3477 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003478 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003479 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3480 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003481 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003482 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003483 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003484 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003485 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003486 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003487 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003488 .avb_ops = &mv88e6352_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 = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003491};
3492
3493static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003494 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003495 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3496 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003497 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003498 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3499 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003500 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003501 .phy_read = mv88e6xxx_g2_smi_phy_read,
3502 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003503 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003504 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003505 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003506 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003507 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003508 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003509 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003510 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003511 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003512 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003513 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003514 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003515 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003516 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003517 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003518 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003519 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3520 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003521 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003522 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3523 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003524 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003525 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003526 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003527 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003528 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003529 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003530 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003531 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003532};
3533
Vivien Didelot16e329a2017-03-28 13:50:33 -04003534static const struct mv88e6xxx_ops mv88e6341_ops = {
3535 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003536 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3537 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003538 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003539 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3540 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3541 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3542 .phy_read = mv88e6xxx_g2_smi_phy_read,
3543 .phy_write = mv88e6xxx_g2_smi_phy_write,
3544 .port_set_link = mv88e6xxx_port_set_link,
3545 .port_set_duplex = mv88e6xxx_port_set_duplex,
3546 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003547 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003548 .port_tag_remap = mv88e6095_port_tag_remap,
3549 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3550 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3551 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003552 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003553 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003554 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003555 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3556 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003557 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003558 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003559 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003560 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003561 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3562 .stats_get_strings = mv88e6320_stats_get_strings,
3563 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003564 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3565 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003566 .watchdog_ops = &mv88e6390_watchdog_ops,
3567 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003568 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003569 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003570 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003571 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003572 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003573 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003574 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003575 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003576 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003577};
3578
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003579static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003580 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003581 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3582 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003583 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003584 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003585 .phy_read = mv88e6xxx_g2_smi_phy_read,
3586 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003587 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003588 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003589 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003590 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003591 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003592 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003593 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003594 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003595 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003596 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003597 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003598 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003599 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003600 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003601 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003602 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003603 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003604 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3605 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003606 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003607 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3608 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003609 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003610 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003611 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003612 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003613 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003614 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003615 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003616};
3617
3618static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003619 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003620 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3621 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003622 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003623 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003624 .phy_read = mv88e6xxx_g2_smi_phy_read,
3625 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003626 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003627 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003628 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003629 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003630 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003631 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003632 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003633 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003634 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003635 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003636 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003637 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003638 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003639 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003640 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003641 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003642 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003643 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3644 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003645 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003646 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3647 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003648 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003649 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003650 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003651 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003652 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003653 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003654 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003655 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003656 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003657};
3658
3659static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003660 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003661 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3662 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003663 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003664 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3665 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003666 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003667 .phy_read = mv88e6xxx_g2_smi_phy_read,
3668 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003669 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003670 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003671 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003672 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003673 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003674 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003675 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003676 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003677 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003678 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003679 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003680 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003681 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003682 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003683 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003684 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003685 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003686 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3687 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003688 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003689 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3690 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003691 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003692 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003693 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003694 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003695 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003696 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003697 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003698 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003699 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3700 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003701 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003702 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003703 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003704 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3705 .serdes_get_strings = mv88e6352_serdes_get_strings,
3706 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003707 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003708};
3709
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003710static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003711 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003712 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003713 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3714 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003715 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3716 .phy_read = mv88e6xxx_g2_smi_phy_read,
3717 .phy_write = mv88e6xxx_g2_smi_phy_write,
3718 .port_set_link = mv88e6xxx_port_set_link,
3719 .port_set_duplex = mv88e6xxx_port_set_duplex,
3720 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3721 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003722 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003723 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003724 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003725 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003726 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003727 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003728 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003729 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003730 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003731 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003732 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003733 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003734 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003735 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003736 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3737 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003738 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003739 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3740 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003741 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003742 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003743 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003744 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003745 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003746 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3747 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003748 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003749 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3750 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003751 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003752 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003753 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003754 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003755};
3756
3757static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003758 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003759 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003760 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3761 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003762 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3763 .phy_read = mv88e6xxx_g2_smi_phy_read,
3764 .phy_write = mv88e6xxx_g2_smi_phy_write,
3765 .port_set_link = mv88e6xxx_port_set_link,
3766 .port_set_duplex = mv88e6xxx_port_set_duplex,
3767 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3768 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003769 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003770 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003771 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003772 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003773 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003774 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003775 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003776 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003777 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003778 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003779 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003780 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003781 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003782 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003783 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3784 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003785 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003786 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3787 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003788 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003789 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003790 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003791 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003792 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003793 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3794 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003795 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003796 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3797 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003798 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003799 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003800 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003801 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003802};
3803
Vivien Didelotf81ec902016-05-09 13:22:58 -04003804static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3805 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003806 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003807 .family = MV88E6XXX_FAMILY_6097,
3808 .name = "Marvell 88E6085",
3809 .num_databases = 4096,
3810 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003811 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003812 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003813 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003814 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003815 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003816 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003817 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003818 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003819 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003820 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003821 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003822 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003823 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003824 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003825 },
3826
3827 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003828 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003829 .family = MV88E6XXX_FAMILY_6095,
3830 .name = "Marvell 88E6095/88E6095F",
3831 .num_databases = 256,
3832 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003833 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003834 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003835 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003836 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003837 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003838 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003839 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003840 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003841 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003842 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003843 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003844 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003845 },
3846
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003847 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003848 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003849 .family = MV88E6XXX_FAMILY_6097,
3850 .name = "Marvell 88E6097/88E6097F",
3851 .num_databases = 4096,
3852 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003853 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003854 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003855 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003856 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003857 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003858 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003859 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003860 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003861 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003862 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003863 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003864 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003865 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003866 .ops = &mv88e6097_ops,
3867 },
3868
Vivien Didelotf81ec902016-05-09 13:22:58 -04003869 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003870 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003871 .family = MV88E6XXX_FAMILY_6165,
3872 .name = "Marvell 88E6123",
3873 .num_databases = 4096,
3874 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003875 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003876 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003877 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003878 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003879 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003880 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003881 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003882 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003883 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003884 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003885 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003886 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003887 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003888 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003889 },
3890
3891 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003892 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003893 .family = MV88E6XXX_FAMILY_6185,
3894 .name = "Marvell 88E6131",
3895 .num_databases = 256,
3896 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003897 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003898 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003899 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003900 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003901 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003902 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003903 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003904 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003905 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003906 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003907 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003908 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003909 },
3910
Vivien Didelot990e27b2017-03-28 13:50:32 -04003911 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003912 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003913 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003914 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003915 .num_databases = 4096,
3916 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003917 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003918 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003919 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003920 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003921 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003922 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003923 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003924 .age_time_coeff = 3750,
3925 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003926 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003927 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003928 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003929 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003930 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003931 .ops = &mv88e6141_ops,
3932 },
3933
Vivien Didelotf81ec902016-05-09 13:22:58 -04003934 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003935 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003936 .family = MV88E6XXX_FAMILY_6165,
3937 .name = "Marvell 88E6161",
3938 .num_databases = 4096,
3939 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003940 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003941 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003942 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003943 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003944 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003945 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003946 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003947 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003948 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003949 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003950 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003951 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003952 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003953 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003954 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003955 },
3956
3957 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003958 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003959 .family = MV88E6XXX_FAMILY_6165,
3960 .name = "Marvell 88E6165",
3961 .num_databases = 4096,
3962 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003963 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003964 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003965 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003966 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003967 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003968 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003969 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003970 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003971 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003972 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003973 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003974 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003975 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003976 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003977 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003978 },
3979
3980 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003981 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003982 .family = MV88E6XXX_FAMILY_6351,
3983 .name = "Marvell 88E6171",
3984 .num_databases = 4096,
3985 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003986 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003987 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003988 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003989 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003990 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003991 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003992 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003993 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003994 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003995 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003996 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003997 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003998 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003999 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004000 },
4001
4002 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004003 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004004 .family = MV88E6XXX_FAMILY_6352,
4005 .name = "Marvell 88E6172",
4006 .num_databases = 4096,
4007 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004008 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004009 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004010 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004011 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004012 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004013 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004014 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004015 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004016 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004017 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004018 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004019 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004020 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004021 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004022 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004023 },
4024
4025 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004026 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004027 .family = MV88E6XXX_FAMILY_6351,
4028 .name = "Marvell 88E6175",
4029 .num_databases = 4096,
4030 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004031 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004032 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004033 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004034 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004035 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004036 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004037 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004038 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004039 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004040 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004041 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004042 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004043 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004044 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004045 },
4046
4047 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004048 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004049 .family = MV88E6XXX_FAMILY_6352,
4050 .name = "Marvell 88E6176",
4051 .num_databases = 4096,
4052 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004053 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004054 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004055 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004056 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004057 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004058 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004059 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004060 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004061 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004062 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004063 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004064 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004065 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004066 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004067 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004068 },
4069
4070 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004071 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004072 .family = MV88E6XXX_FAMILY_6185,
4073 .name = "Marvell 88E6185",
4074 .num_databases = 256,
4075 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004076 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004077 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004078 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004079 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004080 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004081 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004082 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004083 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004084 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004085 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004086 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004087 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004088 },
4089
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004090 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004091 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004092 .family = MV88E6XXX_FAMILY_6390,
4093 .name = "Marvell 88E6190",
4094 .num_databases = 4096,
4095 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004096 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004097 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004098 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004099 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004100 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004101 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004102 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004103 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004104 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004105 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004106 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004107 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004108 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004109 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004110 .ops = &mv88e6190_ops,
4111 },
4112
4113 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004114 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004115 .family = MV88E6XXX_FAMILY_6390,
4116 .name = "Marvell 88E6190X",
4117 .num_databases = 4096,
4118 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004119 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004120 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004121 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004122 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004123 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004124 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004125 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004126 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004127 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004128 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004129 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004130 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004131 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004132 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004133 .ops = &mv88e6190x_ops,
4134 },
4135
4136 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004137 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004138 .family = MV88E6XXX_FAMILY_6390,
4139 .name = "Marvell 88E6191",
4140 .num_databases = 4096,
4141 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004142 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004143 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004144 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004145 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004146 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004147 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004148 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004149 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004150 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004151 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004152 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004153 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004154 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004155 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004156 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004157 },
4158
Vivien Didelotf81ec902016-05-09 13:22:58 -04004159 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004160 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004161 .family = MV88E6XXX_FAMILY_6352,
4162 .name = "Marvell 88E6240",
4163 .num_databases = 4096,
4164 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004165 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004166 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004167 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004168 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004169 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004170 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004171 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004172 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004173 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004174 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004175 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004176 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004177 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004178 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004179 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004180 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004181 },
4182
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004183 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004184 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004185 .family = MV88E6XXX_FAMILY_6390,
4186 .name = "Marvell 88E6290",
4187 .num_databases = 4096,
4188 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004189 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004190 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004191 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004192 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004193 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004194 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004195 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004196 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004197 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004198 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004199 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004200 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004201 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004202 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004203 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004204 .ops = &mv88e6290_ops,
4205 },
4206
Vivien Didelotf81ec902016-05-09 13:22:58 -04004207 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004208 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004209 .family = MV88E6XXX_FAMILY_6320,
4210 .name = "Marvell 88E6320",
4211 .num_databases = 4096,
4212 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004213 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004214 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004215 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004216 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004217 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004218 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004219 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004220 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004221 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004222 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004223 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004224 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004225 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004226 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004227 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004228 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004229 },
4230
4231 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004232 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004233 .family = MV88E6XXX_FAMILY_6320,
4234 .name = "Marvell 88E6321",
4235 .num_databases = 4096,
4236 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004237 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004238 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004239 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004240 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004241 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004242 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004243 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004244 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004245 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004246 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004247 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004248 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004249 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004250 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004251 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004252 },
4253
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004254 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004255 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004256 .family = MV88E6XXX_FAMILY_6341,
4257 .name = "Marvell 88E6341",
4258 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004259 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004260 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004261 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004262 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004263 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004264 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004265 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004266 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004267 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004268 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004269 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004270 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004271 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004272 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004273 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004274 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004275 .ops = &mv88e6341_ops,
4276 },
4277
Vivien Didelotf81ec902016-05-09 13:22:58 -04004278 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004279 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004280 .family = MV88E6XXX_FAMILY_6351,
4281 .name = "Marvell 88E6350",
4282 .num_databases = 4096,
4283 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004284 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004285 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004286 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004287 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004288 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004289 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004290 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004291 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004292 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004293 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004294 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004295 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004296 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004297 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004298 },
4299
4300 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004301 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004302 .family = MV88E6XXX_FAMILY_6351,
4303 .name = "Marvell 88E6351",
4304 .num_databases = 4096,
4305 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004306 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004307 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004308 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004309 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004310 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004311 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004312 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004313 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004314 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004315 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004316 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004317 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004318 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004319 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004320 },
4321
4322 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004323 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004324 .family = MV88E6XXX_FAMILY_6352,
4325 .name = "Marvell 88E6352",
4326 .num_databases = 4096,
4327 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004328 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004329 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004330 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004331 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004332 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004333 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004334 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004335 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004336 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004337 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004338 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004339 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004340 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004341 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004342 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004343 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004344 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004345 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004346 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004347 .family = MV88E6XXX_FAMILY_6390,
4348 .name = "Marvell 88E6390",
4349 .num_databases = 4096,
4350 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004351 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004352 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004353 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004354 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004355 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004356 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004357 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004358 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004359 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004360 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004361 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004362 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004363 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004364 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004365 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004366 .ops = &mv88e6390_ops,
4367 },
4368 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004369 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004370 .family = MV88E6XXX_FAMILY_6390,
4371 .name = "Marvell 88E6390X",
4372 .num_databases = 4096,
4373 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004374 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004375 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004376 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004377 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004378 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004379 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004380 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004381 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004382 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004383 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004384 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004385 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004386 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004387 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004388 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004389 .ops = &mv88e6390x_ops,
4390 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004391};
4392
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004393static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004394{
Vivien Didelota439c062016-04-17 13:23:58 -04004395 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004396
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004397 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4398 if (mv88e6xxx_table[i].prod_num == prod_num)
4399 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004400
Vivien Didelotb9b37712015-10-30 19:39:48 -04004401 return NULL;
4402}
4403
Vivien Didelotfad09c72016-06-21 12:28:20 -04004404static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004405{
4406 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004407 unsigned int prod_num, rev;
4408 u16 id;
4409 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004410
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004411 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004412 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004413 mutex_unlock(&chip->reg_lock);
4414 if (err)
4415 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004416
Vivien Didelot107fcc12017-06-12 12:37:36 -04004417 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4418 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004419
4420 info = mv88e6xxx_lookup_info(prod_num);
4421 if (!info)
4422 return -ENODEV;
4423
Vivien Didelotcaac8542016-06-20 13:14:09 -04004424 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004425 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004426
Vivien Didelotca070c12016-09-02 14:45:34 -04004427 err = mv88e6xxx_g2_require(chip);
4428 if (err)
4429 return err;
4430
Vivien Didelotfad09c72016-06-21 12:28:20 -04004431 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4432 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004433
4434 return 0;
4435}
4436
Vivien Didelotfad09c72016-06-21 12:28:20 -04004437static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004438{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004439 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004440
Vivien Didelotfad09c72016-06-21 12:28:20 -04004441 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4442 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004443 return NULL;
4444
Vivien Didelotfad09c72016-06-21 12:28:20 -04004445 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004446
Vivien Didelotfad09c72016-06-21 12:28:20 -04004447 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004448 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004449
Vivien Didelotfad09c72016-06-21 12:28:20 -04004450 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004451}
4452
Vivien Didelotfad09c72016-06-21 12:28:20 -04004453static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004454 struct mii_bus *bus, int sw_addr)
4455{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004456 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004457 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004458 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004459 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004460 else
4461 return -EINVAL;
4462
Vivien Didelotfad09c72016-06-21 12:28:20 -04004463 chip->bus = bus;
4464 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004465
4466 return 0;
4467}
4468
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004469static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4470 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004471{
Vivien Didelot04bed142016-08-31 18:06:13 -04004472 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004473
Andrew Lunn443d5a12016-12-03 04:35:18 +01004474 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004475}
4476
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004477#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004478static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4479 struct device *host_dev, int sw_addr,
4480 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004481{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004482 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004483 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004484 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004485
Vivien Didelota439c062016-04-17 13:23:58 -04004486 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004487 if (!bus)
4488 return NULL;
4489
Vivien Didelotfad09c72016-06-21 12:28:20 -04004490 chip = mv88e6xxx_alloc_chip(dsa_dev);
4491 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004492 return NULL;
4493
Vivien Didelotcaac8542016-06-20 13:14:09 -04004494 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004495 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004496
Vivien Didelotfad09c72016-06-21 12:28:20 -04004497 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004498 if (err)
4499 goto free;
4500
Vivien Didelotfad09c72016-06-21 12:28:20 -04004501 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004502 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004503 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004504
Andrew Lunndc30c352016-10-16 19:56:49 +02004505 mutex_lock(&chip->reg_lock);
4506 err = mv88e6xxx_switch_reset(chip);
4507 mutex_unlock(&chip->reg_lock);
4508 if (err)
4509 goto free;
4510
Vivien Didelote57e5e72016-08-15 17:19:00 -04004511 mv88e6xxx_phy_init(chip);
4512
Andrew Lunna3c53be52017-01-24 14:53:50 +01004513 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004514 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004515 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004516
Vivien Didelotfad09c72016-06-21 12:28:20 -04004517 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004518
Vivien Didelotfad09c72016-06-21 12:28:20 -04004519 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004520free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004521 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004522
4523 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004524}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004525#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004526
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004527static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004528 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004529{
4530 /* We don't need any dynamic resource from the kernel (yet),
4531 * so skip the prepare phase.
4532 */
4533
4534 return 0;
4535}
4536
4537static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004538 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004539{
Vivien Didelot04bed142016-08-31 18:06:13 -04004540 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004541
4542 mutex_lock(&chip->reg_lock);
4543 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004544 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004545 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4546 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004547 mutex_unlock(&chip->reg_lock);
4548}
4549
4550static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4551 const struct switchdev_obj_port_mdb *mdb)
4552{
Vivien Didelot04bed142016-08-31 18:06:13 -04004553 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004554 int err;
4555
4556 mutex_lock(&chip->reg_lock);
4557 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004558 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004559 mutex_unlock(&chip->reg_lock);
4560
4561 return err;
4562}
4563
Florian Fainellia82f67a2017-01-08 14:52:08 -08004564static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004565#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004566 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004567#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004568 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004569 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004570 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004571 .phylink_validate = mv88e6xxx_validate,
4572 .phylink_mac_link_state = mv88e6xxx_link_state,
4573 .phylink_mac_config = mv88e6xxx_mac_config,
4574 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4575 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004576 .get_strings = mv88e6xxx_get_strings,
4577 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4578 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004579 .port_enable = mv88e6xxx_port_enable,
4580 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004581 .get_mac_eee = mv88e6xxx_get_mac_eee,
4582 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004583 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004584 .get_eeprom = mv88e6xxx_get_eeprom,
4585 .set_eeprom = mv88e6xxx_set_eeprom,
4586 .get_regs_len = mv88e6xxx_get_regs_len,
4587 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004588 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004589 .port_bridge_join = mv88e6xxx_port_bridge_join,
4590 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4591 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004592 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004593 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4594 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4595 .port_vlan_add = mv88e6xxx_port_vlan_add,
4596 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004597 .port_fdb_add = mv88e6xxx_port_fdb_add,
4598 .port_fdb_del = mv88e6xxx_port_fdb_del,
4599 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004600 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4601 .port_mdb_add = mv88e6xxx_port_mdb_add,
4602 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004603 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4604 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004605 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4606 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4607 .port_txtstamp = mv88e6xxx_port_txtstamp,
4608 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4609 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004610};
4611
Florian Fainelliab3d4082017-01-08 14:52:07 -08004612static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4613 .ops = &mv88e6xxx_switch_ops,
4614};
4615
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004616static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004617{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004618 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004619 struct dsa_switch *ds;
4620
Vivien Didelot73b12042017-03-30 17:37:10 -04004621 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004622 if (!ds)
4623 return -ENOMEM;
4624
Vivien Didelotfad09c72016-06-21 12:28:20 -04004625 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004626 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004627 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004628 ds->ageing_time_min = chip->info->age_time_coeff;
4629 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004630
4631 dev_set_drvdata(dev, ds);
4632
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004633 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004634}
4635
Vivien Didelotfad09c72016-06-21 12:28:20 -04004636static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004637{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004638 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004639}
4640
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004641static const void *pdata_device_get_match_data(struct device *dev)
4642{
4643 const struct of_device_id *matches = dev->driver->of_match_table;
4644 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4645
4646 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4647 matches++) {
4648 if (!strcmp(pdata->compatible, matches->compatible))
4649 return matches->data;
4650 }
4651 return NULL;
4652}
4653
Vivien Didelot57d32312016-06-20 13:13:58 -04004654static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004655{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004656 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004657 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004658 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004659 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004660 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004661 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004662 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004663
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004664 if (!np && !pdata)
4665 return -EINVAL;
4666
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004667 if (np)
4668 compat_info = of_device_get_match_data(dev);
4669
4670 if (pdata) {
4671 compat_info = pdata_device_get_match_data(dev);
4672
4673 if (!pdata->netdev)
4674 return -EINVAL;
4675
4676 for (port = 0; port < DSA_MAX_PORTS; port++) {
4677 if (!(pdata->enabled_ports & (1 << port)))
4678 continue;
4679 if (strcmp(pdata->cd.port_names[port], "cpu"))
4680 continue;
4681 pdata->cd.netdev[port] = &pdata->netdev->dev;
4682 break;
4683 }
4684 }
4685
Vivien Didelotcaac8542016-06-20 13:14:09 -04004686 if (!compat_info)
4687 return -EINVAL;
4688
Vivien Didelotfad09c72016-06-21 12:28:20 -04004689 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004690 if (!chip) {
4691 err = -ENOMEM;
4692 goto out;
4693 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004694
Vivien Didelotfad09c72016-06-21 12:28:20 -04004695 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004696
Vivien Didelotfad09c72016-06-21 12:28:20 -04004697 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004698 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004699 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004700
Andrew Lunnb4308f02016-11-21 23:26:55 +01004701 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004702 if (IS_ERR(chip->reset)) {
4703 err = PTR_ERR(chip->reset);
4704 goto out;
4705 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004706
Vivien Didelotfad09c72016-06-21 12:28:20 -04004707 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004708 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004709 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004710
Vivien Didelote57e5e72016-08-15 17:19:00 -04004711 mv88e6xxx_phy_init(chip);
4712
Andrew Lunn00baabe2018-05-19 22:31:35 +02004713 if (chip->info->ops->get_eeprom) {
4714 if (np)
4715 of_property_read_u32(np, "eeprom-length",
4716 &chip->eeprom_len);
4717 else
4718 chip->eeprom_len = pdata->eeprom_len;
4719 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004720
Andrew Lunndc30c352016-10-16 19:56:49 +02004721 mutex_lock(&chip->reg_lock);
4722 err = mv88e6xxx_switch_reset(chip);
4723 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004724 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004725 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004726
Andrew Lunndc30c352016-10-16 19:56:49 +02004727 chip->irq = of_irq_get(np, 0);
4728 if (chip->irq == -EPROBE_DEFER) {
4729 err = chip->irq;
4730 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004731 }
4732
Andrew Lunn294d7112018-02-22 22:58:32 +01004733 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004734 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004735 * controllers
4736 */
4737 mutex_lock(&chip->reg_lock);
4738 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004739 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004740 else
4741 err = mv88e6xxx_irq_poll_setup(chip);
4742 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004743
Andrew Lunn294d7112018-02-22 22:58:32 +01004744 if (err)
4745 goto out;
4746
4747 if (chip->info->g2_irqs > 0) {
4748 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004749 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004750 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004751 }
4752
Andrew Lunn294d7112018-02-22 22:58:32 +01004753 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4754 if (err)
4755 goto out_g2_irq;
4756
4757 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4758 if (err)
4759 goto out_g1_atu_prob_irq;
4760
Andrew Lunna3c53be52017-01-24 14:53:50 +01004761 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004762 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004763 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004764
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004765 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004766 if (err)
4767 goto out_mdio;
4768
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004769 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004770
4771out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004772 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004773out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004774 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004775out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004776 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004777out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004778 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004779 mv88e6xxx_g2_irq_free(chip);
4780out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004781 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004782 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004783 else
4784 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004785out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004786 if (pdata)
4787 dev_put(pdata->netdev);
4788
Andrew Lunndc30c352016-10-16 19:56:49 +02004789 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004790}
4791
4792static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4793{
4794 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004795 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004796
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004797 if (chip->info->ptp_support) {
4798 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004799 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004800 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004801
Andrew Lunn930188c2016-08-22 16:01:03 +02004802 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004803 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004804 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004805
Andrew Lunn76f38f12018-03-17 20:21:09 +01004806 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4807 mv88e6xxx_g1_atu_prob_irq_free(chip);
4808
4809 if (chip->info->g2_irqs > 0)
4810 mv88e6xxx_g2_irq_free(chip);
4811
Andrew Lunn76f38f12018-03-17 20:21:09 +01004812 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004813 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004814 else
4815 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004816}
4817
4818static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004819 {
4820 .compatible = "marvell,mv88e6085",
4821 .data = &mv88e6xxx_table[MV88E6085],
4822 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004823 {
4824 .compatible = "marvell,mv88e6190",
4825 .data = &mv88e6xxx_table[MV88E6190],
4826 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004827 { /* sentinel */ },
4828};
4829
4830MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4831
4832static struct mdio_driver mv88e6xxx_driver = {
4833 .probe = mv88e6xxx_probe,
4834 .remove = mv88e6xxx_remove,
4835 .mdiodrv.driver = {
4836 .name = "mv88e6085",
4837 .of_match_table = mv88e6xxx_of_match,
4838 },
4839};
4840
Ben Hutchings98e67302011-11-25 14:36:19 +00004841static int __init mv88e6xxx_init(void)
4842{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004843 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004844 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004845}
4846module_init(mv88e6xxx_init);
4847
4848static void __exit mv88e6xxx_cleanup(void)
4849{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004850 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004851 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004852}
4853module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004854
4855MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4856MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4857MODULE_LICENSE("GPL");