blob: b57f5403982a3daab802146c7408a9ec2c304f54 [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
Andrew Lunndea87022015-08-31 15:56:47 +0200578/* We expect the switch to perform auto negotiation if there is a real
579 * phy. However, in the case of a fixed link phy, we force the port
580 * settings from the fixed link settings.
581 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400582static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
583 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200584{
Vivien Didelot04bed142016-08-31 18:06:13 -0400585 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200586 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200587
588 if (!phy_is_pseudo_fixed_link(phydev))
589 return;
590
Vivien Didelotfad09c72016-06-21 12:28:20 -0400591 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100592 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200593 phydev->duplex, phydev->pause,
594 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400595 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100596
597 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400598 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200599}
600
Russell King6c422e32018-08-09 15:38:39 +0200601static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
602 unsigned long *mask,
603 struct phylink_link_state *state)
604{
605 if (!phy_interface_mode_is_8023z(state->interface)) {
606 /* 10M and 100M are only supported in non-802.3z mode */
607 phylink_set(mask, 10baseT_Half);
608 phylink_set(mask, 10baseT_Full);
609 phylink_set(mask, 100baseT_Half);
610 phylink_set(mask, 100baseT_Full);
611 }
612}
613
614static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
615 unsigned long *mask,
616 struct phylink_link_state *state)
617{
618 /* FIXME: if the port is in 1000Base-X mode, then it only supports
619 * 1000M FD speeds. In this case, CMODE will indicate 5.
620 */
621 phylink_set(mask, 1000baseT_Full);
622 phylink_set(mask, 1000baseX_Full);
623
624 mv88e6065_phylink_validate(chip, port, mask, state);
625}
626
627static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
628 unsigned long *mask,
629 struct phylink_link_state *state)
630{
631 /* No ethtool bits for 200Mbps */
632 phylink_set(mask, 1000baseT_Full);
633 phylink_set(mask, 1000baseX_Full);
634
635 mv88e6065_phylink_validate(chip, port, mask, state);
636}
637
638static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
639 unsigned long *mask,
640 struct phylink_link_state *state)
641{
642 if (port >= 9)
643 phylink_set(mask, 2500baseX_Full);
644
645 /* No ethtool bits for 200Mbps */
646 phylink_set(mask, 1000baseT_Full);
647 phylink_set(mask, 1000baseX_Full);
648
649 mv88e6065_phylink_validate(chip, port, mask, state);
650}
651
652static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
653 unsigned long *mask,
654 struct phylink_link_state *state)
655{
656 if (port >= 9) {
657 phylink_set(mask, 10000baseT_Full);
658 phylink_set(mask, 10000baseKR_Full);
659 }
660
661 mv88e6390_phylink_validate(chip, port, mask, state);
662}
663
Russell Kingc9a23562018-05-10 13:17:35 -0700664static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
665 unsigned long *supported,
666 struct phylink_link_state *state)
667{
Russell King6c422e32018-08-09 15:38:39 +0200668 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
669 struct mv88e6xxx_chip *chip = ds->priv;
670
671 /* Allow all the expected bits */
672 phylink_set(mask, Autoneg);
673 phylink_set(mask, Pause);
674 phylink_set_port_modes(mask);
675
676 if (chip->info->ops->phylink_validate)
677 chip->info->ops->phylink_validate(chip, port, mask, state);
678
679 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
680 bitmap_and(state->advertising, state->advertising, mask,
681 __ETHTOOL_LINK_MODE_MASK_NBITS);
682
683 /* We can only operate at 2500BaseX or 1000BaseX. If requested
684 * to advertise both, only report advertising at 2500BaseX.
685 */
686 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700687}
688
689static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
690 struct phylink_link_state *state)
691{
692 struct mv88e6xxx_chip *chip = ds->priv;
693 int err;
694
695 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200696 if (chip->info->ops->port_link_state)
697 err = chip->info->ops->port_link_state(chip, port, state);
698 else
699 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700700 mutex_unlock(&chip->reg_lock);
701
702 return err;
703}
704
705static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
706 unsigned int mode,
707 const struct phylink_link_state *state)
708{
709 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200710 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700711
712 if (mode == MLO_AN_PHY)
713 return;
714
715 if (mode == MLO_AN_FIXED) {
716 link = LINK_FORCED_UP;
717 speed = state->speed;
718 duplex = state->duplex;
719 } else {
720 speed = SPEED_UNFORCED;
721 duplex = DUPLEX_UNFORCED;
722 link = LINK_UNFORCED;
723 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200724 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700725
726 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200727 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700728 state->interface);
729 mutex_unlock(&chip->reg_lock);
730
731 if (err && err != -EOPNOTSUPP)
732 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
733}
734
735static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
736{
737 struct mv88e6xxx_chip *chip = ds->priv;
738 int err;
739
740 mutex_lock(&chip->reg_lock);
741 err = chip->info->ops->port_set_link(chip, port, link);
742 mutex_unlock(&chip->reg_lock);
743
744 if (err)
745 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
746}
747
748static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
749 unsigned int mode,
750 phy_interface_t interface)
751{
752 if (mode == MLO_AN_FIXED)
753 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
754}
755
756static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
757 unsigned int mode, phy_interface_t interface,
758 struct phy_device *phydev)
759{
760 if (mode == MLO_AN_FIXED)
761 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
762}
763
Andrew Lunna605a0f2016-11-21 23:26:58 +0100764static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000765{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100766 if (!chip->info->ops->stats_snapshot)
767 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000768
Andrew Lunna605a0f2016-11-21 23:26:58 +0100769 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000770}
771
Andrew Lunne413e7e2015-04-02 04:06:38 +0200772static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100773 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
774 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
775 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
776 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
777 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
778 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
779 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
780 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
781 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
782 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
783 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
784 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
785 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
786 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
787 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
788 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
789 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
790 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
791 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
792 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
793 { "single", 4, 0x14, STATS_TYPE_BANK0, },
794 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
795 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
796 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
797 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
798 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
799 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
800 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
801 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
802 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
803 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
804 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
805 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
806 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
807 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
808 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
809 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
810 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
811 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
812 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
813 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
814 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
815 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
816 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
817 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
818 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
819 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
820 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
821 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
822 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
823 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
824 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
825 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
826 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
827 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
828 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
829 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
830 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
831 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200832};
833
Vivien Didelotfad09c72016-06-21 12:28:20 -0400834static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100835 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100836 int port, u16 bank1_select,
837 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200838{
Andrew Lunn80c46272015-06-20 18:42:30 +0200839 u32 low;
840 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100841 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200842 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200843 u64 value;
844
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100845 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100846 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200847 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
848 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800849 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200850
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200851 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100852 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200853 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
854 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800855 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200856 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200857 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100858 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100859 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100860 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100861 /* fall through */
862 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100863 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100864 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100865 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100866 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500867 break;
868 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800869 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200870 }
871 value = (((u64)high) << 16) | low;
872 return value;
873}
874
Andrew Lunn436fe172018-03-01 02:02:29 +0100875static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
876 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100877{
878 struct mv88e6xxx_hw_stat *stat;
879 int i, j;
880
881 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
882 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100883 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100884 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
885 ETH_GSTRING_LEN);
886 j++;
887 }
888 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100889
890 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100891}
892
Andrew Lunn436fe172018-03-01 02:02:29 +0100893static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
894 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100895{
Andrew Lunn436fe172018-03-01 02:02:29 +0100896 return mv88e6xxx_stats_get_strings(chip, data,
897 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100898}
899
Andrew Lunn436fe172018-03-01 02:02:29 +0100900static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
901 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100902{
Andrew Lunn436fe172018-03-01 02:02:29 +0100903 return mv88e6xxx_stats_get_strings(chip, data,
904 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100905}
906
Andrew Lunn65f60e42018-03-28 23:50:28 +0200907static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
908 "atu_member_violation",
909 "atu_miss_violation",
910 "atu_full_violation",
911 "vtu_member_violation",
912 "vtu_miss_violation",
913};
914
915static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
916{
917 unsigned int i;
918
919 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
920 strlcpy(data + i * ETH_GSTRING_LEN,
921 mv88e6xxx_atu_vtu_stats_strings[i],
922 ETH_GSTRING_LEN);
923}
924
Andrew Lunndfafe442016-11-21 23:27:02 +0100925static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700926 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100927{
Vivien Didelot04bed142016-08-31 18:06:13 -0400928 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100929 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100930
Florian Fainelli89f09042018-04-25 12:12:50 -0700931 if (stringset != ETH_SS_STATS)
932 return;
933
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100934 mutex_lock(&chip->reg_lock);
935
Andrew Lunndfafe442016-11-21 23:27:02 +0100936 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100937 count = chip->info->ops->stats_get_strings(chip, data);
938
939 if (chip->info->ops->serdes_get_strings) {
940 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200941 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100942 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100943
Andrew Lunn65f60e42018-03-28 23:50:28 +0200944 data += count * ETH_GSTRING_LEN;
945 mv88e6xxx_atu_vtu_get_strings(data);
946
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100947 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100948}
949
950static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
951 int types)
952{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100953 struct mv88e6xxx_hw_stat *stat;
954 int i, j;
955
956 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
957 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100958 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100959 j++;
960 }
961 return j;
962}
963
Andrew Lunndfafe442016-11-21 23:27:02 +0100964static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
965{
966 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
967 STATS_TYPE_PORT);
968}
969
970static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
971{
972 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
973 STATS_TYPE_BANK1);
974}
975
Florian Fainelli89f09042018-04-25 12:12:50 -0700976static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100977{
978 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100979 int serdes_count = 0;
980 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100981
Florian Fainelli89f09042018-04-25 12:12:50 -0700982 if (sset != ETH_SS_STATS)
983 return 0;
984
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100985 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100986 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100987 count = chip->info->ops->stats_get_sset_count(chip);
988 if (count < 0)
989 goto out;
990
991 if (chip->info->ops->serdes_get_sset_count)
992 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
993 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +0200994 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +0100995 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200996 goto out;
997 }
998 count += serdes_count;
999 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1000
Andrew Lunn436fe172018-03-01 02:02:29 +01001001out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001002 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001003
Andrew Lunn436fe172018-03-01 02:02:29 +01001004 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001005}
1006
Andrew Lunn436fe172018-03-01 02:02:29 +01001007static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1008 uint64_t *data, int types,
1009 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001010{
1011 struct mv88e6xxx_hw_stat *stat;
1012 int i, j;
1013
1014 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1015 stat = &mv88e6xxx_hw_stats[i];
1016 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001017 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001018 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1019 bank1_select,
1020 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001021 mutex_unlock(&chip->reg_lock);
1022
Andrew Lunn052f9472016-11-21 23:27:03 +01001023 j++;
1024 }
1025 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001026 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001027}
1028
Andrew Lunn436fe172018-03-01 02:02:29 +01001029static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1030 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001031{
1032 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001033 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001034 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001035}
1036
Andrew Lunn436fe172018-03-01 02:02:29 +01001037static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1038 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001039{
1040 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001041 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001042 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1043 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001044}
1045
Andrew Lunn436fe172018-03-01 02:02:29 +01001046static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1047 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001048{
1049 return mv88e6xxx_stats_get_stats(chip, port, data,
1050 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001051 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1052 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001053}
1054
Andrew Lunn65f60e42018-03-28 23:50:28 +02001055static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1056 uint64_t *data)
1057{
1058 *data++ = chip->ports[port].atu_member_violation;
1059 *data++ = chip->ports[port].atu_miss_violation;
1060 *data++ = chip->ports[port].atu_full_violation;
1061 *data++ = chip->ports[port].vtu_member_violation;
1062 *data++ = chip->ports[port].vtu_miss_violation;
1063}
1064
Andrew Lunn052f9472016-11-21 23:27:03 +01001065static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1066 uint64_t *data)
1067{
Andrew Lunn436fe172018-03-01 02:02:29 +01001068 int count = 0;
1069
Andrew Lunn052f9472016-11-21 23:27:03 +01001070 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001071 count = chip->info->ops->stats_get_stats(chip, port, data);
1072
Andrew Lunn65f60e42018-03-28 23:50:28 +02001073 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001074 if (chip->info->ops->serdes_get_stats) {
1075 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001076 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001077 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001078 data += count;
1079 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1080 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001081}
1082
Vivien Didelotf81ec902016-05-09 13:22:58 -04001083static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1084 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001085{
Vivien Didelot04bed142016-08-31 18:06:13 -04001086 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001087 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001088
Vivien Didelotfad09c72016-06-21 12:28:20 -04001089 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001090
Andrew Lunna605a0f2016-11-21 23:26:58 +01001091 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001092 mutex_unlock(&chip->reg_lock);
1093
1094 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001095 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001096
1097 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001098
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001099}
Ben Hutchings98e67302011-11-25 14:36:19 +00001100
Vivien Didelotf81ec902016-05-09 13:22:58 -04001101static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001102{
1103 return 32 * sizeof(u16);
1104}
1105
Vivien Didelotf81ec902016-05-09 13:22:58 -04001106static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1107 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001108{
Vivien Didelot04bed142016-08-31 18:06:13 -04001109 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001110 int err;
1111 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001112 u16 *p = _p;
1113 int i;
1114
1115 regs->version = 0;
1116
1117 memset(p, 0xff, 32 * sizeof(u16));
1118
Vivien Didelotfad09c72016-06-21 12:28:20 -04001119 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001120
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001121 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001122
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001123 err = mv88e6xxx_port_read(chip, port, i, &reg);
1124 if (!err)
1125 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001126 }
Vivien Didelot23062512016-05-09 13:22:45 -04001127
Vivien Didelotfad09c72016-06-21 12:28:20 -04001128 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001129}
1130
Vivien Didelot08f50062017-08-01 16:32:41 -04001131static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1132 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001133{
Vivien Didelot5480db62017-08-01 16:32:40 -04001134 /* Nothing to do on the port's MAC */
1135 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001136}
1137
Vivien Didelot08f50062017-08-01 16:32:41 -04001138static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1139 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001140{
Vivien Didelot5480db62017-08-01 16:32:40 -04001141 /* Nothing to do on the port's MAC */
1142 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001143}
1144
Vivien Didelote5887a22017-03-30 17:37:11 -04001145static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001146{
Vivien Didelote5887a22017-03-30 17:37:11 -04001147 struct dsa_switch *ds = NULL;
1148 struct net_device *br;
1149 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001150 int i;
1151
Vivien Didelote5887a22017-03-30 17:37:11 -04001152 if (dev < DSA_MAX_SWITCHES)
1153 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001154
Vivien Didelote5887a22017-03-30 17:37:11 -04001155 /* Prevent frames from unknown switch or port */
1156 if (!ds || port >= ds->num_ports)
1157 return 0;
1158
1159 /* Frames from DSA links and CPU ports can egress any local port */
1160 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1161 return mv88e6xxx_port_mask(chip);
1162
1163 br = ds->ports[port].bridge_dev;
1164 pvlan = 0;
1165
1166 /* Frames from user ports can egress any local DSA links and CPU ports,
1167 * as well as any local member of their bridge group.
1168 */
1169 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1170 if (dsa_is_cpu_port(chip->ds, i) ||
1171 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001172 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001173 pvlan |= BIT(i);
1174
1175 return pvlan;
1176}
1177
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001178static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001179{
1180 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001181
1182 /* prevent frames from going back out of the port they came in on */
1183 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001184
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001185 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001186}
1187
Vivien Didelotf81ec902016-05-09 13:22:58 -04001188static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1189 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001190{
Vivien Didelot04bed142016-08-31 18:06:13 -04001191 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001192 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001193
Vivien Didelotfad09c72016-06-21 12:28:20 -04001194 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001195 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001196 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001197
1198 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001199 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001200}
1201
Vivien Didelot93e18d62018-05-11 17:16:35 -04001202static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1203{
1204 int err;
1205
1206 if (chip->info->ops->ieee_pri_map) {
1207 err = chip->info->ops->ieee_pri_map(chip);
1208 if (err)
1209 return err;
1210 }
1211
1212 if (chip->info->ops->ip_pri_map) {
1213 err = chip->info->ops->ip_pri_map(chip);
1214 if (err)
1215 return err;
1216 }
1217
1218 return 0;
1219}
1220
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001221static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1222{
1223 int target, port;
1224 int err;
1225
1226 if (!chip->info->global2_addr)
1227 return 0;
1228
1229 /* Initialize the routing port to the 32 possible target devices */
1230 for (target = 0; target < 32; target++) {
1231 port = 0x1f;
1232 if (target < DSA_MAX_SWITCHES)
1233 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1234 port = chip->ds->rtable[target];
1235
1236 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1237 if (err)
1238 return err;
1239 }
1240
Vivien Didelot02317e62018-05-09 11:38:49 -04001241 if (chip->info->ops->set_cascade_port) {
1242 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1243 err = chip->info->ops->set_cascade_port(chip, port);
1244 if (err)
1245 return err;
1246 }
1247
Vivien Didelot23c98912018-05-09 11:38:50 -04001248 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1249 if (err)
1250 return err;
1251
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001252 return 0;
1253}
1254
Vivien Didelotb28f8722018-04-26 21:56:44 -04001255static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1256{
1257 /* Clear all trunk masks and mapping */
1258 if (chip->info->global2_addr)
1259 return mv88e6xxx_g2_trunk_clear(chip);
1260
1261 return 0;
1262}
1263
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001264static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1265{
1266 if (chip->info->ops->rmu_disable)
1267 return chip->info->ops->rmu_disable(chip);
1268
1269 return 0;
1270}
1271
Vivien Didelot9e907d72017-07-17 13:03:43 -04001272static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1273{
1274 if (chip->info->ops->pot_clear)
1275 return chip->info->ops->pot_clear(chip);
1276
1277 return 0;
1278}
1279
Vivien Didelot51c901a2017-07-17 13:03:41 -04001280static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1281{
1282 if (chip->info->ops->mgmt_rsvd2cpu)
1283 return chip->info->ops->mgmt_rsvd2cpu(chip);
1284
1285 return 0;
1286}
1287
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001288static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1289{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001290 int err;
1291
Vivien Didelotdaefc942017-03-11 16:12:54 -05001292 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1293 if (err)
1294 return err;
1295
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001296 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1297 if (err)
1298 return err;
1299
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001300 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1301}
1302
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001303static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1304{
1305 int port;
1306 int err;
1307
1308 if (!chip->info->ops->irl_init_all)
1309 return 0;
1310
1311 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1312 /* Disable ingress rate limiting by resetting all per port
1313 * ingress rate limit resources to their initial state.
1314 */
1315 err = chip->info->ops->irl_init_all(chip, port);
1316 if (err)
1317 return err;
1318 }
1319
1320 return 0;
1321}
1322
Vivien Didelot04a69a12017-10-13 14:18:05 -04001323static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1324{
1325 if (chip->info->ops->set_switch_mac) {
1326 u8 addr[ETH_ALEN];
1327
1328 eth_random_addr(addr);
1329
1330 return chip->info->ops->set_switch_mac(chip, addr);
1331 }
1332
1333 return 0;
1334}
1335
Vivien Didelot17a15942017-03-30 17:37:09 -04001336static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1337{
1338 u16 pvlan = 0;
1339
1340 if (!mv88e6xxx_has_pvt(chip))
1341 return -EOPNOTSUPP;
1342
1343 /* Skip the local source device, which uses in-chip port VLAN */
1344 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001345 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001346
1347 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1348}
1349
Vivien Didelot81228992017-03-30 17:37:08 -04001350static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1351{
Vivien Didelot17a15942017-03-30 17:37:09 -04001352 int dev, port;
1353 int err;
1354
Vivien Didelot81228992017-03-30 17:37:08 -04001355 if (!mv88e6xxx_has_pvt(chip))
1356 return 0;
1357
1358 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1359 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1360 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001361 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1362 if (err)
1363 return err;
1364
1365 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1366 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1367 err = mv88e6xxx_pvt_map(chip, dev, port);
1368 if (err)
1369 return err;
1370 }
1371 }
1372
1373 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001374}
1375
Vivien Didelot749efcb2016-09-22 16:49:24 -04001376static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1377{
1378 struct mv88e6xxx_chip *chip = ds->priv;
1379 int err;
1380
1381 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001382 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001383 mutex_unlock(&chip->reg_lock);
1384
1385 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001386 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001387}
1388
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001389static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1390{
1391 if (!chip->info->max_vid)
1392 return 0;
1393
1394 return mv88e6xxx_g1_vtu_flush(chip);
1395}
1396
Vivien Didelotf1394b782017-05-01 14:05:22 -04001397static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1398 struct mv88e6xxx_vtu_entry *entry)
1399{
1400 if (!chip->info->ops->vtu_getnext)
1401 return -EOPNOTSUPP;
1402
1403 return chip->info->ops->vtu_getnext(chip, entry);
1404}
1405
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001406static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1407 struct mv88e6xxx_vtu_entry *entry)
1408{
1409 if (!chip->info->ops->vtu_loadpurge)
1410 return -EOPNOTSUPP;
1411
1412 return chip->info->ops->vtu_loadpurge(chip, entry);
1413}
1414
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001415static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001416{
1417 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001418 struct mv88e6xxx_vtu_entry vlan = {
1419 .vid = chip->info->max_vid,
1420 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001421 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001422
1423 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1424
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001425 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001426 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001427 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001428 if (err)
1429 return err;
1430
1431 set_bit(*fid, fid_bitmap);
1432 }
1433
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001434 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001435 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001436 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001437 if (err)
1438 return err;
1439
1440 if (!vlan.valid)
1441 break;
1442
1443 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001444 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001445
1446 /* The reset value 0x000 is used to indicate that multiple address
1447 * databases are not needed. Return the next positive available.
1448 */
1449 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001450 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001451 return -ENOSPC;
1452
1453 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001454 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001455}
1456
Vivien Didelot567aa592017-05-01 14:05:25 -04001457static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1458 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001459{
1460 int err;
1461
1462 if (!vid)
1463 return -EINVAL;
1464
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001465 entry->vid = vid - 1;
1466 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001467
Vivien Didelotf1394b782017-05-01 14:05:22 -04001468 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001469 if (err)
1470 return err;
1471
Vivien Didelot567aa592017-05-01 14:05:25 -04001472 if (entry->vid == vid && entry->valid)
1473 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001474
Vivien Didelot567aa592017-05-01 14:05:25 -04001475 if (new) {
1476 int i;
1477
1478 /* Initialize a fresh VLAN entry */
1479 memset(entry, 0, sizeof(*entry));
1480 entry->valid = true;
1481 entry->vid = vid;
1482
Vivien Didelot553a7682017-06-07 18:12:16 -04001483 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001484 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001485 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001486 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001487
1488 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001489 }
1490
Vivien Didelot567aa592017-05-01 14:05:25 -04001491 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1492 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001493}
1494
Vivien Didelotda9c3592016-02-12 12:09:40 -05001495static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1496 u16 vid_begin, u16 vid_end)
1497{
Vivien Didelot04bed142016-08-31 18:06:13 -04001498 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001499 struct mv88e6xxx_vtu_entry vlan = {
1500 .vid = vid_begin - 1,
1501 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001502 int i, err;
1503
Andrew Lunndb06ae412017-09-25 23:32:20 +02001504 /* DSA and CPU ports have to be members of multiple vlans */
1505 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1506 return 0;
1507
Vivien Didelotda9c3592016-02-12 12:09:40 -05001508 if (!vid_begin)
1509 return -EOPNOTSUPP;
1510
Vivien Didelotfad09c72016-06-21 12:28:20 -04001511 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001512
Vivien Didelotda9c3592016-02-12 12:09:40 -05001513 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001514 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001515 if (err)
1516 goto unlock;
1517
1518 if (!vlan.valid)
1519 break;
1520
1521 if (vlan.vid > vid_end)
1522 break;
1523
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001524 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001525 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1526 continue;
1527
Andrew Lunncd886462017-11-09 22:29:53 +01001528 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001529 continue;
1530
Vivien Didelotbd00e052017-05-01 14:05:11 -04001531 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001532 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001533 continue;
1534
Vivien Didelotc8652c82017-10-16 11:12:19 -04001535 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001536 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001537 break; /* same bridge, check next VLAN */
1538
Vivien Didelotc8652c82017-10-16 11:12:19 -04001539 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001540 continue;
1541
Andrew Lunn743fcc22017-11-09 22:29:54 +01001542 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1543 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001544 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545 err = -EOPNOTSUPP;
1546 goto unlock;
1547 }
1548 } while (vlan.vid < vid_end);
1549
1550unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001551 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001552
1553 return err;
1554}
1555
Vivien Didelotf81ec902016-05-09 13:22:58 -04001556static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1557 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001558{
Vivien Didelot04bed142016-08-31 18:06:13 -04001559 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001560 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1561 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001562 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001563
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001564 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001565 return -EOPNOTSUPP;
1566
Vivien Didelotfad09c72016-06-21 12:28:20 -04001567 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001568 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001569 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001570
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001571 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001572}
1573
Vivien Didelot57d32312016-06-20 13:13:58 -04001574static int
1575mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001576 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001577{
Vivien Didelot04bed142016-08-31 18:06:13 -04001578 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001579 int err;
1580
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001581 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001582 return -EOPNOTSUPP;
1583
Vivien Didelotda9c3592016-02-12 12:09:40 -05001584 /* If the requested port doesn't belong to the same bridge as the VLAN
1585 * members, do not support it (yet) and fallback to software VLAN.
1586 */
1587 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1588 vlan->vid_end);
1589 if (err)
1590 return err;
1591
Vivien Didelot76e398a2015-11-01 12:33:55 -05001592 /* We don't need any dynamic resource from the kernel (yet),
1593 * so skip the prepare phase.
1594 */
1595 return 0;
1596}
1597
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001598static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1599 const unsigned char *addr, u16 vid,
1600 u8 state)
1601{
1602 struct mv88e6xxx_vtu_entry vlan;
1603 struct mv88e6xxx_atu_entry entry;
1604 int err;
1605
1606 /* Null VLAN ID corresponds to the port private database */
1607 if (vid == 0)
1608 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1609 else
1610 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1611 if (err)
1612 return err;
1613
1614 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1615 ether_addr_copy(entry.mac, addr);
1616 eth_addr_dec(entry.mac);
1617
1618 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1619 if (err)
1620 return err;
1621
1622 /* Initialize a fresh ATU entry if it isn't found */
1623 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1624 !ether_addr_equal(entry.mac, addr)) {
1625 memset(&entry, 0, sizeof(entry));
1626 ether_addr_copy(entry.mac, addr);
1627 }
1628
1629 /* Purge the ATU entry only if no port is using it anymore */
1630 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1631 entry.portvec &= ~BIT(port);
1632 if (!entry.portvec)
1633 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1634 } else {
1635 entry.portvec |= BIT(port);
1636 entry.state = state;
1637 }
1638
1639 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1640}
1641
Andrew Lunn87fa8862017-11-09 22:29:56 +01001642static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1643 u16 vid)
1644{
1645 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1646 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1647
1648 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1649}
1650
1651static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1652{
1653 int port;
1654 int err;
1655
1656 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1657 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1658 if (err)
1659 return err;
1660 }
1661
1662 return 0;
1663}
1664
Vivien Didelotfad09c72016-06-21 12:28:20 -04001665static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001666 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001667{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001668 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001669 int err;
1670
Vivien Didelot567aa592017-05-01 14:05:25 -04001671 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001672 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001673 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001674
Vivien Didelotc91498e2017-06-07 18:12:13 -04001675 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001676
Andrew Lunn87fa8862017-11-09 22:29:56 +01001677 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1678 if (err)
1679 return err;
1680
1681 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001682}
1683
Vivien Didelotf81ec902016-05-09 13:22:58 -04001684static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001685 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001686{
Vivien Didelot04bed142016-08-31 18:06:13 -04001687 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001688 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1689 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001690 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001691 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001692
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001693 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001694 return;
1695
Vivien Didelotc91498e2017-06-07 18:12:13 -04001696 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001697 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001698 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001699 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001700 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001701 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001702
Vivien Didelotfad09c72016-06-21 12:28:20 -04001703 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001704
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001705 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001706 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001707 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1708 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001709
Vivien Didelot77064f32016-11-04 03:23:30 +01001710 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001711 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1712 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001713
Vivien Didelotfad09c72016-06-21 12:28:20 -04001714 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001715}
1716
Vivien Didelotfad09c72016-06-21 12:28:20 -04001717static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001718 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001719{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001720 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001721 int i, err;
1722
Vivien Didelot567aa592017-05-01 14:05:25 -04001723 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001724 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001725 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001726
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001727 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001728 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001729 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001730
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001731 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001732
1733 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001734 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001735 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001736 if (vlan.member[i] !=
1737 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001738 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001739 break;
1740 }
1741 }
1742
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001743 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001744 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001745 return err;
1746
Vivien Didelote606ca32017-03-11 16:12:55 -05001747 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001748}
1749
Vivien Didelotf81ec902016-05-09 13:22:58 -04001750static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1751 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001752{
Vivien Didelot04bed142016-08-31 18:06:13 -04001753 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001754 u16 pvid, vid;
1755 int err = 0;
1756
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001757 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001758 return -EOPNOTSUPP;
1759
Vivien Didelotfad09c72016-06-21 12:28:20 -04001760 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001761
Vivien Didelot77064f32016-11-04 03:23:30 +01001762 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001763 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001764 goto unlock;
1765
Vivien Didelot76e398a2015-11-01 12:33:55 -05001766 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001767 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001768 if (err)
1769 goto unlock;
1770
1771 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001772 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001773 if (err)
1774 goto unlock;
1775 }
1776 }
1777
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001778unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001779 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001780
1781 return err;
1782}
1783
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001784static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1785 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001786{
Vivien Didelot04bed142016-08-31 18:06:13 -04001787 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001788 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001789
Vivien Didelotfad09c72016-06-21 12:28:20 -04001790 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001791 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1792 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001793 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001794
1795 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001796}
1797
Vivien Didelotf81ec902016-05-09 13:22:58 -04001798static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001799 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001800{
Vivien Didelot04bed142016-08-31 18:06:13 -04001801 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001802 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001803
Vivien Didelotfad09c72016-06-21 12:28:20 -04001804 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001805 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001806 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001807 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001808
Vivien Didelot83dabd12016-08-31 11:50:04 -04001809 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001810}
1811
Vivien Didelot83dabd12016-08-31 11:50:04 -04001812static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1813 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001814 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001815{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001816 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001817 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001818 int err;
1819
Vivien Didelot27c0e602017-06-15 12:14:01 -04001820 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001821 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001822
1823 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001824 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001825 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001826 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001827 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001828 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001829
Vivien Didelot27c0e602017-06-15 12:14:01 -04001830 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001831 break;
1832
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001833 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001834 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001835
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001836 if (!is_unicast_ether_addr(addr.mac))
1837 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001838
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001839 is_static = (addr.state ==
1840 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1841 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001842 if (err)
1843 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001844 } while (!is_broadcast_ether_addr(addr.mac));
1845
1846 return err;
1847}
1848
Vivien Didelot83dabd12016-08-31 11:50:04 -04001849static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001850 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001851{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001852 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001853 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001854 };
1855 u16 fid;
1856 int err;
1857
1858 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001859 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001860 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001861 mutex_unlock(&chip->reg_lock);
1862
Vivien Didelot83dabd12016-08-31 11:50:04 -04001863 if (err)
1864 return err;
1865
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001866 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001867 if (err)
1868 return err;
1869
1870 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001871 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001872 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001873 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001874 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001875 if (err)
1876 return err;
1877
1878 if (!vlan.valid)
1879 break;
1880
1881 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001882 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001883 if (err)
1884 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001885 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001886
1887 return err;
1888}
1889
Vivien Didelotf81ec902016-05-09 13:22:58 -04001890static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001891 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001892{
Vivien Didelot04bed142016-08-31 18:06:13 -04001893 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001894
Andrew Lunna61e5402018-02-15 14:38:35 +01001895 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001896}
1897
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001898static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1899 struct net_device *br)
1900{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001901 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001902 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001903 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001904 int err;
1905
1906 /* Remap the Port VLAN of each local bridge group member */
1907 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1908 if (chip->ds->ports[port].bridge_dev == br) {
1909 err = mv88e6xxx_port_vlan_map(chip, port);
1910 if (err)
1911 return err;
1912 }
1913 }
1914
Vivien Didelote96a6e02017-03-30 17:37:13 -04001915 if (!mv88e6xxx_has_pvt(chip))
1916 return 0;
1917
1918 /* Remap the Port VLAN of each cross-chip bridge group member */
1919 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1920 ds = chip->ds->dst->ds[dev];
1921 if (!ds)
1922 break;
1923
1924 for (port = 0; port < ds->num_ports; ++port) {
1925 if (ds->ports[port].bridge_dev == br) {
1926 err = mv88e6xxx_pvt_map(chip, dev, port);
1927 if (err)
1928 return err;
1929 }
1930 }
1931 }
1932
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001933 return 0;
1934}
1935
Vivien Didelotf81ec902016-05-09 13:22:58 -04001936static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001937 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001938{
Vivien Didelot04bed142016-08-31 18:06:13 -04001939 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001940 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001941
Vivien Didelotfad09c72016-06-21 12:28:20 -04001942 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001943 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001944 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001945
Vivien Didelot466dfa02016-02-26 13:16:05 -05001946 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001947}
1948
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001949static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1950 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001951{
Vivien Didelot04bed142016-08-31 18:06:13 -04001952 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001953
Vivien Didelotfad09c72016-06-21 12:28:20 -04001954 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001955 if (mv88e6xxx_bridge_map(chip, br) ||
1956 mv88e6xxx_port_vlan_map(chip, port))
1957 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001958 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001959}
1960
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001961static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1962 int port, struct net_device *br)
1963{
1964 struct mv88e6xxx_chip *chip = ds->priv;
1965 int err;
1966
1967 if (!mv88e6xxx_has_pvt(chip))
1968 return 0;
1969
1970 mutex_lock(&chip->reg_lock);
1971 err = mv88e6xxx_pvt_map(chip, dev, port);
1972 mutex_unlock(&chip->reg_lock);
1973
1974 return err;
1975}
1976
1977static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1978 int port, struct net_device *br)
1979{
1980 struct mv88e6xxx_chip *chip = ds->priv;
1981
1982 if (!mv88e6xxx_has_pvt(chip))
1983 return;
1984
1985 mutex_lock(&chip->reg_lock);
1986 if (mv88e6xxx_pvt_map(chip, dev, port))
1987 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
1988 mutex_unlock(&chip->reg_lock);
1989}
1990
Vivien Didelot17e708b2016-12-05 17:30:27 -05001991static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
1992{
1993 if (chip->info->ops->reset)
1994 return chip->info->ops->reset(chip);
1995
1996 return 0;
1997}
1998
Vivien Didelot309eca62016-12-05 17:30:26 -05001999static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2000{
2001 struct gpio_desc *gpiod = chip->reset;
2002
2003 /* If there is a GPIO connected to the reset pin, toggle it */
2004 if (gpiod) {
2005 gpiod_set_value_cansleep(gpiod, 1);
2006 usleep_range(10000, 20000);
2007 gpiod_set_value_cansleep(gpiod, 0);
2008 usleep_range(10000, 20000);
2009 }
2010}
2011
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002012static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2013{
2014 int i, err;
2015
2016 /* Set all ports to the Disabled state */
2017 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002018 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002019 if (err)
2020 return err;
2021 }
2022
2023 /* Wait for transmit queues to drain,
2024 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2025 */
2026 usleep_range(2000, 4000);
2027
2028 return 0;
2029}
2030
Vivien Didelotfad09c72016-06-21 12:28:20 -04002031static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002032{
Vivien Didelota935c052016-09-29 12:21:53 -04002033 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002034
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002035 err = mv88e6xxx_disable_ports(chip);
2036 if (err)
2037 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002038
Vivien Didelot309eca62016-12-05 17:30:26 -05002039 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002040
Vivien Didelot17e708b2016-12-05 17:30:27 -05002041 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002042}
2043
Vivien Didelot43145572017-03-11 16:12:59 -05002044static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002045 enum mv88e6xxx_frame_mode frame,
2046 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002047{
2048 int err;
2049
Vivien Didelot43145572017-03-11 16:12:59 -05002050 if (!chip->info->ops->port_set_frame_mode)
2051 return -EOPNOTSUPP;
2052
2053 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002054 if (err)
2055 return err;
2056
Vivien Didelot43145572017-03-11 16:12:59 -05002057 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2058 if (err)
2059 return err;
2060
2061 if (chip->info->ops->port_set_ether_type)
2062 return chip->info->ops->port_set_ether_type(chip, port, etype);
2063
2064 return 0;
2065}
2066
2067static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2068{
2069 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002070 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002071 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002072}
2073
2074static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2075{
2076 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002077 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002078 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002079}
2080
2081static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2082{
2083 return mv88e6xxx_set_port_mode(chip, port,
2084 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002085 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2086 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002087}
2088
2089static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2090{
2091 if (dsa_is_dsa_port(chip->ds, port))
2092 return mv88e6xxx_set_port_mode_dsa(chip, port);
2093
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002094 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002095 return mv88e6xxx_set_port_mode_normal(chip, port);
2096
2097 /* Setup CPU port mode depending on its supported tag format */
2098 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2099 return mv88e6xxx_set_port_mode_dsa(chip, port);
2100
2101 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2102 return mv88e6xxx_set_port_mode_edsa(chip, port);
2103
2104 return -EINVAL;
2105}
2106
Vivien Didelotea698f42017-03-11 16:12:50 -05002107static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2108{
2109 bool message = dsa_is_dsa_port(chip->ds, port);
2110
2111 return mv88e6xxx_port_set_message_port(chip, port, message);
2112}
2113
Vivien Didelot601aeed2017-03-11 16:13:00 -05002114static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2115{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002116 struct dsa_switch *ds = chip->ds;
2117 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002118
2119 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002120 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002121 if (chip->info->ops->port_set_egress_floods)
2122 return chip->info->ops->port_set_egress_floods(chip, port,
2123 flood, flood);
2124
2125 return 0;
2126}
2127
Andrew Lunn6d917822017-05-26 01:03:21 +02002128static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2129 bool on)
2130{
Vivien Didelot523a8902017-05-26 18:02:42 -04002131 if (chip->info->ops->serdes_power)
2132 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002133
Vivien Didelot523a8902017-05-26 18:02:42 -04002134 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002135}
2136
Vivien Didelotfa371c82017-12-05 15:34:10 -05002137static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2138{
2139 struct dsa_switch *ds = chip->ds;
2140 int upstream_port;
2141 int err;
2142
Vivien Didelot07073c72017-12-05 15:34:13 -05002143 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002144 if (chip->info->ops->port_set_upstream_port) {
2145 err = chip->info->ops->port_set_upstream_port(chip, port,
2146 upstream_port);
2147 if (err)
2148 return err;
2149 }
2150
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002151 if (port == upstream_port) {
2152 if (chip->info->ops->set_cpu_port) {
2153 err = chip->info->ops->set_cpu_port(chip,
2154 upstream_port);
2155 if (err)
2156 return err;
2157 }
2158
2159 if (chip->info->ops->set_egress_port) {
2160 err = chip->info->ops->set_egress_port(chip,
2161 upstream_port);
2162 if (err)
2163 return err;
2164 }
2165 }
2166
Vivien Didelotfa371c82017-12-05 15:34:10 -05002167 return 0;
2168}
2169
Vivien Didelotfad09c72016-06-21 12:28:20 -04002170static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002171{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002172 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002173 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002174 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002175
Andrew Lunn7b898462018-08-09 15:38:47 +02002176 chip->ports[port].chip = chip;
2177 chip->ports[port].port = port;
2178
Vivien Didelotd78343d2016-11-04 03:23:36 +01002179 /* MAC Forcing register: don't force link, speed, duplex or flow control
2180 * state to any particular values on physical ports, but force the CPU
2181 * port and all DSA ports to their maximum bandwidth and full duplex.
2182 */
2183 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2184 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2185 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002186 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002187 PHY_INTERFACE_MODE_NA);
2188 else
2189 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2190 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002191 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002192 PHY_INTERFACE_MODE_NA);
2193 if (err)
2194 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002195
2196 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2197 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2198 * tunneling, determine priority by looking at 802.1p and IP
2199 * priority fields (IP prio has precedence), and set STP state
2200 * to Forwarding.
2201 *
2202 * If this is the CPU link, use DSA or EDSA tagging depending
2203 * on which tagging mode was configured.
2204 *
2205 * If this is a link to another switch, use DSA tagging mode.
2206 *
2207 * If this is the upstream port for this switch, enable
2208 * forwarding of unknown unicasts and multicasts.
2209 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002210 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2211 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2212 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2213 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002214 if (err)
2215 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002216
Vivien Didelot601aeed2017-03-11 16:13:00 -05002217 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002218 if (err)
2219 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002220
Vivien Didelot601aeed2017-03-11 16:13:00 -05002221 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002222 if (err)
2223 return err;
2224
Andrew Lunn04aca992017-05-26 01:03:24 +02002225 /* Enable the SERDES interface for DSA and CPU ports. Normal
2226 * ports SERDES are enabled when the port is enabled, thus
2227 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002228 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002229 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2230 err = mv88e6xxx_serdes_power(chip, port, true);
2231 if (err)
2232 return err;
2233 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002234
Vivien Didelot8efdda42015-08-13 12:52:23 -04002235 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002236 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002237 * untagged frames on this port, do a destination address lookup on all
2238 * received packets as usual, disable ARP mirroring and don't send a
2239 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002240 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002241 err = mv88e6xxx_port_set_map_da(chip, port);
2242 if (err)
2243 return err;
2244
Vivien Didelotfa371c82017-12-05 15:34:10 -05002245 err = mv88e6xxx_setup_upstream_port(chip, port);
2246 if (err)
2247 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002248
Andrew Lunna23b2962017-02-04 20:15:28 +01002249 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002250 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002251 if (err)
2252 return err;
2253
Vivien Didelotcd782652017-06-08 18:34:13 -04002254 if (chip->info->ops->port_set_jumbo_size) {
2255 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002256 if (err)
2257 return err;
2258 }
2259
Andrew Lunn54d792f2015-05-06 01:09:47 +02002260 /* Port Association Vector: when learning source addresses
2261 * of packets, add the address to the address database using
2262 * a port bitmap that has only the bit for this port set and
2263 * the other bits clear.
2264 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002265 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002266 /* Disable learning for CPU port */
2267 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002268 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002269
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002270 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2271 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002272 if (err)
2273 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002274
2275 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002276 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2277 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002278 if (err)
2279 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002280
Vivien Didelot08984322017-06-08 18:34:12 -04002281 if (chip->info->ops->port_pause_limit) {
2282 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002283 if (err)
2284 return err;
2285 }
2286
Vivien Didelotc8c94892017-03-11 16:13:01 -05002287 if (chip->info->ops->port_disable_learn_limit) {
2288 err = chip->info->ops->port_disable_learn_limit(chip, port);
2289 if (err)
2290 return err;
2291 }
2292
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002293 if (chip->info->ops->port_disable_pri_override) {
2294 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002295 if (err)
2296 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002297 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002298
Andrew Lunnef0a7312016-12-03 04:35:16 +01002299 if (chip->info->ops->port_tag_remap) {
2300 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002301 if (err)
2302 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002303 }
2304
Andrew Lunnef70b112016-12-03 04:45:18 +01002305 if (chip->info->ops->port_egress_rate_limiting) {
2306 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002307 if (err)
2308 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002309 }
2310
Vivien Didelotea698f42017-03-11 16:12:50 -05002311 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002312 if (err)
2313 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002314
Vivien Didelot207afda2016-04-14 14:42:09 -04002315 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002316 * database, and allow bidirectional communication between the
2317 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002318 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002319 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002320 if (err)
2321 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002322
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002323 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002324 if (err)
2325 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002326
2327 /* Default VLAN ID and priority: don't set a default VLAN
2328 * ID, and set the default packet priority to zero.
2329 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002330 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002331}
2332
Andrew Lunn04aca992017-05-26 01:03:24 +02002333static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2334 struct phy_device *phydev)
2335{
2336 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002337 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002338
2339 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002340
Vivien Didelot523a8902017-05-26 18:02:42 -04002341 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002342
2343 if (!err && chip->info->ops->serdes_irq_setup)
2344 err = chip->info->ops->serdes_irq_setup(chip, port);
2345
Andrew Lunn04aca992017-05-26 01:03:24 +02002346 mutex_unlock(&chip->reg_lock);
2347
2348 return err;
2349}
2350
2351static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2352 struct phy_device *phydev)
2353{
2354 struct mv88e6xxx_chip *chip = ds->priv;
2355
2356 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002357
2358 if (chip->info->ops->serdes_irq_free)
2359 chip->info->ops->serdes_irq_free(chip, port);
2360
Vivien Didelot523a8902017-05-26 18:02:42 -04002361 if (mv88e6xxx_serdes_power(chip, port, false))
2362 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002363
Andrew Lunn04aca992017-05-26 01:03:24 +02002364 mutex_unlock(&chip->reg_lock);
2365}
2366
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002367static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2368 unsigned int ageing_time)
2369{
Vivien Didelot04bed142016-08-31 18:06:13 -04002370 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002371 int err;
2372
2373 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002374 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002375 mutex_unlock(&chip->reg_lock);
2376
2377 return err;
2378}
2379
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002380static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002381{
2382 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002383
Andrew Lunnde2273872016-11-21 23:27:01 +01002384 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002385 if (chip->info->ops->stats_set_histogram) {
2386 err = chip->info->ops->stats_set_histogram(chip);
2387 if (err)
2388 return err;
2389 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002390
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002391 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002392}
2393
Vivien Didelotf81ec902016-05-09 13:22:58 -04002394static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002395{
Vivien Didelot04bed142016-08-31 18:06:13 -04002396 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002397 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002398 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002399 int i;
2400
Vivien Didelotfad09c72016-06-21 12:28:20 -04002401 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002402 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002403
Vivien Didelotfad09c72016-06-21 12:28:20 -04002404 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002405
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002406 /* Cache the cmode of each port. */
2407 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2408 if (chip->info->ops->port_get_cmode) {
2409 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2410 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002411 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002412
2413 chip->ports[i].cmode = cmode;
2414 }
2415 }
2416
Vivien Didelot97299342016-07-18 20:45:30 -04002417 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002418 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002419 if (dsa_is_unused_port(ds, i))
2420 continue;
2421
Vivien Didelot97299342016-07-18 20:45:30 -04002422 err = mv88e6xxx_setup_port(chip, i);
2423 if (err)
2424 goto unlock;
2425 }
2426
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002427 err = mv88e6xxx_irl_setup(chip);
2428 if (err)
2429 goto unlock;
2430
Vivien Didelot04a69a12017-10-13 14:18:05 -04002431 err = mv88e6xxx_mac_setup(chip);
2432 if (err)
2433 goto unlock;
2434
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002435 err = mv88e6xxx_phy_setup(chip);
2436 if (err)
2437 goto unlock;
2438
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002439 err = mv88e6xxx_vtu_setup(chip);
2440 if (err)
2441 goto unlock;
2442
Vivien Didelot81228992017-03-30 17:37:08 -04002443 err = mv88e6xxx_pvt_setup(chip);
2444 if (err)
2445 goto unlock;
2446
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002447 err = mv88e6xxx_atu_setup(chip);
2448 if (err)
2449 goto unlock;
2450
Andrew Lunn87fa8862017-11-09 22:29:56 +01002451 err = mv88e6xxx_broadcast_setup(chip, 0);
2452 if (err)
2453 goto unlock;
2454
Vivien Didelot9e907d72017-07-17 13:03:43 -04002455 err = mv88e6xxx_pot_setup(chip);
2456 if (err)
2457 goto unlock;
2458
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002459 err = mv88e6xxx_rmu_setup(chip);
2460 if (err)
2461 goto unlock;
2462
Vivien Didelot51c901a2017-07-17 13:03:41 -04002463 err = mv88e6xxx_rsvd2cpu_setup(chip);
2464 if (err)
2465 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002466
Vivien Didelotb28f8722018-04-26 21:56:44 -04002467 err = mv88e6xxx_trunk_setup(chip);
2468 if (err)
2469 goto unlock;
2470
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002471 err = mv88e6xxx_devmap_setup(chip);
2472 if (err)
2473 goto unlock;
2474
Vivien Didelot93e18d62018-05-11 17:16:35 -04002475 err = mv88e6xxx_pri_setup(chip);
2476 if (err)
2477 goto unlock;
2478
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002479 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002480 if (chip->info->ptp_support) {
2481 err = mv88e6xxx_ptp_setup(chip);
2482 if (err)
2483 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002484
2485 err = mv88e6xxx_hwtstamp_setup(chip);
2486 if (err)
2487 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002488 }
2489
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002490 err = mv88e6xxx_stats_setup(chip);
2491 if (err)
2492 goto unlock;
2493
Vivien Didelot6b17e862015-08-13 12:52:18 -04002494unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002495 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002496
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002497 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002498}
2499
Vivien Didelote57e5e72016-08-15 17:19:00 -04002500static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002501{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002502 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2503 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002504 u16 val;
2505 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002506
Andrew Lunnee26a222017-01-24 14:53:48 +01002507 if (!chip->info->ops->phy_read)
2508 return -EOPNOTSUPP;
2509
Vivien Didelotfad09c72016-06-21 12:28:20 -04002510 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002511 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002512 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002513
Andrew Lunnda9f3302017-02-01 03:40:05 +01002514 if (reg == MII_PHYSID2) {
2515 /* Some internal PHYS don't have a model number. Use
2516 * the mv88e6390 family model number instead.
2517 */
2518 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002519 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002520 }
2521
Vivien Didelote57e5e72016-08-15 17:19:00 -04002522 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002523}
2524
Vivien Didelote57e5e72016-08-15 17:19:00 -04002525static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002526{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002527 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2528 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002529 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002530
Andrew Lunnee26a222017-01-24 14:53:48 +01002531 if (!chip->info->ops->phy_write)
2532 return -EOPNOTSUPP;
2533
Vivien Didelotfad09c72016-06-21 12:28:20 -04002534 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002535 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002536 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002537
2538 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002539}
2540
Vivien Didelotfad09c72016-06-21 12:28:20 -04002541static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002542 struct device_node *np,
2543 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002544{
2545 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002546 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002547 struct mii_bus *bus;
2548 int err;
2549
Andrew Lunn2510bab2018-02-22 01:51:49 +01002550 if (external) {
2551 mutex_lock(&chip->reg_lock);
2552 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2553 mutex_unlock(&chip->reg_lock);
2554
2555 if (err)
2556 return err;
2557 }
2558
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002559 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002560 if (!bus)
2561 return -ENOMEM;
2562
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002563 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002564 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002565 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002566 INIT_LIST_HEAD(&mdio_bus->list);
2567 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002568
Andrew Lunnb516d452016-06-04 21:17:06 +02002569 if (np) {
2570 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002571 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002572 } else {
2573 bus->name = "mv88e6xxx SMI";
2574 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2575 }
2576
2577 bus->read = mv88e6xxx_mdio_read;
2578 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002579 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002580
Andrew Lunn6f882842018-03-17 20:32:05 +01002581 if (!external) {
2582 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2583 if (err)
2584 return err;
2585 }
2586
Florian Fainelli00e798c2018-05-15 16:56:19 -07002587 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002588 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002589 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002590 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002591 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002592 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002593
2594 if (external)
2595 list_add_tail(&mdio_bus->list, &chip->mdios);
2596 else
2597 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002598
2599 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002600}
2601
Andrew Lunna3c53be52017-01-24 14:53:50 +01002602static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2603 { .compatible = "marvell,mv88e6xxx-mdio-external",
2604 .data = (void *)true },
2605 { },
2606};
2607
Andrew Lunn3126aee2017-12-07 01:05:57 +01002608static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2609
2610{
2611 struct mv88e6xxx_mdio_bus *mdio_bus;
2612 struct mii_bus *bus;
2613
2614 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2615 bus = mdio_bus->bus;
2616
Andrew Lunn6f882842018-03-17 20:32:05 +01002617 if (!mdio_bus->external)
2618 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2619
Andrew Lunn3126aee2017-12-07 01:05:57 +01002620 mdiobus_unregister(bus);
2621 }
2622}
2623
Andrew Lunna3c53be52017-01-24 14:53:50 +01002624static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2625 struct device_node *np)
2626{
2627 const struct of_device_id *match;
2628 struct device_node *child;
2629 int err;
2630
2631 /* Always register one mdio bus for the internal/default mdio
2632 * bus. This maybe represented in the device tree, but is
2633 * optional.
2634 */
2635 child = of_get_child_by_name(np, "mdio");
2636 err = mv88e6xxx_mdio_register(chip, child, false);
2637 if (err)
2638 return err;
2639
2640 /* Walk the device tree, and see if there are any other nodes
2641 * which say they are compatible with the external mdio
2642 * bus.
2643 */
2644 for_each_available_child_of_node(np, child) {
2645 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2646 if (match) {
2647 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002648 if (err) {
2649 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002650 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002651 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002652 }
2653 }
2654
2655 return 0;
2656}
2657
Vivien Didelot855b1932016-07-20 18:18:35 -04002658static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2659{
Vivien Didelot04bed142016-08-31 18:06:13 -04002660 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002661
2662 return chip->eeprom_len;
2663}
2664
Vivien Didelot855b1932016-07-20 18:18:35 -04002665static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2666 struct ethtool_eeprom *eeprom, u8 *data)
2667{
Vivien Didelot04bed142016-08-31 18:06:13 -04002668 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002669 int err;
2670
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002671 if (!chip->info->ops->get_eeprom)
2672 return -EOPNOTSUPP;
2673
Vivien Didelot855b1932016-07-20 18:18:35 -04002674 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002675 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002676 mutex_unlock(&chip->reg_lock);
2677
2678 if (err)
2679 return err;
2680
2681 eeprom->magic = 0xc3ec4951;
2682
2683 return 0;
2684}
2685
Vivien Didelot855b1932016-07-20 18:18:35 -04002686static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2687 struct ethtool_eeprom *eeprom, u8 *data)
2688{
Vivien Didelot04bed142016-08-31 18:06:13 -04002689 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002690 int err;
2691
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002692 if (!chip->info->ops->set_eeprom)
2693 return -EOPNOTSUPP;
2694
Vivien Didelot855b1932016-07-20 18:18:35 -04002695 if (eeprom->magic != 0xc3ec4951)
2696 return -EINVAL;
2697
2698 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002699 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002700 mutex_unlock(&chip->reg_lock);
2701
2702 return err;
2703}
2704
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002705static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002706 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002707 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2708 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002709 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002710 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002711 .phy_read = mv88e6185_phy_ppu_read,
2712 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002713 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002714 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002715 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002716 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002717 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002718 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002719 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002720 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002721 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002722 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002723 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002724 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002725 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002726 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002727 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002728 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2729 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002730 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002731 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2732 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002733 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002734 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002735 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002736 .ppu_enable = mv88e6185_g1_ppu_enable,
2737 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002738 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002739 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002740 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002741 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002742 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002743};
2744
2745static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002746 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002747 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2748 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002749 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002750 .phy_read = mv88e6185_phy_ppu_read,
2751 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002752 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002753 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002754 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002755 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002756 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002757 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002758 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002759 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002760 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002761 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002762 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2763 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002764 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002765 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002766 .ppu_enable = mv88e6185_g1_ppu_enable,
2767 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002768 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002769 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002770 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002771 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002772};
2773
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002774static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002775 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002776 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2777 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002778 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002779 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2780 .phy_read = mv88e6xxx_g2_smi_phy_read,
2781 .phy_write = mv88e6xxx_g2_smi_phy_write,
2782 .port_set_link = mv88e6xxx_port_set_link,
2783 .port_set_duplex = mv88e6xxx_port_set_duplex,
2784 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002785 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002786 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002787 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002788 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002789 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002790 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002791 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002792 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002793 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002794 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002795 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002796 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002797 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002798 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2799 .stats_get_strings = mv88e6095_stats_get_strings,
2800 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002801 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2802 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002803 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002804 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002805 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002806 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002807 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002808 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002809 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002810 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002811};
2812
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002813static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002814 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002815 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2816 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002817 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002818 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002819 .phy_read = mv88e6xxx_g2_smi_phy_read,
2820 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002821 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002822 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002823 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002824 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002825 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002826 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002827 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002828 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002829 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002830 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002831 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002832 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2833 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002834 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002835 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2836 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002837 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002838 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002839 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002840 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002841 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002842 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002843 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002844};
2845
2846static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002847 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002848 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2849 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002850 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002851 .phy_read = mv88e6185_phy_ppu_read,
2852 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002853 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002854 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002855 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002856 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002857 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002858 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002859 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002860 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002861 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002862 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002863 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002864 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002865 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002866 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002867 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002868 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002869 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2870 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002871 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002872 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2873 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002874 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002875 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002876 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002877 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002878 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002879 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002880 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002881 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002882 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002883};
2884
Vivien Didelot990e27b2017-03-28 13:50:32 -04002885static const struct mv88e6xxx_ops mv88e6141_ops = {
2886 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002887 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2888 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002889 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002890 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2891 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2892 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2893 .phy_read = mv88e6xxx_g2_smi_phy_read,
2894 .phy_write = mv88e6xxx_g2_smi_phy_write,
2895 .port_set_link = mv88e6xxx_port_set_link,
2896 .port_set_duplex = mv88e6xxx_port_set_duplex,
2897 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
2898 .port_set_speed = mv88e6390_port_set_speed,
2899 .port_tag_remap = mv88e6095_port_tag_remap,
2900 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2901 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2902 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002903 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002904 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002905 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002906 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2907 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002908 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002909 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002910 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002911 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002912 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2913 .stats_get_strings = mv88e6320_stats_get_strings,
2914 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002915 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2916 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002917 .watchdog_ops = &mv88e6390_watchdog_ops,
2918 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002919 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002920 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002921 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002922 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002923 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002924 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02002925 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002926};
2927
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002928static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002929 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002930 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2931 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002932 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002933 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002934 .phy_read = mv88e6xxx_g2_smi_phy_read,
2935 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002936 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002937 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002938 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002939 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002940 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002941 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002942 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002943 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002944 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002945 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002946 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002947 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002948 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002949 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002950 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002951 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002952 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2953 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002954 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002955 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2956 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002957 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002958 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002959 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002960 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002961 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002962 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002963 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002964 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002965 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002966};
2967
2968static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002969 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002970 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2971 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002972 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002973 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002974 .phy_read = mv88e6165_phy_read,
2975 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002976 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002977 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002978 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002979 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002980 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002981 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002982 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002983 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002984 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002985 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2986 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002987 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002988 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2989 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002990 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002991 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002992 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002993 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002994 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002995 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002996 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002997 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002998 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002999};
3000
3001static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003002 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003003 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3004 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003005 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003006 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003007 .phy_read = mv88e6xxx_g2_smi_phy_read,
3008 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003009 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003010 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003011 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003012 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003013 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003014 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003015 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003016 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003017 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003018 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003019 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003020 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003021 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003022 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003023 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003024 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003025 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003026 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3027 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003028 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003029 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3030 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003031 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003032 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003033 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003034 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003035 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003036 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003037 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003038};
3039
3040static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003041 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003042 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3043 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003044 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003045 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3046 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003047 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003048 .phy_read = mv88e6xxx_g2_smi_phy_read,
3049 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003050 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003051 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003052 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003053 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003054 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003055 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003056 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003057 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003058 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003059 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003060 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003061 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003062 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003063 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003064 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003065 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003066 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003067 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3068 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003069 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003070 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3071 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003072 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003073 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003074 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003075 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003076 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003077 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003078 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003079 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003080 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003081 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003082};
3083
3084static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003085 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003086 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3087 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003088 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003089 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003090 .phy_read = mv88e6xxx_g2_smi_phy_read,
3091 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003092 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003093 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003094 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003095 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003096 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003097 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003098 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003099 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003100 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003101 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003102 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003103 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003104 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003105 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003106 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003107 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003108 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003109 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3110 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003111 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003112 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3113 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003114 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003115 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003116 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003117 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003118 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003119 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003120 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003121};
3122
3123static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003124 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003125 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3126 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003127 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003128 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3129 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003130 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003131 .phy_read = mv88e6xxx_g2_smi_phy_read,
3132 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003133 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003134 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003135 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003136 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003137 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003138 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003139 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003140 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003141 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003142 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003143 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003144 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003145 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003146 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003147 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003148 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003149 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003150 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3151 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003152 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003153 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3154 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003155 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003156 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003157 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003158 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003159 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003160 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003161 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003162 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003163 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003164 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003165};
3166
3167static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003168 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003169 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3170 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003171 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003172 .phy_read = mv88e6185_phy_ppu_read,
3173 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003174 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003175 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003176 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003177 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003178 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003179 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003180 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003181 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003182 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003183 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003184 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003185 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003186 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3187 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003188 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003189 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3190 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003191 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003192 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003193 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003194 .ppu_enable = mv88e6185_g1_ppu_enable,
3195 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003196 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003197 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003198 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003199 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003200};
3201
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003202static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003203 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003204 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003205 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3206 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003207 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3208 .phy_read = mv88e6xxx_g2_smi_phy_read,
3209 .phy_write = mv88e6xxx_g2_smi_phy_write,
3210 .port_set_link = mv88e6xxx_port_set_link,
3211 .port_set_duplex = mv88e6xxx_port_set_duplex,
3212 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3213 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003214 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003215 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003216 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003217 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003218 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003219 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003220 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003221 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003222 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003223 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003224 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003225 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3226 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003227 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003228 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3229 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003230 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003231 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003232 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003233 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003234 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003235 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3236 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003237 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003238 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3239 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003240 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003241 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003242};
3243
3244static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003245 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003246 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003247 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3248 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003249 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3250 .phy_read = mv88e6xxx_g2_smi_phy_read,
3251 .phy_write = mv88e6xxx_g2_smi_phy_write,
3252 .port_set_link = mv88e6xxx_port_set_link,
3253 .port_set_duplex = mv88e6xxx_port_set_duplex,
3254 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3255 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003256 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003257 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003258 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003259 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003260 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003261 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003262 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003263 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003264 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003265 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003266 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003267 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3268 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003269 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003270 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3271 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003272 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003273 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003274 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003275 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003276 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003277 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3278 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003279 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003280 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3281 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003282 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003283 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003284};
3285
3286static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003287 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003288 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003289 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3290 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003291 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3292 .phy_read = mv88e6xxx_g2_smi_phy_read,
3293 .phy_write = mv88e6xxx_g2_smi_phy_write,
3294 .port_set_link = mv88e6xxx_port_set_link,
3295 .port_set_duplex = mv88e6xxx_port_set_duplex,
3296 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3297 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003298 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003299 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003300 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003301 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003302 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003303 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003304 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003305 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003306 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003307 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003308 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003309 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3310 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003311 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003312 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3313 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003314 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003315 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003316 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003317 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003318 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003319 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3320 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003321 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003322 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3323 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003324 .avb_ops = &mv88e6390_avb_ops,
3325 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003326 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003327};
3328
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003329static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003330 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003331 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3332 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003333 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003334 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3335 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003336 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003337 .phy_read = mv88e6xxx_g2_smi_phy_read,
3338 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003339 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003340 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003341 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003342 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003343 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003344 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003345 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003346 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003347 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003348 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003349 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003350 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003351 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003352 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003353 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003354 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003355 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003356 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3357 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003358 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003359 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3360 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003361 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003362 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003363 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003364 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003365 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003366 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003367 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003368 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003369 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003370 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003371 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003372 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003373};
3374
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003375static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003376 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003377 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003378 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3379 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003380 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3381 .phy_read = mv88e6xxx_g2_smi_phy_read,
3382 .phy_write = mv88e6xxx_g2_smi_phy_write,
3383 .port_set_link = mv88e6xxx_port_set_link,
3384 .port_set_duplex = mv88e6xxx_port_set_duplex,
3385 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3386 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003387 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003388 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003389 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003390 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003391 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003392 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003393 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003394 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003395 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003396 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003397 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003398 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003399 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3400 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003401 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003402 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3403 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003404 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003405 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003406 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003407 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003408 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003409 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3410 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003411 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003412 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3413 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003414 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003415 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003416 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003417 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003418};
3419
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003420static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003421 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003422 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3423 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003424 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003425 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3426 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003427 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003428 .phy_read = mv88e6xxx_g2_smi_phy_read,
3429 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003430 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003431 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003432 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003433 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003434 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003435 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003436 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003437 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003438 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003439 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003440 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003441 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003442 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003443 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003444 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003445 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003446 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3447 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003448 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003449 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3450 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003451 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003452 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003453 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003454 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003455 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003456 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003457 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003458 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003459 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003460};
3461
3462static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003463 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003464 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3465 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003466 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003467 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3468 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003469 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003470 .phy_read = mv88e6xxx_g2_smi_phy_read,
3471 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003472 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003473 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003474 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003475 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003476 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003477 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003478 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003479 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003480 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003481 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003482 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003483 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003484 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003485 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003486 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003487 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003488 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3489 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003490 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003491 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3492 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003493 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003494 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003495 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003496 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003497 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003498 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003499 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003500};
3501
Vivien Didelot16e329a2017-03-28 13:50:33 -04003502static const struct mv88e6xxx_ops mv88e6341_ops = {
3503 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003504 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3505 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003506 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003507 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3508 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3509 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3510 .phy_read = mv88e6xxx_g2_smi_phy_read,
3511 .phy_write = mv88e6xxx_g2_smi_phy_write,
3512 .port_set_link = mv88e6xxx_port_set_link,
3513 .port_set_duplex = mv88e6xxx_port_set_duplex,
3514 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3515 .port_set_speed = mv88e6390_port_set_speed,
3516 .port_tag_remap = mv88e6095_port_tag_remap,
3517 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3518 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3519 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003520 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003521 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003522 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003523 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3524 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003525 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003526 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003527 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003528 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003529 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3530 .stats_get_strings = mv88e6320_stats_get_strings,
3531 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003532 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3533 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003534 .watchdog_ops = &mv88e6390_watchdog_ops,
3535 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003536 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003537 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003538 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003539 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003540 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003541 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003542 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003543 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003544 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003545};
3546
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003547static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003548 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003549 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3550 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003551 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003552 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003553 .phy_read = mv88e6xxx_g2_smi_phy_read,
3554 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003555 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003556 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003557 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003558 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003559 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003560 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003561 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003562 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003563 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003564 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003565 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003566 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003567 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003568 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003569 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003570 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003571 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003572 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3573 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003574 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003575 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3576 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003577 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003578 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003579 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003580 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003581 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003582 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003583 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003584};
3585
3586static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003587 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003588 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3589 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003590 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003591 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003592 .phy_read = mv88e6xxx_g2_smi_phy_read,
3593 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003594 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003595 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003596 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003597 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003598 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003599 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003600 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003601 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003602 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003603 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003604 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003605 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003606 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003607 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003608 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003609 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003610 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003611 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3612 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003613 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003614 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3615 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003616 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003617 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003618 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003619 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003620 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003621 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003622 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003623 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003624 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003625};
3626
3627static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003628 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003629 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3630 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003631 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003632 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3633 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003634 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003635 .phy_read = mv88e6xxx_g2_smi_phy_read,
3636 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003637 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003638 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003639 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003640 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003641 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003642 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003643 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003644 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003645 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003646 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003647 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003648 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003649 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003650 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003651 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003652 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003653 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003654 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3655 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003656 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003657 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3658 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003659 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003660 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003661 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003662 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003663 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003664 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003665 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003666 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003667 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003668 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003669 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003670 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3671 .serdes_get_strings = mv88e6352_serdes_get_strings,
3672 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003673 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003674};
3675
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003676static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003677 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003678 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003679 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3680 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003681 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3682 .phy_read = mv88e6xxx_g2_smi_phy_read,
3683 .phy_write = mv88e6xxx_g2_smi_phy_write,
3684 .port_set_link = mv88e6xxx_port_set_link,
3685 .port_set_duplex = mv88e6xxx_port_set_duplex,
3686 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3687 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003688 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003689 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003690 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003691 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003692 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003693 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003694 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003695 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003696 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003697 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003698 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003699 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003700 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003701 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003702 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3703 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003704 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003705 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3706 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003707 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003708 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003709 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003710 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003711 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003712 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3713 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003714 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003715 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3716 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003717 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003718 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003719 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003720 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003721};
3722
3723static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003724 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003725 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003726 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3727 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003728 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3729 .phy_read = mv88e6xxx_g2_smi_phy_read,
3730 .phy_write = mv88e6xxx_g2_smi_phy_write,
3731 .port_set_link = mv88e6xxx_port_set_link,
3732 .port_set_duplex = mv88e6xxx_port_set_duplex,
3733 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3734 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003735 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003736 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003737 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003738 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003739 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003740 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003741 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003742 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003743 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003744 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003745 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003746 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003747 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003748 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003749 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3750 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003751 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003752 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3753 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003754 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003755 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003756 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003757 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003758 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003759 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3760 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003761 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003762 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3763 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003764 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003765 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003766 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003767 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003768};
3769
Vivien Didelotf81ec902016-05-09 13:22:58 -04003770static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3771 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003772 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003773 .family = MV88E6XXX_FAMILY_6097,
3774 .name = "Marvell 88E6085",
3775 .num_databases = 4096,
3776 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003777 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003778 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003779 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003780 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003781 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003782 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003783 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003784 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003785 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003786 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003787 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003788 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003789 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003790 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003791 },
3792
3793 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003794 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003795 .family = MV88E6XXX_FAMILY_6095,
3796 .name = "Marvell 88E6095/88E6095F",
3797 .num_databases = 256,
3798 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003799 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003800 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003801 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003802 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003803 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003804 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003805 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003806 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003807 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003808 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003809 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003810 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003811 },
3812
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003813 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003814 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003815 .family = MV88E6XXX_FAMILY_6097,
3816 .name = "Marvell 88E6097/88E6097F",
3817 .num_databases = 4096,
3818 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003819 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003820 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003821 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003822 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003823 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003824 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003825 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003826 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003827 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003828 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003829 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003830 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003831 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003832 .ops = &mv88e6097_ops,
3833 },
3834
Vivien Didelotf81ec902016-05-09 13:22:58 -04003835 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003836 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003837 .family = MV88E6XXX_FAMILY_6165,
3838 .name = "Marvell 88E6123",
3839 .num_databases = 4096,
3840 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003841 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003842 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003843 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003844 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003845 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003846 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003847 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003848 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003849 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003850 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003851 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003852 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003853 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003854 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003855 },
3856
3857 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003858 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003859 .family = MV88E6XXX_FAMILY_6185,
3860 .name = "Marvell 88E6131",
3861 .num_databases = 256,
3862 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003863 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003864 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003865 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003866 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003867 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003868 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003869 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003870 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003871 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003872 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003873 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003874 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003875 },
3876
Vivien Didelot990e27b2017-03-28 13:50:32 -04003877 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003878 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003879 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003880 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003881 .num_databases = 4096,
3882 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003883 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003884 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003885 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003886 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003887 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003888 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003889 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003890 .age_time_coeff = 3750,
3891 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003892 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003893 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003894 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003895 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003896 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003897 .ops = &mv88e6141_ops,
3898 },
3899
Vivien Didelotf81ec902016-05-09 13:22:58 -04003900 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003901 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003902 .family = MV88E6XXX_FAMILY_6165,
3903 .name = "Marvell 88E6161",
3904 .num_databases = 4096,
3905 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003906 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003907 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003908 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003909 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003910 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003911 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003912 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003913 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003914 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003915 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003916 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003917 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003918 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003919 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003920 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003921 },
3922
3923 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003924 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003925 .family = MV88E6XXX_FAMILY_6165,
3926 .name = "Marvell 88E6165",
3927 .num_databases = 4096,
3928 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003929 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003930 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003931 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003932 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003933 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003934 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003935 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003936 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003937 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003938 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003939 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003940 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003941 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003942 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003943 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003944 },
3945
3946 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003947 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003948 .family = MV88E6XXX_FAMILY_6351,
3949 .name = "Marvell 88E6171",
3950 .num_databases = 4096,
3951 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003952 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003953 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003954 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003955 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003956 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003957 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003958 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003959 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003960 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003961 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003962 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003963 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003964 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003965 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003966 },
3967
3968 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003969 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003970 .family = MV88E6XXX_FAMILY_6352,
3971 .name = "Marvell 88E6172",
3972 .num_databases = 4096,
3973 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003974 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003975 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003976 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003977 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003978 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003979 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003980 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003981 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003982 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003983 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003984 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003985 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003986 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003987 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003988 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003989 },
3990
3991 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003992 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003993 .family = MV88E6XXX_FAMILY_6351,
3994 .name = "Marvell 88E6175",
3995 .num_databases = 4096,
3996 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003997 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003998 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003999 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004000 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004001 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004002 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004003 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004004 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004005 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004006 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004007 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004008 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004009 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004010 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004011 },
4012
4013 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004014 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004015 .family = MV88E6XXX_FAMILY_6352,
4016 .name = "Marvell 88E6176",
4017 .num_databases = 4096,
4018 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004019 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004020 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004021 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004022 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004023 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004024 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004025 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004026 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004027 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004028 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004029 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004030 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004031 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004032 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004033 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004034 },
4035
4036 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004037 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004038 .family = MV88E6XXX_FAMILY_6185,
4039 .name = "Marvell 88E6185",
4040 .num_databases = 256,
4041 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004042 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004043 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004044 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004045 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004046 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004047 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004048 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004049 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004050 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004051 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004052 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004053 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004054 },
4055
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004056 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004057 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004058 .family = MV88E6XXX_FAMILY_6390,
4059 .name = "Marvell 88E6190",
4060 .num_databases = 4096,
4061 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004062 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004063 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004064 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004065 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004066 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004067 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004068 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004069 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004070 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004071 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004072 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004073 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004074 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004075 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004076 .ops = &mv88e6190_ops,
4077 },
4078
4079 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004080 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004081 .family = MV88E6XXX_FAMILY_6390,
4082 .name = "Marvell 88E6190X",
4083 .num_databases = 4096,
4084 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004085 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004086 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004087 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004088 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004089 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004090 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004091 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004092 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004093 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004094 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004095 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004096 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004097 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004098 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004099 .ops = &mv88e6190x_ops,
4100 },
4101
4102 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004103 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004104 .family = MV88E6XXX_FAMILY_6390,
4105 .name = "Marvell 88E6191",
4106 .num_databases = 4096,
4107 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004108 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004109 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004110 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004111 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004112 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004113 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004114 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004115 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004116 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004117 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004118 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004119 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004120 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004121 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004122 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004123 },
4124
Vivien Didelotf81ec902016-05-09 13:22:58 -04004125 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004126 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004127 .family = MV88E6XXX_FAMILY_6352,
4128 .name = "Marvell 88E6240",
4129 .num_databases = 4096,
4130 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004131 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004132 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004133 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004134 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004135 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004136 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004137 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004138 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004139 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004140 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004141 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004142 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004143 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004144 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004145 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004146 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004147 },
4148
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004149 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004150 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004151 .family = MV88E6XXX_FAMILY_6390,
4152 .name = "Marvell 88E6290",
4153 .num_databases = 4096,
4154 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004155 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004156 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004157 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004158 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004159 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004160 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004161 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004162 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004163 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004164 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004165 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004166 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004167 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004168 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004169 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004170 .ops = &mv88e6290_ops,
4171 },
4172
Vivien Didelotf81ec902016-05-09 13:22:58 -04004173 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004174 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004175 .family = MV88E6XXX_FAMILY_6320,
4176 .name = "Marvell 88E6320",
4177 .num_databases = 4096,
4178 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004179 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004180 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004181 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004182 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004183 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004184 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004185 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004186 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004187 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004188 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004189 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004190 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004191 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004192 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004193 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004194 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004195 },
4196
4197 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004198 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004199 .family = MV88E6XXX_FAMILY_6320,
4200 .name = "Marvell 88E6321",
4201 .num_databases = 4096,
4202 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004203 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004204 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004205 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004206 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004207 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004208 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004209 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004210 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004211 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004212 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004213 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004214 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004215 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004216 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004217 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004218 },
4219
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004220 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004221 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004222 .family = MV88E6XXX_FAMILY_6341,
4223 .name = "Marvell 88E6341",
4224 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004225 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004226 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004227 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004228 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004229 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004230 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004231 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004232 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004233 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004234 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004235 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004236 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004237 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004238 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004239 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004240 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004241 .ops = &mv88e6341_ops,
4242 },
4243
Vivien Didelotf81ec902016-05-09 13:22:58 -04004244 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004245 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004246 .family = MV88E6XXX_FAMILY_6351,
4247 .name = "Marvell 88E6350",
4248 .num_databases = 4096,
4249 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004250 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004251 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004252 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004253 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004254 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004255 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004256 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004257 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004258 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004259 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004260 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004261 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004262 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004263 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004264 },
4265
4266 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004267 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004268 .family = MV88E6XXX_FAMILY_6351,
4269 .name = "Marvell 88E6351",
4270 .num_databases = 4096,
4271 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004272 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004273 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004274 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004275 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004276 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004277 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004278 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004279 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004280 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004281 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004282 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004283 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004284 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004285 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004286 },
4287
4288 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004289 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004290 .family = MV88E6XXX_FAMILY_6352,
4291 .name = "Marvell 88E6352",
4292 .num_databases = 4096,
4293 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004294 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004295 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004296 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004297 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004298 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004299 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004300 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004301 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004302 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004303 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004304 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004305 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004306 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004307 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004308 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004309 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004310 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004311 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004312 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004313 .family = MV88E6XXX_FAMILY_6390,
4314 .name = "Marvell 88E6390",
4315 .num_databases = 4096,
4316 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004317 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004318 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004319 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004320 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004321 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004322 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004323 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004324 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004325 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004326 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004327 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004328 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004329 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004330 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004331 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004332 .ops = &mv88e6390_ops,
4333 },
4334 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004335 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004336 .family = MV88E6XXX_FAMILY_6390,
4337 .name = "Marvell 88E6390X",
4338 .num_databases = 4096,
4339 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004340 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004341 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004342 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004343 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004344 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004345 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004346 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004347 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004348 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004349 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004350 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004351 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004352 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004353 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004354 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004355 .ops = &mv88e6390x_ops,
4356 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004357};
4358
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004359static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004360{
Vivien Didelota439c062016-04-17 13:23:58 -04004361 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004362
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004363 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4364 if (mv88e6xxx_table[i].prod_num == prod_num)
4365 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004366
Vivien Didelotb9b37712015-10-30 19:39:48 -04004367 return NULL;
4368}
4369
Vivien Didelotfad09c72016-06-21 12:28:20 -04004370static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004371{
4372 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004373 unsigned int prod_num, rev;
4374 u16 id;
4375 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004376
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004377 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004378 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004379 mutex_unlock(&chip->reg_lock);
4380 if (err)
4381 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004382
Vivien Didelot107fcc12017-06-12 12:37:36 -04004383 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4384 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004385
4386 info = mv88e6xxx_lookup_info(prod_num);
4387 if (!info)
4388 return -ENODEV;
4389
Vivien Didelotcaac8542016-06-20 13:14:09 -04004390 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004391 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004392
Vivien Didelotca070c12016-09-02 14:45:34 -04004393 err = mv88e6xxx_g2_require(chip);
4394 if (err)
4395 return err;
4396
Vivien Didelotfad09c72016-06-21 12:28:20 -04004397 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4398 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004399
4400 return 0;
4401}
4402
Vivien Didelotfad09c72016-06-21 12:28:20 -04004403static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004404{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004405 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004406
Vivien Didelotfad09c72016-06-21 12:28:20 -04004407 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4408 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004409 return NULL;
4410
Vivien Didelotfad09c72016-06-21 12:28:20 -04004411 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004412
Vivien Didelotfad09c72016-06-21 12:28:20 -04004413 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004414 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004415
Vivien Didelotfad09c72016-06-21 12:28:20 -04004416 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004417}
4418
Vivien Didelotfad09c72016-06-21 12:28:20 -04004419static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004420 struct mii_bus *bus, int sw_addr)
4421{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004422 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004423 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004424 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004425 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004426 else
4427 return -EINVAL;
4428
Vivien Didelotfad09c72016-06-21 12:28:20 -04004429 chip->bus = bus;
4430 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004431
4432 return 0;
4433}
4434
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004435static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4436 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004437{
Vivien Didelot04bed142016-08-31 18:06:13 -04004438 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004439
Andrew Lunn443d5a12016-12-03 04:35:18 +01004440 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004441}
4442
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004443#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004444static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4445 struct device *host_dev, int sw_addr,
4446 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004447{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004448 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004449 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004450 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004451
Vivien Didelota439c062016-04-17 13:23:58 -04004452 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004453 if (!bus)
4454 return NULL;
4455
Vivien Didelotfad09c72016-06-21 12:28:20 -04004456 chip = mv88e6xxx_alloc_chip(dsa_dev);
4457 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004458 return NULL;
4459
Vivien Didelotcaac8542016-06-20 13:14:09 -04004460 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004461 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004462
Vivien Didelotfad09c72016-06-21 12:28:20 -04004463 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004464 if (err)
4465 goto free;
4466
Vivien Didelotfad09c72016-06-21 12:28:20 -04004467 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004468 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004469 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004470
Andrew Lunndc30c352016-10-16 19:56:49 +02004471 mutex_lock(&chip->reg_lock);
4472 err = mv88e6xxx_switch_reset(chip);
4473 mutex_unlock(&chip->reg_lock);
4474 if (err)
4475 goto free;
4476
Vivien Didelote57e5e72016-08-15 17:19:00 -04004477 mv88e6xxx_phy_init(chip);
4478
Andrew Lunna3c53be52017-01-24 14:53:50 +01004479 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004480 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004481 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004482
Vivien Didelotfad09c72016-06-21 12:28:20 -04004483 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004484
Vivien Didelotfad09c72016-06-21 12:28:20 -04004485 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004486free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004487 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004488
4489 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004490}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004491#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004492
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004493static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004494 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004495{
4496 /* We don't need any dynamic resource from the kernel (yet),
4497 * so skip the prepare phase.
4498 */
4499
4500 return 0;
4501}
4502
4503static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004504 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004505{
Vivien Didelot04bed142016-08-31 18:06:13 -04004506 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004507
4508 mutex_lock(&chip->reg_lock);
4509 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004510 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004511 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4512 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004513 mutex_unlock(&chip->reg_lock);
4514}
4515
4516static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4517 const struct switchdev_obj_port_mdb *mdb)
4518{
Vivien Didelot04bed142016-08-31 18:06:13 -04004519 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004520 int err;
4521
4522 mutex_lock(&chip->reg_lock);
4523 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004524 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004525 mutex_unlock(&chip->reg_lock);
4526
4527 return err;
4528}
4529
Florian Fainellia82f67a2017-01-08 14:52:08 -08004530static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004531#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004532 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004533#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004534 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004535 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004536 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004537 .phylink_validate = mv88e6xxx_validate,
4538 .phylink_mac_link_state = mv88e6xxx_link_state,
4539 .phylink_mac_config = mv88e6xxx_mac_config,
4540 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4541 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004542 .get_strings = mv88e6xxx_get_strings,
4543 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4544 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004545 .port_enable = mv88e6xxx_port_enable,
4546 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004547 .get_mac_eee = mv88e6xxx_get_mac_eee,
4548 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004549 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004550 .get_eeprom = mv88e6xxx_get_eeprom,
4551 .set_eeprom = mv88e6xxx_set_eeprom,
4552 .get_regs_len = mv88e6xxx_get_regs_len,
4553 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004554 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004555 .port_bridge_join = mv88e6xxx_port_bridge_join,
4556 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4557 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004558 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004559 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4560 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4561 .port_vlan_add = mv88e6xxx_port_vlan_add,
4562 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004563 .port_fdb_add = mv88e6xxx_port_fdb_add,
4564 .port_fdb_del = mv88e6xxx_port_fdb_del,
4565 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004566 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4567 .port_mdb_add = mv88e6xxx_port_mdb_add,
4568 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004569 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4570 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004571 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4572 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4573 .port_txtstamp = mv88e6xxx_port_txtstamp,
4574 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4575 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004576};
4577
Florian Fainelliab3d4082017-01-08 14:52:07 -08004578static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4579 .ops = &mv88e6xxx_switch_ops,
4580};
4581
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004582static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004583{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004584 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004585 struct dsa_switch *ds;
4586
Vivien Didelot73b12042017-03-30 17:37:10 -04004587 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004588 if (!ds)
4589 return -ENOMEM;
4590
Vivien Didelotfad09c72016-06-21 12:28:20 -04004591 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004592 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004593 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004594 ds->ageing_time_min = chip->info->age_time_coeff;
4595 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004596
4597 dev_set_drvdata(dev, ds);
4598
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004599 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004600}
4601
Vivien Didelotfad09c72016-06-21 12:28:20 -04004602static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004603{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004604 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004605}
4606
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004607static const void *pdata_device_get_match_data(struct device *dev)
4608{
4609 const struct of_device_id *matches = dev->driver->of_match_table;
4610 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4611
4612 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4613 matches++) {
4614 if (!strcmp(pdata->compatible, matches->compatible))
4615 return matches->data;
4616 }
4617 return NULL;
4618}
4619
Vivien Didelot57d32312016-06-20 13:13:58 -04004620static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004621{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004622 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004623 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004624 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004625 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004626 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004627 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004628 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004629
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004630 if (!np && !pdata)
4631 return -EINVAL;
4632
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004633 if (np)
4634 compat_info = of_device_get_match_data(dev);
4635
4636 if (pdata) {
4637 compat_info = pdata_device_get_match_data(dev);
4638
4639 if (!pdata->netdev)
4640 return -EINVAL;
4641
4642 for (port = 0; port < DSA_MAX_PORTS; port++) {
4643 if (!(pdata->enabled_ports & (1 << port)))
4644 continue;
4645 if (strcmp(pdata->cd.port_names[port], "cpu"))
4646 continue;
4647 pdata->cd.netdev[port] = &pdata->netdev->dev;
4648 break;
4649 }
4650 }
4651
Vivien Didelotcaac8542016-06-20 13:14:09 -04004652 if (!compat_info)
4653 return -EINVAL;
4654
Vivien Didelotfad09c72016-06-21 12:28:20 -04004655 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004656 if (!chip) {
4657 err = -ENOMEM;
4658 goto out;
4659 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004660
Vivien Didelotfad09c72016-06-21 12:28:20 -04004661 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004662
Vivien Didelotfad09c72016-06-21 12:28:20 -04004663 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004664 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004665 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004666
Andrew Lunnb4308f02016-11-21 23:26:55 +01004667 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004668 if (IS_ERR(chip->reset)) {
4669 err = PTR_ERR(chip->reset);
4670 goto out;
4671 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004672
Vivien Didelotfad09c72016-06-21 12:28:20 -04004673 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004674 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004675 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004676
Vivien Didelote57e5e72016-08-15 17:19:00 -04004677 mv88e6xxx_phy_init(chip);
4678
Andrew Lunn00baabe2018-05-19 22:31:35 +02004679 if (chip->info->ops->get_eeprom) {
4680 if (np)
4681 of_property_read_u32(np, "eeprom-length",
4682 &chip->eeprom_len);
4683 else
4684 chip->eeprom_len = pdata->eeprom_len;
4685 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004686
Andrew Lunndc30c352016-10-16 19:56:49 +02004687 mutex_lock(&chip->reg_lock);
4688 err = mv88e6xxx_switch_reset(chip);
4689 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004690 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004691 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004692
Andrew Lunndc30c352016-10-16 19:56:49 +02004693 chip->irq = of_irq_get(np, 0);
4694 if (chip->irq == -EPROBE_DEFER) {
4695 err = chip->irq;
4696 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004697 }
4698
Andrew Lunn294d7112018-02-22 22:58:32 +01004699 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004700 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004701 * controllers
4702 */
4703 mutex_lock(&chip->reg_lock);
4704 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004705 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004706 else
4707 err = mv88e6xxx_irq_poll_setup(chip);
4708 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004709
Andrew Lunn294d7112018-02-22 22:58:32 +01004710 if (err)
4711 goto out;
4712
4713 if (chip->info->g2_irqs > 0) {
4714 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004715 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004716 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004717 }
4718
Andrew Lunn294d7112018-02-22 22:58:32 +01004719 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4720 if (err)
4721 goto out_g2_irq;
4722
4723 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4724 if (err)
4725 goto out_g1_atu_prob_irq;
4726
Andrew Lunna3c53be52017-01-24 14:53:50 +01004727 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004728 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004729 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004730
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004731 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004732 if (err)
4733 goto out_mdio;
4734
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004735 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004736
4737out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004738 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004739out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004740 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004741out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004742 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004743out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004744 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004745 mv88e6xxx_g2_irq_free(chip);
4746out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004747 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004748 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004749 else
4750 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004751out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004752 if (pdata)
4753 dev_put(pdata->netdev);
4754
Andrew Lunndc30c352016-10-16 19:56:49 +02004755 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004756}
4757
4758static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4759{
4760 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004761 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004762
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004763 if (chip->info->ptp_support) {
4764 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004765 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004766 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004767
Andrew Lunn930188c2016-08-22 16:01:03 +02004768 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004769 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004770 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004771
Andrew Lunn76f38f12018-03-17 20:21:09 +01004772 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4773 mv88e6xxx_g1_atu_prob_irq_free(chip);
4774
4775 if (chip->info->g2_irqs > 0)
4776 mv88e6xxx_g2_irq_free(chip);
4777
Andrew Lunn76f38f12018-03-17 20:21:09 +01004778 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004779 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004780 else
4781 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004782}
4783
4784static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004785 {
4786 .compatible = "marvell,mv88e6085",
4787 .data = &mv88e6xxx_table[MV88E6085],
4788 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004789 {
4790 .compatible = "marvell,mv88e6190",
4791 .data = &mv88e6xxx_table[MV88E6190],
4792 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004793 { /* sentinel */ },
4794};
4795
4796MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4797
4798static struct mdio_driver mv88e6xxx_driver = {
4799 .probe = mv88e6xxx_probe,
4800 .remove = mv88e6xxx_remove,
4801 .mdiodrv.driver = {
4802 .name = "mv88e6085",
4803 .of_match_table = mv88e6xxx_of_match,
4804 },
4805};
4806
Ben Hutchings98e67302011-11-25 14:36:19 +00004807static int __init mv88e6xxx_init(void)
4808{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004809 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004810 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004811}
4812module_init(mv88e6xxx_init);
4813
4814static void __exit mv88e6xxx_cleanup(void)
4815{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004816 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004817 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004818}
4819module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004820
4821MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4822MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4823MODULE_LICENSE("GPL");