blob: 24fb6a68503966a4ae049ef6b6fafa7d2bce7edf [file] [log] [blame]
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04002 * Marvell 88e6xxx Ethernet switch single-chip support
3 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00004 * Copyright (c) 2008 Marvell Semiconductor
5 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
7 *
Vivien Didelot4333d612017-03-28 15:10:36 -04008 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
9 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
10 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
Barry Grussling19b2f972013-01-08 16:05:54 +000017#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070018#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020019#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070020#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020021#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000024#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000025#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020026#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000027#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040028#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020029#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020030#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020031#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000032#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010033#include <linux/gpio/consumer.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000034#include <linux/phy.h>
Russell Kingc9a23562018-05-10 13:17:35 -070035#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000036#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040037
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040038#include "chip.h"
Vivien Didelota935c052016-09-29 12:21:53 -040039#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040040#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010041#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020042#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010043#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010044#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020045#include "serdes.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000046
Vivien Didelotfad09c72016-06-21 12:28:20 -040047static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048{
Vivien Didelotfad09c72016-06-21 12:28:20 -040049 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
50 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040051 dump_stack();
52 }
53}
54
Vivien Didelot914b32f2016-06-20 13:14:11 -040055/* The switch ADDR[4:1] configuration pins define the chip SMI device address
56 * (ADDR[0] is always zero, thus only even SMI addresses can be strapped).
57 *
58 * When ADDR is all zero, the chip uses Single-chip Addressing Mode, assuming it
59 * is the only device connected to the SMI master. In this mode it responds to
60 * all 32 possible SMI addresses, and thus maps directly the internal devices.
61 *
62 * When ADDR is non-zero, the chip uses Multi-chip Addressing Mode, allowing
63 * multiple devices to share the SMI interface. In this mode it responds to only
64 * 2 registers, used to indirectly access the internal SMI devices.
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000065 */
Vivien Didelot914b32f2016-06-20 13:14:11 -040066
Vivien Didelotfad09c72016-06-21 12:28:20 -040067static int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040068 int addr, int reg, u16 *val)
69{
Vivien Didelotfad09c72016-06-21 12:28:20 -040070 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040071 return -EOPNOTSUPP;
72
Vivien Didelotfad09c72016-06-21 12:28:20 -040073 return chip->smi_ops->read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040074}
75
Vivien Didelotfad09c72016-06-21 12:28:20 -040076static int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040077 int addr, int reg, u16 val)
78{
Vivien Didelotfad09c72016-06-21 12:28:20 -040079 if (!chip->smi_ops)
Vivien Didelot914b32f2016-06-20 13:14:11 -040080 return -EOPNOTSUPP;
81
Vivien Didelotfad09c72016-06-21 12:28:20 -040082 return chip->smi_ops->write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040083}
84
Vivien Didelotfad09c72016-06-21 12:28:20 -040085static int mv88e6xxx_smi_single_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -040086 int addr, int reg, u16 *val)
87{
88 int ret;
89
Vivien Didelotfad09c72016-06-21 12:28:20 -040090 ret = mdiobus_read_nested(chip->bus, addr, reg);
Vivien Didelot914b32f2016-06-20 13:14:11 -040091 if (ret < 0)
92 return ret;
93
94 *val = ret & 0xffff;
95
96 return 0;
97}
98
Vivien Didelotfad09c72016-06-21 12:28:20 -040099static int mv88e6xxx_smi_single_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400100 int addr, int reg, u16 val)
101{
102 int ret;
103
Vivien Didelotfad09c72016-06-21 12:28:20 -0400104 ret = mdiobus_write_nested(chip->bus, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400105 if (ret < 0)
106 return ret;
107
108 return 0;
109}
110
Vivien Didelotc08026a2016-09-29 12:21:59 -0400111static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_single_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400112 .read = mv88e6xxx_smi_single_chip_read,
113 .write = mv88e6xxx_smi_single_chip_write,
114};
115
Vivien Didelotfad09c72016-06-21 12:28:20 -0400116static int mv88e6xxx_smi_multi_chip_wait(struct mv88e6xxx_chip *chip)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000117{
118 int ret;
119 int i;
120
121 for (i = 0; i < 16; i++) {
Vivien Didelotfad09c72016-06-21 12:28:20 -0400122 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_CMD);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000123 if (ret < 0)
124 return ret;
125
Andrew Lunncca8b132015-04-02 04:06:39 +0200126 if ((ret & SMI_CMD_BUSY) == 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000127 return 0;
128 }
129
130 return -ETIMEDOUT;
131}
132
Vivien Didelotfad09c72016-06-21 12:28:20 -0400133static int mv88e6xxx_smi_multi_chip_read(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400134 int addr, int reg, u16 *val)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000135{
136 int ret;
137
Barry Grussling3675c8d2013-01-08 16:05:53 +0000138 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400139 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000140 if (ret < 0)
141 return ret;
142
Barry Grussling3675c8d2013-01-08 16:05:53 +0000143 /* Transmit the read command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400144 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Neil Armstrong6e899e62015-10-22 10:37:53 +0200145 SMI_CMD_OP_22_READ | (addr << 5) | reg);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000146 if (ret < 0)
147 return ret;
148
Barry Grussling3675c8d2013-01-08 16:05:53 +0000149 /* Wait for the read command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400150 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000151 if (ret < 0)
152 return ret;
153
Barry Grussling3675c8d2013-01-08 16:05:53 +0000154 /* Read the data. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400155 ret = mdiobus_read_nested(chip->bus, chip->sw_addr, SMI_DATA);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000156 if (ret < 0)
157 return ret;
158
Vivien Didelot914b32f2016-06-20 13:14:11 -0400159 *val = ret & 0xffff;
160
161 return 0;
162}
163
Vivien Didelotfad09c72016-06-21 12:28:20 -0400164static int mv88e6xxx_smi_multi_chip_write(struct mv88e6xxx_chip *chip,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400165 int addr, int reg, u16 val)
166{
167 int ret;
168
169 /* Wait for the bus to become free. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400170 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400171 if (ret < 0)
172 return ret;
173
174 /* Transmit the data to write. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400175 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_DATA, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400176 if (ret < 0)
177 return ret;
178
179 /* Transmit the write command. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400180 ret = mdiobus_write_nested(chip->bus, chip->sw_addr, SMI_CMD,
Vivien Didelot914b32f2016-06-20 13:14:11 -0400181 SMI_CMD_OP_22_WRITE | (addr << 5) | reg);
182 if (ret < 0)
183 return ret;
184
185 /* Wait for the write command to complete. */
Vivien Didelotfad09c72016-06-21 12:28:20 -0400186 ret = mv88e6xxx_smi_multi_chip_wait(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400187 if (ret < 0)
188 return ret;
189
190 return 0;
191}
192
Vivien Didelotc08026a2016-09-29 12:21:59 -0400193static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_multi_chip_ops = {
Vivien Didelot914b32f2016-06-20 13:14:11 -0400194 .read = mv88e6xxx_smi_multi_chip_read,
195 .write = mv88e6xxx_smi_multi_chip_write,
196};
197
Vivien Didelotec561272016-09-02 14:45:33 -0400198int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400199{
200 int err;
201
Vivien Didelotfad09c72016-06-21 12:28:20 -0400202 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400203
Vivien Didelotfad09c72016-06-21 12:28:20 -0400204 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400205 if (err)
206 return err;
207
Vivien Didelotfad09c72016-06-21 12:28:20 -0400208 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400209 addr, reg, *val);
210
211 return 0;
212}
213
Vivien Didelotec561272016-09-02 14:45:33 -0400214int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -0400215{
216 int err;
217
Vivien Didelotfad09c72016-06-21 12:28:20 -0400218 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400219
Vivien Didelotfad09c72016-06-21 12:28:20 -0400220 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -0400221 if (err)
222 return err;
223
Vivien Didelotfad09c72016-06-21 12:28:20 -0400224 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -0400225 addr, reg, val);
226
227 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000228}
229
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200230struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100231{
232 struct mv88e6xxx_mdio_bus *mdio_bus;
233
234 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
235 list);
236 if (!mdio_bus)
237 return NULL;
238
239 return mdio_bus->bus;
240}
241
Andrew Lunndc30c352016-10-16 19:56:49 +0200242static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
243{
244 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
245 unsigned int n = d->hwirq;
246
247 chip->g1_irq.masked |= (1 << n);
248}
249
250static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
251{
252 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
253 unsigned int n = d->hwirq;
254
255 chip->g1_irq.masked &= ~(1 << n);
256}
257
Andrew Lunn294d7112018-02-22 22:58:32 +0100258static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200259{
Andrew Lunndc30c352016-10-16 19:56:49 +0200260 unsigned int nhandled = 0;
261 unsigned int sub_irq;
262 unsigned int n;
263 u16 reg;
264 int err;
265
266 mutex_lock(&chip->reg_lock);
Vivien Didelot82466922017-06-15 12:13:59 -0400267 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200268 mutex_unlock(&chip->reg_lock);
269
270 if (err)
271 goto out;
272
273 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
274 if (reg & (1 << n)) {
275 sub_irq = irq_find_mapping(chip->g1_irq.domain, n);
276 handle_nested_irq(sub_irq);
277 ++nhandled;
278 }
279 }
280out:
281 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
282}
283
Andrew Lunn294d7112018-02-22 22:58:32 +0100284static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
285{
286 struct mv88e6xxx_chip *chip = dev_id;
287
288 return mv88e6xxx_g1_irq_thread_work(chip);
289}
290
Andrew Lunndc30c352016-10-16 19:56:49 +0200291static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
292{
293 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
294
295 mutex_lock(&chip->reg_lock);
296}
297
298static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
299{
300 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
301 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
302 u16 reg;
303 int err;
304
Vivien Didelotd77f4322017-06-15 12:14:03 -0400305 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200306 if (err)
307 goto out;
308
309 reg &= ~mask;
310 reg |= (~chip->g1_irq.masked & mask);
311
Vivien Didelotd77f4322017-06-15 12:14:03 -0400312 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200313 if (err)
314 goto out;
315
316out:
317 mutex_unlock(&chip->reg_lock);
318}
319
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530320static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200321 .name = "mv88e6xxx-g1",
322 .irq_mask = mv88e6xxx_g1_irq_mask,
323 .irq_unmask = mv88e6xxx_g1_irq_unmask,
324 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
325 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
326};
327
328static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
329 unsigned int irq,
330 irq_hw_number_t hwirq)
331{
332 struct mv88e6xxx_chip *chip = d->host_data;
333
334 irq_set_chip_data(irq, d->host_data);
335 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
336 irq_set_noprobe(irq);
337
338 return 0;
339}
340
341static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
342 .map = mv88e6xxx_g1_irq_domain_map,
343 .xlate = irq_domain_xlate_twocell,
344};
345
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200346/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100347static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200348{
349 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100350 u16 mask;
351
Vivien Didelotd77f4322017-06-15 12:14:03 -0400352 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100353 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400354 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100355
Andreas Färber5edef2f2016-11-27 23:26:28 +0100356 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100357 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200358 irq_dispose_mapping(virq);
359 }
360
Andrew Lunna3db3d32016-11-20 20:14:14 +0100361 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200362}
363
Andrew Lunn294d7112018-02-22 22:58:32 +0100364static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
365{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200366 /*
367 * free_irq must be called without reg_lock taken because the irq
368 * handler takes this lock, too.
369 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100370 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200371
372 mutex_lock(&chip->reg_lock);
373 mv88e6xxx_g1_irq_free_common(chip);
374 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100375}
376
377static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200378{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100379 int err, irq, virq;
380 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200381
382 chip->g1_irq.nirqs = chip->info->g1_irqs;
383 chip->g1_irq.domain = irq_domain_add_simple(
384 NULL, chip->g1_irq.nirqs, 0,
385 &mv88e6xxx_g1_irq_domain_ops, chip);
386 if (!chip->g1_irq.domain)
387 return -ENOMEM;
388
389 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
390 irq_create_mapping(chip->g1_irq.domain, irq);
391
392 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
393 chip->g1_irq.masked = ~0;
394
Vivien Didelotd77f4322017-06-15 12:14:03 -0400395 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200396 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100397 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200398
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100399 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200400
Vivien Didelotd77f4322017-06-15 12:14:03 -0400401 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200402 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100403 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200404
405 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400406 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200407 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100408 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200409
Andrew Lunndc30c352016-10-16 19:56:49 +0200410 return 0;
411
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100412out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100413 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400414 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100415
416out_mapping:
417 for (irq = 0; irq < 16; irq++) {
418 virq = irq_find_mapping(chip->g1_irq.domain, irq);
419 irq_dispose_mapping(virq);
420 }
421
422 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200423
424 return err;
425}
426
Andrew Lunn294d7112018-02-22 22:58:32 +0100427static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
428{
429 int err;
430
431 err = mv88e6xxx_g1_irq_setup_common(chip);
432 if (err)
433 return err;
434
435 err = request_threaded_irq(chip->irq, NULL,
436 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200437 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn294d7112018-02-22 22:58:32 +0100438 dev_name(chip->dev), chip);
439 if (err)
440 mv88e6xxx_g1_irq_free_common(chip);
441
442 return err;
443}
444
445static void mv88e6xxx_irq_poll(struct kthread_work *work)
446{
447 struct mv88e6xxx_chip *chip = container_of(work,
448 struct mv88e6xxx_chip,
449 irq_poll_work.work);
450 mv88e6xxx_g1_irq_thread_work(chip);
451
452 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
453 msecs_to_jiffies(100));
454}
455
456static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
457{
458 int err;
459
460 err = mv88e6xxx_g1_irq_setup_common(chip);
461 if (err)
462 return err;
463
464 kthread_init_delayed_work(&chip->irq_poll_work,
465 mv88e6xxx_irq_poll);
466
467 chip->kworker = kthread_create_worker(0, dev_name(chip->dev));
468 if (IS_ERR(chip->kworker))
469 return PTR_ERR(chip->kworker);
470
471 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
472 msecs_to_jiffies(100));
473
474 return 0;
475}
476
477static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
478{
479 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
480 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200481
482 mutex_lock(&chip->reg_lock);
483 mv88e6xxx_g1_irq_free_common(chip);
484 mutex_unlock(&chip->reg_lock);
Andrew Lunn294d7112018-02-22 22:58:32 +0100485}
486
Vivien Didelotec561272016-09-02 14:45:33 -0400487int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask)
Vivien Didelot2d79af62016-08-15 17:18:57 -0400488{
Andrew Lunn6441e6692016-08-19 00:01:55 +0200489 int i;
Vivien Didelot2d79af62016-08-15 17:18:57 -0400490
Andrew Lunn6441e6692016-08-19 00:01:55 +0200491 for (i = 0; i < 16; i++) {
Vivien Didelot2d79af62016-08-15 17:18:57 -0400492 u16 val;
493 int err;
494
495 err = mv88e6xxx_read(chip, addr, reg, &val);
496 if (err)
497 return err;
498
499 if (!(val & mask))
500 return 0;
501
502 usleep_range(1000, 2000);
503 }
504
Andrew Lunn30853552016-08-19 00:01:57 +0200505 dev_err(chip->dev, "Timeout while waiting for switch\n");
Vivien Didelot2d79af62016-08-15 17:18:57 -0400506 return -ETIMEDOUT;
507}
508
Vivien Didelotf22ab642016-07-18 20:45:31 -0400509/* Indirect write to single pointer-data register with an Update bit */
Vivien Didelotec561272016-09-02 14:45:33 -0400510int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, u16 update)
Vivien Didelotf22ab642016-07-18 20:45:31 -0400511{
512 u16 val;
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200513 int err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400514
515 /* Wait until the previous operation is completed */
Andrew Lunn0f02b4f2016-08-19 00:01:56 +0200516 err = mv88e6xxx_wait(chip, addr, reg, BIT(15));
517 if (err)
518 return err;
Vivien Didelotf22ab642016-07-18 20:45:31 -0400519
520 /* Set the Update bit to trigger a write operation */
521 val = BIT(15) | update;
522
523 return mv88e6xxx_write(chip, addr, reg, val);
524}
525
Vivien Didelotd78343d2016-11-04 03:23:36 +0100526static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
Andrew Lunn54186b92018-08-09 15:38:37 +0200527 int link, int speed, int duplex, int pause,
Vivien Didelotd78343d2016-11-04 03:23:36 +0100528 phy_interface_t mode)
529{
530 int err;
531
532 if (!chip->info->ops->port_set_link)
533 return 0;
534
535 /* Port's MAC control must not be changed unless the link is down */
536 err = chip->info->ops->port_set_link(chip, port, 0);
537 if (err)
538 return err;
539
540 if (chip->info->ops->port_set_speed) {
541 err = chip->info->ops->port_set_speed(chip, port, speed);
542 if (err && err != -EOPNOTSUPP)
543 goto restore_link;
544 }
545
Andrew Lunn54186b92018-08-09 15:38:37 +0200546 if (chip->info->ops->port_set_pause) {
547 err = chip->info->ops->port_set_pause(chip, port, pause);
548 if (err)
549 goto restore_link;
550 }
551
Vivien Didelotd78343d2016-11-04 03:23:36 +0100552 if (chip->info->ops->port_set_duplex) {
553 err = chip->info->ops->port_set_duplex(chip, port, duplex);
554 if (err && err != -EOPNOTSUPP)
555 goto restore_link;
556 }
557
558 if (chip->info->ops->port_set_rgmii_delay) {
559 err = chip->info->ops->port_set_rgmii_delay(chip, port, mode);
560 if (err && err != -EOPNOTSUPP)
561 goto restore_link;
562 }
563
Andrew Lunnf39908d2017-02-04 20:02:50 +0100564 if (chip->info->ops->port_set_cmode) {
565 err = chip->info->ops->port_set_cmode(chip, port, mode);
566 if (err && err != -EOPNOTSUPP)
567 goto restore_link;
568 }
569
Vivien Didelotd78343d2016-11-04 03:23:36 +0100570 err = 0;
571restore_link:
572 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400573 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100574
575 return err;
576}
577
Marek Vasutd700ec42018-09-12 00:15:24 +0200578static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
579{
580 struct mv88e6xxx_chip *chip = ds->priv;
581
582 return port < chip->info->num_internal_phys;
583}
584
Andrew Lunndea87022015-08-31 15:56:47 +0200585/* We expect the switch to perform auto negotiation if there is a real
586 * phy. However, in the case of a fixed link phy, we force the port
587 * settings from the fixed link settings.
588 */
Vivien Didelotf81ec902016-05-09 13:22:58 -0400589static void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
590 struct phy_device *phydev)
Andrew Lunndea87022015-08-31 15:56:47 +0200591{
Vivien Didelot04bed142016-08-31 18:06:13 -0400592 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200593 int err;
Andrew Lunndea87022015-08-31 15:56:47 +0200594
Marek Vasutd700ec42018-09-12 00:15:24 +0200595 if (!phy_is_pseudo_fixed_link(phydev) &&
596 mv88e6xxx_phy_is_internal(ds, port))
Andrew Lunndea87022015-08-31 15:56:47 +0200597 return;
598
Vivien Didelotfad09c72016-06-21 12:28:20 -0400599 mutex_lock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100600 err = mv88e6xxx_port_setup_mac(chip, port, phydev->link, phydev->speed,
Andrew Lunn54186b92018-08-09 15:38:37 +0200601 phydev->duplex, phydev->pause,
602 phydev->interface);
Vivien Didelotfad09c72016-06-21 12:28:20 -0400603 mutex_unlock(&chip->reg_lock);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100604
605 if (err && err != -EOPNOTSUPP)
Vivien Didelot774439e52017-06-08 18:34:08 -0400606 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
Andrew Lunndea87022015-08-31 15:56:47 +0200607}
608
Russell King6c422e32018-08-09 15:38:39 +0200609static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
610 unsigned long *mask,
611 struct phylink_link_state *state)
612{
613 if (!phy_interface_mode_is_8023z(state->interface)) {
614 /* 10M and 100M are only supported in non-802.3z mode */
615 phylink_set(mask, 10baseT_Half);
616 phylink_set(mask, 10baseT_Full);
617 phylink_set(mask, 100baseT_Half);
618 phylink_set(mask, 100baseT_Full);
619 }
620}
621
622static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
623 unsigned long *mask,
624 struct phylink_link_state *state)
625{
626 /* FIXME: if the port is in 1000Base-X mode, then it only supports
627 * 1000M FD speeds. In this case, CMODE will indicate 5.
628 */
629 phylink_set(mask, 1000baseT_Full);
630 phylink_set(mask, 1000baseX_Full);
631
632 mv88e6065_phylink_validate(chip, port, mask, state);
633}
634
635static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
636 unsigned long *mask,
637 struct phylink_link_state *state)
638{
639 /* No ethtool bits for 200Mbps */
640 phylink_set(mask, 1000baseT_Full);
641 phylink_set(mask, 1000baseX_Full);
642
643 mv88e6065_phylink_validate(chip, port, mask, state);
644}
645
646static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
647 unsigned long *mask,
648 struct phylink_link_state *state)
649{
650 if (port >= 9)
651 phylink_set(mask, 2500baseX_Full);
652
653 /* No ethtool bits for 200Mbps */
654 phylink_set(mask, 1000baseT_Full);
655 phylink_set(mask, 1000baseX_Full);
656
657 mv88e6065_phylink_validate(chip, port, mask, state);
658}
659
660static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
661 unsigned long *mask,
662 struct phylink_link_state *state)
663{
664 if (port >= 9) {
665 phylink_set(mask, 10000baseT_Full);
666 phylink_set(mask, 10000baseKR_Full);
667 }
668
669 mv88e6390_phylink_validate(chip, port, mask, state);
670}
671
Russell Kingc9a23562018-05-10 13:17:35 -0700672static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
673 unsigned long *supported,
674 struct phylink_link_state *state)
675{
Russell King6c422e32018-08-09 15:38:39 +0200676 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
677 struct mv88e6xxx_chip *chip = ds->priv;
678
679 /* Allow all the expected bits */
680 phylink_set(mask, Autoneg);
681 phylink_set(mask, Pause);
682 phylink_set_port_modes(mask);
683
684 if (chip->info->ops->phylink_validate)
685 chip->info->ops->phylink_validate(chip, port, mask, state);
686
687 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
688 bitmap_and(state->advertising, state->advertising, mask,
689 __ETHTOOL_LINK_MODE_MASK_NBITS);
690
691 /* We can only operate at 2500BaseX or 1000BaseX. If requested
692 * to advertise both, only report advertising at 2500BaseX.
693 */
694 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700695}
696
697static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
698 struct phylink_link_state *state)
699{
700 struct mv88e6xxx_chip *chip = ds->priv;
701 int err;
702
703 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200704 if (chip->info->ops->port_link_state)
705 err = chip->info->ops->port_link_state(chip, port, state);
706 else
707 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700708 mutex_unlock(&chip->reg_lock);
709
710 return err;
711}
712
713static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
714 unsigned int mode,
715 const struct phylink_link_state *state)
716{
717 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200718 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700719
Marek Vasutd700ec42018-09-12 00:15:24 +0200720 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700721 return;
722
723 if (mode == MLO_AN_FIXED) {
724 link = LINK_FORCED_UP;
725 speed = state->speed;
726 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200727 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
728 link = state->link;
729 speed = state->speed;
730 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700731 } else {
732 speed = SPEED_UNFORCED;
733 duplex = DUPLEX_UNFORCED;
734 link = LINK_UNFORCED;
735 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200736 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700737
738 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200739 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700740 state->interface);
741 mutex_unlock(&chip->reg_lock);
742
743 if (err && err != -EOPNOTSUPP)
744 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
745}
746
747static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
748{
749 struct mv88e6xxx_chip *chip = ds->priv;
750 int err;
751
752 mutex_lock(&chip->reg_lock);
753 err = chip->info->ops->port_set_link(chip, port, link);
754 mutex_unlock(&chip->reg_lock);
755
756 if (err)
757 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
758}
759
760static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
761 unsigned int mode,
762 phy_interface_t interface)
763{
764 if (mode == MLO_AN_FIXED)
765 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
766}
767
768static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
769 unsigned int mode, phy_interface_t interface,
770 struct phy_device *phydev)
771{
772 if (mode == MLO_AN_FIXED)
773 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
774}
775
Andrew Lunna605a0f2016-11-21 23:26:58 +0100776static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000777{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100778 if (!chip->info->ops->stats_snapshot)
779 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000780
Andrew Lunna605a0f2016-11-21 23:26:58 +0100781 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000782}
783
Andrew Lunne413e7e2015-04-02 04:06:38 +0200784static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100785 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
786 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
787 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
788 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
789 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
790 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
791 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
792 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
793 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
794 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
795 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
796 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
797 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
798 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
799 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
800 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
801 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
802 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
803 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
804 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
805 { "single", 4, 0x14, STATS_TYPE_BANK0, },
806 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
807 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
808 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
809 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
810 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
811 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
812 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
813 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
814 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
815 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
816 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
817 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
818 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
819 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
820 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
821 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
822 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
823 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
824 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
825 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
826 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
827 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
828 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
829 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
830 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
831 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
832 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
833 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
834 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
835 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
836 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
837 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
838 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
839 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
840 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
841 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
842 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
843 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200844};
845
Vivien Didelotfad09c72016-06-21 12:28:20 -0400846static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100847 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100848 int port, u16 bank1_select,
849 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200850{
Andrew Lunn80c46272015-06-20 18:42:30 +0200851 u32 low;
852 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100853 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200854 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200855 u64 value;
856
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100857 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100858 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200859 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
860 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800861 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200862
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200863 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100864 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200865 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
866 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800867 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200868 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200869 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100870 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100871 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100872 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100873 /* fall through */
874 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100875 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100876 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100877 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100878 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500879 break;
880 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800881 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200882 }
883 value = (((u64)high) << 16) | low;
884 return value;
885}
886
Andrew Lunn436fe172018-03-01 02:02:29 +0100887static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
888 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100889{
890 struct mv88e6xxx_hw_stat *stat;
891 int i, j;
892
893 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
894 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100895 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100896 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
897 ETH_GSTRING_LEN);
898 j++;
899 }
900 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100901
902 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100903}
904
Andrew Lunn436fe172018-03-01 02:02:29 +0100905static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
906 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100907{
Andrew Lunn436fe172018-03-01 02:02:29 +0100908 return mv88e6xxx_stats_get_strings(chip, data,
909 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100910}
911
Andrew Lunn436fe172018-03-01 02:02:29 +0100912static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
913 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100914{
Andrew Lunn436fe172018-03-01 02:02:29 +0100915 return mv88e6xxx_stats_get_strings(chip, data,
916 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100917}
918
Andrew Lunn65f60e42018-03-28 23:50:28 +0200919static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
920 "atu_member_violation",
921 "atu_miss_violation",
922 "atu_full_violation",
923 "vtu_member_violation",
924 "vtu_miss_violation",
925};
926
927static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
928{
929 unsigned int i;
930
931 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
932 strlcpy(data + i * ETH_GSTRING_LEN,
933 mv88e6xxx_atu_vtu_stats_strings[i],
934 ETH_GSTRING_LEN);
935}
936
Andrew Lunndfafe442016-11-21 23:27:02 +0100937static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700938 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100939{
Vivien Didelot04bed142016-08-31 18:06:13 -0400940 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100941 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100942
Florian Fainelli89f09042018-04-25 12:12:50 -0700943 if (stringset != ETH_SS_STATS)
944 return;
945
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100946 mutex_lock(&chip->reg_lock);
947
Andrew Lunndfafe442016-11-21 23:27:02 +0100948 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100949 count = chip->info->ops->stats_get_strings(chip, data);
950
951 if (chip->info->ops->serdes_get_strings) {
952 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200953 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100954 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100955
Andrew Lunn65f60e42018-03-28 23:50:28 +0200956 data += count * ETH_GSTRING_LEN;
957 mv88e6xxx_atu_vtu_get_strings(data);
958
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100959 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100960}
961
962static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
963 int types)
964{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100965 struct mv88e6xxx_hw_stat *stat;
966 int i, j;
967
968 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
969 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100970 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100971 j++;
972 }
973 return j;
974}
975
Andrew Lunndfafe442016-11-21 23:27:02 +0100976static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
977{
978 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
979 STATS_TYPE_PORT);
980}
981
982static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
983{
984 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
985 STATS_TYPE_BANK1);
986}
987
Florian Fainelli89f09042018-04-25 12:12:50 -0700988static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100989{
990 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100991 int serdes_count = 0;
992 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100993
Florian Fainelli89f09042018-04-25 12:12:50 -0700994 if (sset != ETH_SS_STATS)
995 return 0;
996
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100997 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100998 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100999 count = chip->info->ops->stats_get_sset_count(chip);
1000 if (count < 0)
1001 goto out;
1002
1003 if (chip->info->ops->serdes_get_sset_count)
1004 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1005 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001006 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001007 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001008 goto out;
1009 }
1010 count += serdes_count;
1011 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1012
Andrew Lunn436fe172018-03-01 02:02:29 +01001013out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001014 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001015
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001017}
1018
Andrew Lunn436fe172018-03-01 02:02:29 +01001019static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1020 uint64_t *data, int types,
1021 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001022{
1023 struct mv88e6xxx_hw_stat *stat;
1024 int i, j;
1025
1026 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1027 stat = &mv88e6xxx_hw_stats[i];
1028 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001029 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001030 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1031 bank1_select,
1032 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001033 mutex_unlock(&chip->reg_lock);
1034
Andrew Lunn052f9472016-11-21 23:27:03 +01001035 j++;
1036 }
1037 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001038 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001039}
1040
Andrew Lunn436fe172018-03-01 02:02:29 +01001041static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1042 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001043{
1044 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001045 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001046 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001047}
1048
Andrew Lunn436fe172018-03-01 02:02:29 +01001049static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1050 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001051{
1052 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001053 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001054 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1055 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001056}
1057
Andrew Lunn436fe172018-03-01 02:02:29 +01001058static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1059 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001060{
1061 return mv88e6xxx_stats_get_stats(chip, port, data,
1062 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001063 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1064 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001065}
1066
Andrew Lunn65f60e42018-03-28 23:50:28 +02001067static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1068 uint64_t *data)
1069{
1070 *data++ = chip->ports[port].atu_member_violation;
1071 *data++ = chip->ports[port].atu_miss_violation;
1072 *data++ = chip->ports[port].atu_full_violation;
1073 *data++ = chip->ports[port].vtu_member_violation;
1074 *data++ = chip->ports[port].vtu_miss_violation;
1075}
1076
Andrew Lunn052f9472016-11-21 23:27:03 +01001077static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1078 uint64_t *data)
1079{
Andrew Lunn436fe172018-03-01 02:02:29 +01001080 int count = 0;
1081
Andrew Lunn052f9472016-11-21 23:27:03 +01001082 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001083 count = chip->info->ops->stats_get_stats(chip, port, data);
1084
Andrew Lunn65f60e42018-03-28 23:50:28 +02001085 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001086 if (chip->info->ops->serdes_get_stats) {
1087 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001088 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001089 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001090 data += count;
1091 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1092 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001093}
1094
Vivien Didelotf81ec902016-05-09 13:22:58 -04001095static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1096 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001097{
Vivien Didelot04bed142016-08-31 18:06:13 -04001098 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001099 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001100
Vivien Didelotfad09c72016-06-21 12:28:20 -04001101 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001102
Andrew Lunna605a0f2016-11-21 23:26:58 +01001103 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001104 mutex_unlock(&chip->reg_lock);
1105
1106 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001107 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001108
1109 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001110
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001111}
Ben Hutchings98e67302011-11-25 14:36:19 +00001112
Vivien Didelotf81ec902016-05-09 13:22:58 -04001113static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001114{
1115 return 32 * sizeof(u16);
1116}
1117
Vivien Didelotf81ec902016-05-09 13:22:58 -04001118static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1119 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001120{
Vivien Didelot04bed142016-08-31 18:06:13 -04001121 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001122 int err;
1123 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001124 u16 *p = _p;
1125 int i;
1126
Vivien Didelota5f39322018-12-17 16:05:21 -05001127 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001128
1129 memset(p, 0xff, 32 * sizeof(u16));
1130
Vivien Didelotfad09c72016-06-21 12:28:20 -04001131 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001132
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001133 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001134
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001135 err = mv88e6xxx_port_read(chip, port, i, &reg);
1136 if (!err)
1137 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138 }
Vivien Didelot23062512016-05-09 13:22:45 -04001139
Vivien Didelotfad09c72016-06-21 12:28:20 -04001140 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001141}
1142
Vivien Didelot08f50062017-08-01 16:32:41 -04001143static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1144 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001145{
Vivien Didelot5480db62017-08-01 16:32:40 -04001146 /* Nothing to do on the port's MAC */
1147 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001148}
1149
Vivien Didelot08f50062017-08-01 16:32:41 -04001150static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1151 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001152{
Vivien Didelot5480db62017-08-01 16:32:40 -04001153 /* Nothing to do on the port's MAC */
1154 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001155}
1156
Vivien Didelote5887a22017-03-30 17:37:11 -04001157static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001158{
Vivien Didelote5887a22017-03-30 17:37:11 -04001159 struct dsa_switch *ds = NULL;
1160 struct net_device *br;
1161 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001162 int i;
1163
Vivien Didelote5887a22017-03-30 17:37:11 -04001164 if (dev < DSA_MAX_SWITCHES)
1165 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001166
Vivien Didelote5887a22017-03-30 17:37:11 -04001167 /* Prevent frames from unknown switch or port */
1168 if (!ds || port >= ds->num_ports)
1169 return 0;
1170
1171 /* Frames from DSA links and CPU ports can egress any local port */
1172 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1173 return mv88e6xxx_port_mask(chip);
1174
1175 br = ds->ports[port].bridge_dev;
1176 pvlan = 0;
1177
1178 /* Frames from user ports can egress any local DSA links and CPU ports,
1179 * as well as any local member of their bridge group.
1180 */
1181 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1182 if (dsa_is_cpu_port(chip->ds, i) ||
1183 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001184 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001185 pvlan |= BIT(i);
1186
1187 return pvlan;
1188}
1189
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001190static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001191{
1192 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001193
1194 /* prevent frames from going back out of the port they came in on */
1195 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001196
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001197 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001198}
1199
Vivien Didelotf81ec902016-05-09 13:22:58 -04001200static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1201 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001202{
Vivien Didelot04bed142016-08-31 18:06:13 -04001203 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001204 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001205
Vivien Didelotfad09c72016-06-21 12:28:20 -04001206 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001207 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001208 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001209
1210 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001211 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001212}
1213
Vivien Didelot93e18d62018-05-11 17:16:35 -04001214static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1215{
1216 int err;
1217
1218 if (chip->info->ops->ieee_pri_map) {
1219 err = chip->info->ops->ieee_pri_map(chip);
1220 if (err)
1221 return err;
1222 }
1223
1224 if (chip->info->ops->ip_pri_map) {
1225 err = chip->info->ops->ip_pri_map(chip);
1226 if (err)
1227 return err;
1228 }
1229
1230 return 0;
1231}
1232
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001233static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1234{
1235 int target, port;
1236 int err;
1237
1238 if (!chip->info->global2_addr)
1239 return 0;
1240
1241 /* Initialize the routing port to the 32 possible target devices */
1242 for (target = 0; target < 32; target++) {
1243 port = 0x1f;
1244 if (target < DSA_MAX_SWITCHES)
1245 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1246 port = chip->ds->rtable[target];
1247
1248 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1249 if (err)
1250 return err;
1251 }
1252
Vivien Didelot02317e62018-05-09 11:38:49 -04001253 if (chip->info->ops->set_cascade_port) {
1254 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1255 err = chip->info->ops->set_cascade_port(chip, port);
1256 if (err)
1257 return err;
1258 }
1259
Vivien Didelot23c98912018-05-09 11:38:50 -04001260 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1261 if (err)
1262 return err;
1263
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001264 return 0;
1265}
1266
Vivien Didelotb28f8722018-04-26 21:56:44 -04001267static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1268{
1269 /* Clear all trunk masks and mapping */
1270 if (chip->info->global2_addr)
1271 return mv88e6xxx_g2_trunk_clear(chip);
1272
1273 return 0;
1274}
1275
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001276static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1277{
1278 if (chip->info->ops->rmu_disable)
1279 return chip->info->ops->rmu_disable(chip);
1280
1281 return 0;
1282}
1283
Vivien Didelot9e907d72017-07-17 13:03:43 -04001284static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1285{
1286 if (chip->info->ops->pot_clear)
1287 return chip->info->ops->pot_clear(chip);
1288
1289 return 0;
1290}
1291
Vivien Didelot51c901a2017-07-17 13:03:41 -04001292static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1293{
1294 if (chip->info->ops->mgmt_rsvd2cpu)
1295 return chip->info->ops->mgmt_rsvd2cpu(chip);
1296
1297 return 0;
1298}
1299
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001300static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1301{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001302 int err;
1303
Vivien Didelotdaefc942017-03-11 16:12:54 -05001304 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1305 if (err)
1306 return err;
1307
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001308 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1309 if (err)
1310 return err;
1311
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001312 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1313}
1314
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001315static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1316{
1317 int port;
1318 int err;
1319
1320 if (!chip->info->ops->irl_init_all)
1321 return 0;
1322
1323 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1324 /* Disable ingress rate limiting by resetting all per port
1325 * ingress rate limit resources to their initial state.
1326 */
1327 err = chip->info->ops->irl_init_all(chip, port);
1328 if (err)
1329 return err;
1330 }
1331
1332 return 0;
1333}
1334
Vivien Didelot04a69a12017-10-13 14:18:05 -04001335static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1336{
1337 if (chip->info->ops->set_switch_mac) {
1338 u8 addr[ETH_ALEN];
1339
1340 eth_random_addr(addr);
1341
1342 return chip->info->ops->set_switch_mac(chip, addr);
1343 }
1344
1345 return 0;
1346}
1347
Vivien Didelot17a15942017-03-30 17:37:09 -04001348static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1349{
1350 u16 pvlan = 0;
1351
1352 if (!mv88e6xxx_has_pvt(chip))
1353 return -EOPNOTSUPP;
1354
1355 /* Skip the local source device, which uses in-chip port VLAN */
1356 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001357 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001358
1359 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1360}
1361
Vivien Didelot81228992017-03-30 17:37:08 -04001362static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1363{
Vivien Didelot17a15942017-03-30 17:37:09 -04001364 int dev, port;
1365 int err;
1366
Vivien Didelot81228992017-03-30 17:37:08 -04001367 if (!mv88e6xxx_has_pvt(chip))
1368 return 0;
1369
1370 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1371 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1372 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001373 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1374 if (err)
1375 return err;
1376
1377 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1378 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1379 err = mv88e6xxx_pvt_map(chip, dev, port);
1380 if (err)
1381 return err;
1382 }
1383 }
1384
1385 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001386}
1387
Vivien Didelot749efcb2016-09-22 16:49:24 -04001388static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1389{
1390 struct mv88e6xxx_chip *chip = ds->priv;
1391 int err;
1392
1393 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001394 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001395 mutex_unlock(&chip->reg_lock);
1396
1397 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001398 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001399}
1400
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001401static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1402{
1403 if (!chip->info->max_vid)
1404 return 0;
1405
1406 return mv88e6xxx_g1_vtu_flush(chip);
1407}
1408
Vivien Didelotf1394b782017-05-01 14:05:22 -04001409static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1410 struct mv88e6xxx_vtu_entry *entry)
1411{
1412 if (!chip->info->ops->vtu_getnext)
1413 return -EOPNOTSUPP;
1414
1415 return chip->info->ops->vtu_getnext(chip, entry);
1416}
1417
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001418static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1419 struct mv88e6xxx_vtu_entry *entry)
1420{
1421 if (!chip->info->ops->vtu_loadpurge)
1422 return -EOPNOTSUPP;
1423
1424 return chip->info->ops->vtu_loadpurge(chip, entry);
1425}
1426
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001427static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001428{
1429 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001430 struct mv88e6xxx_vtu_entry vlan = {
1431 .vid = chip->info->max_vid,
1432 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001433 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001434
1435 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1436
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001437 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001438 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001439 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001440 if (err)
1441 return err;
1442
1443 set_bit(*fid, fid_bitmap);
1444 }
1445
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001446 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001447 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001448 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001449 if (err)
1450 return err;
1451
1452 if (!vlan.valid)
1453 break;
1454
1455 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001456 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001457
1458 /* The reset value 0x000 is used to indicate that multiple address
1459 * databases are not needed. Return the next positive available.
1460 */
1461 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001462 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001463 return -ENOSPC;
1464
1465 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001466 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001467}
1468
Vivien Didelot567aa592017-05-01 14:05:25 -04001469static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1470 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001471{
1472 int err;
1473
1474 if (!vid)
1475 return -EINVAL;
1476
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001477 entry->vid = vid - 1;
1478 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001479
Vivien Didelotf1394b782017-05-01 14:05:22 -04001480 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001481 if (err)
1482 return err;
1483
Vivien Didelot567aa592017-05-01 14:05:25 -04001484 if (entry->vid == vid && entry->valid)
1485 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001486
Vivien Didelot567aa592017-05-01 14:05:25 -04001487 if (new) {
1488 int i;
1489
1490 /* Initialize a fresh VLAN entry */
1491 memset(entry, 0, sizeof(*entry));
1492 entry->valid = true;
1493 entry->vid = vid;
1494
Vivien Didelot553a7682017-06-07 18:12:16 -04001495 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001496 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001497 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001498 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001499
1500 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001501 }
1502
Vivien Didelot567aa592017-05-01 14:05:25 -04001503 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1504 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001505}
1506
Vivien Didelotda9c3592016-02-12 12:09:40 -05001507static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1508 u16 vid_begin, u16 vid_end)
1509{
Vivien Didelot04bed142016-08-31 18:06:13 -04001510 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001511 struct mv88e6xxx_vtu_entry vlan = {
1512 .vid = vid_begin - 1,
1513 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001514 int i, err;
1515
Andrew Lunndb06ae412017-09-25 23:32:20 +02001516 /* DSA and CPU ports have to be members of multiple vlans */
1517 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1518 return 0;
1519
Vivien Didelotda9c3592016-02-12 12:09:40 -05001520 if (!vid_begin)
1521 return -EOPNOTSUPP;
1522
Vivien Didelotfad09c72016-06-21 12:28:20 -04001523 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001524
Vivien Didelotda9c3592016-02-12 12:09:40 -05001525 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001526 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001527 if (err)
1528 goto unlock;
1529
1530 if (!vlan.valid)
1531 break;
1532
1533 if (vlan.vid > vid_end)
1534 break;
1535
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001536 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001537 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1538 continue;
1539
Andrew Lunncd886462017-11-09 22:29:53 +01001540 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001541 continue;
1542
Vivien Didelotbd00e052017-05-01 14:05:11 -04001543 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001544 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545 continue;
1546
Vivien Didelotc8652c82017-10-16 11:12:19 -04001547 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001548 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001549 break; /* same bridge, check next VLAN */
1550
Vivien Didelotc8652c82017-10-16 11:12:19 -04001551 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001552 continue;
1553
Andrew Lunn743fcc22017-11-09 22:29:54 +01001554 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1555 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001556 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001557 err = -EOPNOTSUPP;
1558 goto unlock;
1559 }
1560 } while (vlan.vid < vid_end);
1561
1562unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001563 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001564
1565 return err;
1566}
1567
Vivien Didelotf81ec902016-05-09 13:22:58 -04001568static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1569 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001570{
Vivien Didelot04bed142016-08-31 18:06:13 -04001571 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001572 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1573 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001574 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001575
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001576 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001577 return -EOPNOTSUPP;
1578
Vivien Didelotfad09c72016-06-21 12:28:20 -04001579 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001580 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001581 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001582
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001583 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001584}
1585
Vivien Didelot57d32312016-06-20 13:13:58 -04001586static int
1587mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001588 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001589{
Vivien Didelot04bed142016-08-31 18:06:13 -04001590 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001591 int err;
1592
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001593 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001594 return -EOPNOTSUPP;
1595
Vivien Didelotda9c3592016-02-12 12:09:40 -05001596 /* If the requested port doesn't belong to the same bridge as the VLAN
1597 * members, do not support it (yet) and fallback to software VLAN.
1598 */
1599 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1600 vlan->vid_end);
1601 if (err)
1602 return err;
1603
Vivien Didelot76e398a2015-11-01 12:33:55 -05001604 /* We don't need any dynamic resource from the kernel (yet),
1605 * so skip the prepare phase.
1606 */
1607 return 0;
1608}
1609
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001610static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1611 const unsigned char *addr, u16 vid,
1612 u8 state)
1613{
1614 struct mv88e6xxx_vtu_entry vlan;
1615 struct mv88e6xxx_atu_entry entry;
1616 int err;
1617
1618 /* Null VLAN ID corresponds to the port private database */
1619 if (vid == 0)
1620 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1621 else
1622 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1623 if (err)
1624 return err;
1625
1626 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1627 ether_addr_copy(entry.mac, addr);
1628 eth_addr_dec(entry.mac);
1629
1630 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1631 if (err)
1632 return err;
1633
1634 /* Initialize a fresh ATU entry if it isn't found */
1635 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1636 !ether_addr_equal(entry.mac, addr)) {
1637 memset(&entry, 0, sizeof(entry));
1638 ether_addr_copy(entry.mac, addr);
1639 }
1640
1641 /* Purge the ATU entry only if no port is using it anymore */
1642 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1643 entry.portvec &= ~BIT(port);
1644 if (!entry.portvec)
1645 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1646 } else {
1647 entry.portvec |= BIT(port);
1648 entry.state = state;
1649 }
1650
1651 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1652}
1653
Andrew Lunn87fa8862017-11-09 22:29:56 +01001654static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1655 u16 vid)
1656{
1657 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1658 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1659
1660 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1661}
1662
1663static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1664{
1665 int port;
1666 int err;
1667
1668 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1669 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1670 if (err)
1671 return err;
1672 }
1673
1674 return 0;
1675}
1676
Vivien Didelotfad09c72016-06-21 12:28:20 -04001677static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001678 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001679{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001680 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001681 int err;
1682
Vivien Didelot567aa592017-05-01 14:05:25 -04001683 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001684 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001685 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001686
Vivien Didelotc91498e2017-06-07 18:12:13 -04001687 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001688
Andrew Lunn87fa8862017-11-09 22:29:56 +01001689 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1690 if (err)
1691 return err;
1692
1693 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001694}
1695
Vivien Didelotf81ec902016-05-09 13:22:58 -04001696static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001697 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001698{
Vivien Didelot04bed142016-08-31 18:06:13 -04001699 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001700 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1701 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001702 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001703 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001704
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001705 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001706 return;
1707
Vivien Didelotc91498e2017-06-07 18:12:13 -04001708 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001709 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001710 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001711 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001712 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001713 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001714
Vivien Didelotfad09c72016-06-21 12:28:20 -04001715 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001716
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001717 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001718 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001719 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1720 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001721
Vivien Didelot77064f32016-11-04 03:23:30 +01001722 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001723 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1724 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001725
Vivien Didelotfad09c72016-06-21 12:28:20 -04001726 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001727}
1728
Vivien Didelotfad09c72016-06-21 12:28:20 -04001729static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001730 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001731{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001732 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001733 int i, err;
1734
Vivien Didelot567aa592017-05-01 14:05:25 -04001735 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001736 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001737 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001738
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001739 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001740 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001741 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001742
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001743 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001744
1745 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001746 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001747 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001748 if (vlan.member[i] !=
1749 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001750 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001751 break;
1752 }
1753 }
1754
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001755 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001756 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001757 return err;
1758
Vivien Didelote606ca32017-03-11 16:12:55 -05001759 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001760}
1761
Vivien Didelotf81ec902016-05-09 13:22:58 -04001762static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1763 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001764{
Vivien Didelot04bed142016-08-31 18:06:13 -04001765 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001766 u16 pvid, vid;
1767 int err = 0;
1768
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001769 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001770 return -EOPNOTSUPP;
1771
Vivien Didelotfad09c72016-06-21 12:28:20 -04001772 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001773
Vivien Didelot77064f32016-11-04 03:23:30 +01001774 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001775 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001776 goto unlock;
1777
Vivien Didelot76e398a2015-11-01 12:33:55 -05001778 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001779 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001780 if (err)
1781 goto unlock;
1782
1783 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001784 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001785 if (err)
1786 goto unlock;
1787 }
1788 }
1789
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001790unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001791 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001792
1793 return err;
1794}
1795
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001796static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1797 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001798{
Vivien Didelot04bed142016-08-31 18:06:13 -04001799 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001800 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001801
Vivien Didelotfad09c72016-06-21 12:28:20 -04001802 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001803 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1804 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001805 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001806
1807 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001808}
1809
Vivien Didelotf81ec902016-05-09 13:22:58 -04001810static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001811 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001812{
Vivien Didelot04bed142016-08-31 18:06:13 -04001813 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001814 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001815
Vivien Didelotfad09c72016-06-21 12:28:20 -04001816 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001817 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001818 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001819 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001820
Vivien Didelot83dabd12016-08-31 11:50:04 -04001821 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001822}
1823
Vivien Didelot83dabd12016-08-31 11:50:04 -04001824static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1825 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001826 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001827{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001828 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001829 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001830 int err;
1831
Vivien Didelot27c0e602017-06-15 12:14:01 -04001832 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001833 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001834
1835 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001836 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001837 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001838 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001839 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001840 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001841
Vivien Didelot27c0e602017-06-15 12:14:01 -04001842 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001843 break;
1844
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001845 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001846 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001847
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001848 if (!is_unicast_ether_addr(addr.mac))
1849 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001850
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001851 is_static = (addr.state ==
1852 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1853 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001854 if (err)
1855 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001856 } while (!is_broadcast_ether_addr(addr.mac));
1857
1858 return err;
1859}
1860
Vivien Didelot83dabd12016-08-31 11:50:04 -04001861static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001862 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001863{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001864 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001865 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001866 };
1867 u16 fid;
1868 int err;
1869
1870 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001871 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001872 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001873 mutex_unlock(&chip->reg_lock);
1874
Vivien Didelot83dabd12016-08-31 11:50:04 -04001875 if (err)
1876 return err;
1877
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001878 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001879 if (err)
1880 return err;
1881
1882 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001883 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001884 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001885 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001886 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001887 if (err)
1888 return err;
1889
1890 if (!vlan.valid)
1891 break;
1892
1893 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001894 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001895 if (err)
1896 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001897 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001898
1899 return err;
1900}
1901
Vivien Didelotf81ec902016-05-09 13:22:58 -04001902static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001903 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001904{
Vivien Didelot04bed142016-08-31 18:06:13 -04001905 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001906
Andrew Lunna61e5402018-02-15 14:38:35 +01001907 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001908}
1909
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001910static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1911 struct net_device *br)
1912{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001913 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001914 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001915 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001916 int err;
1917
1918 /* Remap the Port VLAN of each local bridge group member */
1919 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1920 if (chip->ds->ports[port].bridge_dev == br) {
1921 err = mv88e6xxx_port_vlan_map(chip, port);
1922 if (err)
1923 return err;
1924 }
1925 }
1926
Vivien Didelote96a6e02017-03-30 17:37:13 -04001927 if (!mv88e6xxx_has_pvt(chip))
1928 return 0;
1929
1930 /* Remap the Port VLAN of each cross-chip bridge group member */
1931 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1932 ds = chip->ds->dst->ds[dev];
1933 if (!ds)
1934 break;
1935
1936 for (port = 0; port < ds->num_ports; ++port) {
1937 if (ds->ports[port].bridge_dev == br) {
1938 err = mv88e6xxx_pvt_map(chip, dev, port);
1939 if (err)
1940 return err;
1941 }
1942 }
1943 }
1944
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001945 return 0;
1946}
1947
Vivien Didelotf81ec902016-05-09 13:22:58 -04001948static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001949 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001950{
Vivien Didelot04bed142016-08-31 18:06:13 -04001951 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001952 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001953
Vivien Didelotfad09c72016-06-21 12:28:20 -04001954 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001955 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001956 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001957
Vivien Didelot466dfa02016-02-26 13:16:05 -05001958 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001959}
1960
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001961static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1962 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001963{
Vivien Didelot04bed142016-08-31 18:06:13 -04001964 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001965
Vivien Didelotfad09c72016-06-21 12:28:20 -04001966 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001967 if (mv88e6xxx_bridge_map(chip, br) ||
1968 mv88e6xxx_port_vlan_map(chip, port))
1969 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001970 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001971}
1972
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001973static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1974 int port, struct net_device *br)
1975{
1976 struct mv88e6xxx_chip *chip = ds->priv;
1977 int err;
1978
1979 if (!mv88e6xxx_has_pvt(chip))
1980 return 0;
1981
1982 mutex_lock(&chip->reg_lock);
1983 err = mv88e6xxx_pvt_map(chip, dev, port);
1984 mutex_unlock(&chip->reg_lock);
1985
1986 return err;
1987}
1988
1989static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1990 int port, struct net_device *br)
1991{
1992 struct mv88e6xxx_chip *chip = ds->priv;
1993
1994 if (!mv88e6xxx_has_pvt(chip))
1995 return;
1996
1997 mutex_lock(&chip->reg_lock);
1998 if (mv88e6xxx_pvt_map(chip, dev, port))
1999 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2000 mutex_unlock(&chip->reg_lock);
2001}
2002
Vivien Didelot17e708b2016-12-05 17:30:27 -05002003static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2004{
2005 if (chip->info->ops->reset)
2006 return chip->info->ops->reset(chip);
2007
2008 return 0;
2009}
2010
Vivien Didelot309eca62016-12-05 17:30:26 -05002011static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2012{
2013 struct gpio_desc *gpiod = chip->reset;
2014
2015 /* If there is a GPIO connected to the reset pin, toggle it */
2016 if (gpiod) {
2017 gpiod_set_value_cansleep(gpiod, 1);
2018 usleep_range(10000, 20000);
2019 gpiod_set_value_cansleep(gpiod, 0);
2020 usleep_range(10000, 20000);
2021 }
2022}
2023
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002024static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2025{
2026 int i, err;
2027
2028 /* Set all ports to the Disabled state */
2029 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002030 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002031 if (err)
2032 return err;
2033 }
2034
2035 /* Wait for transmit queues to drain,
2036 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2037 */
2038 usleep_range(2000, 4000);
2039
2040 return 0;
2041}
2042
Vivien Didelotfad09c72016-06-21 12:28:20 -04002043static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002044{
Vivien Didelota935c052016-09-29 12:21:53 -04002045 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002046
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002047 err = mv88e6xxx_disable_ports(chip);
2048 if (err)
2049 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002050
Vivien Didelot309eca62016-12-05 17:30:26 -05002051 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002052
Vivien Didelot17e708b2016-12-05 17:30:27 -05002053 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002054}
2055
Vivien Didelot43145572017-03-11 16:12:59 -05002056static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002057 enum mv88e6xxx_frame_mode frame,
2058 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002059{
2060 int err;
2061
Vivien Didelot43145572017-03-11 16:12:59 -05002062 if (!chip->info->ops->port_set_frame_mode)
2063 return -EOPNOTSUPP;
2064
2065 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002066 if (err)
2067 return err;
2068
Vivien Didelot43145572017-03-11 16:12:59 -05002069 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2070 if (err)
2071 return err;
2072
2073 if (chip->info->ops->port_set_ether_type)
2074 return chip->info->ops->port_set_ether_type(chip, port, etype);
2075
2076 return 0;
2077}
2078
2079static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2080{
2081 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002082 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002083 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002084}
2085
2086static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2087{
2088 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002089 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002090 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002091}
2092
2093static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2094{
2095 return mv88e6xxx_set_port_mode(chip, port,
2096 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002097 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2098 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002099}
2100
2101static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2102{
2103 if (dsa_is_dsa_port(chip->ds, port))
2104 return mv88e6xxx_set_port_mode_dsa(chip, port);
2105
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002106 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002107 return mv88e6xxx_set_port_mode_normal(chip, port);
2108
2109 /* Setup CPU port mode depending on its supported tag format */
2110 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2111 return mv88e6xxx_set_port_mode_dsa(chip, port);
2112
2113 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2114 return mv88e6xxx_set_port_mode_edsa(chip, port);
2115
2116 return -EINVAL;
2117}
2118
Vivien Didelotea698f42017-03-11 16:12:50 -05002119static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2120{
2121 bool message = dsa_is_dsa_port(chip->ds, port);
2122
2123 return mv88e6xxx_port_set_message_port(chip, port, message);
2124}
2125
Vivien Didelot601aeed2017-03-11 16:13:00 -05002126static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2127{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002128 struct dsa_switch *ds = chip->ds;
2129 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002130
2131 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002132 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002133 if (chip->info->ops->port_set_egress_floods)
2134 return chip->info->ops->port_set_egress_floods(chip, port,
2135 flood, flood);
2136
2137 return 0;
2138}
2139
Andrew Lunn6d917822017-05-26 01:03:21 +02002140static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2141 bool on)
2142{
Vivien Didelot523a8902017-05-26 18:02:42 -04002143 if (chip->info->ops->serdes_power)
2144 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002145
Vivien Didelot523a8902017-05-26 18:02:42 -04002146 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002147}
2148
Vivien Didelotfa371c82017-12-05 15:34:10 -05002149static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2150{
2151 struct dsa_switch *ds = chip->ds;
2152 int upstream_port;
2153 int err;
2154
Vivien Didelot07073c72017-12-05 15:34:13 -05002155 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002156 if (chip->info->ops->port_set_upstream_port) {
2157 err = chip->info->ops->port_set_upstream_port(chip, port,
2158 upstream_port);
2159 if (err)
2160 return err;
2161 }
2162
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002163 if (port == upstream_port) {
2164 if (chip->info->ops->set_cpu_port) {
2165 err = chip->info->ops->set_cpu_port(chip,
2166 upstream_port);
2167 if (err)
2168 return err;
2169 }
2170
2171 if (chip->info->ops->set_egress_port) {
2172 err = chip->info->ops->set_egress_port(chip,
2173 upstream_port);
2174 if (err)
2175 return err;
2176 }
2177 }
2178
Vivien Didelotfa371c82017-12-05 15:34:10 -05002179 return 0;
2180}
2181
Vivien Didelotfad09c72016-06-21 12:28:20 -04002182static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002183{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002184 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002185 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002186 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002187
Andrew Lunn7b898462018-08-09 15:38:47 +02002188 chip->ports[port].chip = chip;
2189 chip->ports[port].port = port;
2190
Vivien Didelotd78343d2016-11-04 03:23:36 +01002191 /* MAC Forcing register: don't force link, speed, duplex or flow control
2192 * state to any particular values on physical ports, but force the CPU
2193 * port and all DSA ports to their maximum bandwidth and full duplex.
2194 */
2195 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2196 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2197 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002198 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002199 PHY_INTERFACE_MODE_NA);
2200 else
2201 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2202 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002203 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002204 PHY_INTERFACE_MODE_NA);
2205 if (err)
2206 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002207
2208 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2209 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2210 * tunneling, determine priority by looking at 802.1p and IP
2211 * priority fields (IP prio has precedence), and set STP state
2212 * to Forwarding.
2213 *
2214 * If this is the CPU link, use DSA or EDSA tagging depending
2215 * on which tagging mode was configured.
2216 *
2217 * If this is a link to another switch, use DSA tagging mode.
2218 *
2219 * If this is the upstream port for this switch, enable
2220 * forwarding of unknown unicasts and multicasts.
2221 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002222 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2223 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2224 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2225 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002226 if (err)
2227 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002228
Vivien Didelot601aeed2017-03-11 16:13:00 -05002229 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002230 if (err)
2231 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002232
Vivien Didelot601aeed2017-03-11 16:13:00 -05002233 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002234 if (err)
2235 return err;
2236
Andrew Lunn04aca992017-05-26 01:03:24 +02002237 /* Enable the SERDES interface for DSA and CPU ports. Normal
2238 * ports SERDES are enabled when the port is enabled, thus
2239 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002240 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002241 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2242 err = mv88e6xxx_serdes_power(chip, port, true);
2243 if (err)
2244 return err;
2245 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002246
Vivien Didelot8efdda42015-08-13 12:52:23 -04002247 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002248 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002249 * untagged frames on this port, do a destination address lookup on all
2250 * received packets as usual, disable ARP mirroring and don't send a
2251 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002252 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002253 err = mv88e6xxx_port_set_map_da(chip, port);
2254 if (err)
2255 return err;
2256
Vivien Didelotfa371c82017-12-05 15:34:10 -05002257 err = mv88e6xxx_setup_upstream_port(chip, port);
2258 if (err)
2259 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002260
Andrew Lunna23b2962017-02-04 20:15:28 +01002261 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002262 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002263 if (err)
2264 return err;
2265
Vivien Didelotcd782652017-06-08 18:34:13 -04002266 if (chip->info->ops->port_set_jumbo_size) {
2267 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002268 if (err)
2269 return err;
2270 }
2271
Andrew Lunn54d792f2015-05-06 01:09:47 +02002272 /* Port Association Vector: when learning source addresses
2273 * of packets, add the address to the address database using
2274 * a port bitmap that has only the bit for this port set and
2275 * the other bits clear.
2276 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002277 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002278 /* Disable learning for CPU port */
2279 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002280 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002281
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002282 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2283 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002284 if (err)
2285 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002286
2287 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002288 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2289 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002290 if (err)
2291 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002292
Vivien Didelot08984322017-06-08 18:34:12 -04002293 if (chip->info->ops->port_pause_limit) {
2294 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002295 if (err)
2296 return err;
2297 }
2298
Vivien Didelotc8c94892017-03-11 16:13:01 -05002299 if (chip->info->ops->port_disable_learn_limit) {
2300 err = chip->info->ops->port_disable_learn_limit(chip, port);
2301 if (err)
2302 return err;
2303 }
2304
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002305 if (chip->info->ops->port_disable_pri_override) {
2306 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002307 if (err)
2308 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002309 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002310
Andrew Lunnef0a7312016-12-03 04:35:16 +01002311 if (chip->info->ops->port_tag_remap) {
2312 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002313 if (err)
2314 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002315 }
2316
Andrew Lunnef70b112016-12-03 04:45:18 +01002317 if (chip->info->ops->port_egress_rate_limiting) {
2318 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002319 if (err)
2320 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002321 }
2322
Vivien Didelotea698f42017-03-11 16:12:50 -05002323 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002324 if (err)
2325 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002326
Vivien Didelot207afda2016-04-14 14:42:09 -04002327 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002328 * database, and allow bidirectional communication between the
2329 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002330 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002331 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002332 if (err)
2333 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002334
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002335 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002336 if (err)
2337 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002338
2339 /* Default VLAN ID and priority: don't set a default VLAN
2340 * ID, and set the default packet priority to zero.
2341 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002342 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002343}
2344
Andrew Lunn04aca992017-05-26 01:03:24 +02002345static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2346 struct phy_device *phydev)
2347{
2348 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002349 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002350
2351 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002352
Vivien Didelot523a8902017-05-26 18:02:42 -04002353 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002354
2355 if (!err && chip->info->ops->serdes_irq_setup)
2356 err = chip->info->ops->serdes_irq_setup(chip, port);
2357
Andrew Lunn04aca992017-05-26 01:03:24 +02002358 mutex_unlock(&chip->reg_lock);
2359
2360 return err;
2361}
2362
2363static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2364 struct phy_device *phydev)
2365{
2366 struct mv88e6xxx_chip *chip = ds->priv;
2367
2368 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002369
2370 if (chip->info->ops->serdes_irq_free)
2371 chip->info->ops->serdes_irq_free(chip, port);
2372
Vivien Didelot523a8902017-05-26 18:02:42 -04002373 if (mv88e6xxx_serdes_power(chip, port, false))
2374 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002375
Andrew Lunn04aca992017-05-26 01:03:24 +02002376 mutex_unlock(&chip->reg_lock);
2377}
2378
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002379static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2380 unsigned int ageing_time)
2381{
Vivien Didelot04bed142016-08-31 18:06:13 -04002382 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002383 int err;
2384
2385 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002386 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002387 mutex_unlock(&chip->reg_lock);
2388
2389 return err;
2390}
2391
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002392static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002393{
2394 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002395
Andrew Lunnde2273872016-11-21 23:27:01 +01002396 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002397 if (chip->info->ops->stats_set_histogram) {
2398 err = chip->info->ops->stats_set_histogram(chip);
2399 if (err)
2400 return err;
2401 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002402
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002403 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002404}
2405
Vivien Didelotf81ec902016-05-09 13:22:58 -04002406static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002407{
Vivien Didelot04bed142016-08-31 18:06:13 -04002408 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002409 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002410 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002411 int i;
2412
Vivien Didelotfad09c72016-06-21 12:28:20 -04002413 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002414 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002415
Vivien Didelotfad09c72016-06-21 12:28:20 -04002416 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002417
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002418 /* Cache the cmode of each port. */
2419 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2420 if (chip->info->ops->port_get_cmode) {
2421 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2422 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002423 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002424
2425 chip->ports[i].cmode = cmode;
2426 }
2427 }
2428
Vivien Didelot97299342016-07-18 20:45:30 -04002429 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002430 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002431 if (dsa_is_unused_port(ds, i))
2432 continue;
2433
Vivien Didelot97299342016-07-18 20:45:30 -04002434 err = mv88e6xxx_setup_port(chip, i);
2435 if (err)
2436 goto unlock;
2437 }
2438
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002439 err = mv88e6xxx_irl_setup(chip);
2440 if (err)
2441 goto unlock;
2442
Vivien Didelot04a69a12017-10-13 14:18:05 -04002443 err = mv88e6xxx_mac_setup(chip);
2444 if (err)
2445 goto unlock;
2446
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002447 err = mv88e6xxx_phy_setup(chip);
2448 if (err)
2449 goto unlock;
2450
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002451 err = mv88e6xxx_vtu_setup(chip);
2452 if (err)
2453 goto unlock;
2454
Vivien Didelot81228992017-03-30 17:37:08 -04002455 err = mv88e6xxx_pvt_setup(chip);
2456 if (err)
2457 goto unlock;
2458
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002459 err = mv88e6xxx_atu_setup(chip);
2460 if (err)
2461 goto unlock;
2462
Andrew Lunn87fa8862017-11-09 22:29:56 +01002463 err = mv88e6xxx_broadcast_setup(chip, 0);
2464 if (err)
2465 goto unlock;
2466
Vivien Didelot9e907d72017-07-17 13:03:43 -04002467 err = mv88e6xxx_pot_setup(chip);
2468 if (err)
2469 goto unlock;
2470
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002471 err = mv88e6xxx_rmu_setup(chip);
2472 if (err)
2473 goto unlock;
2474
Vivien Didelot51c901a2017-07-17 13:03:41 -04002475 err = mv88e6xxx_rsvd2cpu_setup(chip);
2476 if (err)
2477 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002478
Vivien Didelotb28f8722018-04-26 21:56:44 -04002479 err = mv88e6xxx_trunk_setup(chip);
2480 if (err)
2481 goto unlock;
2482
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002483 err = mv88e6xxx_devmap_setup(chip);
2484 if (err)
2485 goto unlock;
2486
Vivien Didelot93e18d62018-05-11 17:16:35 -04002487 err = mv88e6xxx_pri_setup(chip);
2488 if (err)
2489 goto unlock;
2490
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002491 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002492 if (chip->info->ptp_support) {
2493 err = mv88e6xxx_ptp_setup(chip);
2494 if (err)
2495 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002496
2497 err = mv88e6xxx_hwtstamp_setup(chip);
2498 if (err)
2499 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002500 }
2501
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002502 err = mv88e6xxx_stats_setup(chip);
2503 if (err)
2504 goto unlock;
2505
Vivien Didelot6b17e862015-08-13 12:52:18 -04002506unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002507 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002508
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002509 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002510}
2511
Vivien Didelote57e5e72016-08-15 17:19:00 -04002512static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002513{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002514 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2515 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002516 u16 val;
2517 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002518
Andrew Lunnee26a222017-01-24 14:53:48 +01002519 if (!chip->info->ops->phy_read)
2520 return -EOPNOTSUPP;
2521
Vivien Didelotfad09c72016-06-21 12:28:20 -04002522 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002523 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002524 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002525
Andrew Lunnda9f3302017-02-01 03:40:05 +01002526 if (reg == MII_PHYSID2) {
2527 /* Some internal PHYS don't have a model number. Use
2528 * the mv88e6390 family model number instead.
2529 */
2530 if (!(val & 0x3f0))
Vivien Didelot107fcc12017-06-12 12:37:36 -04002531 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002532 }
2533
Vivien Didelote57e5e72016-08-15 17:19:00 -04002534 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002535}
2536
Vivien Didelote57e5e72016-08-15 17:19:00 -04002537static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002538{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002539 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2540 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002541 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002542
Andrew Lunnee26a222017-01-24 14:53:48 +01002543 if (!chip->info->ops->phy_write)
2544 return -EOPNOTSUPP;
2545
Vivien Didelotfad09c72016-06-21 12:28:20 -04002546 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002547 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002548 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002549
2550 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002551}
2552
Vivien Didelotfad09c72016-06-21 12:28:20 -04002553static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002554 struct device_node *np,
2555 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002556{
2557 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002558 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002559 struct mii_bus *bus;
2560 int err;
2561
Andrew Lunn2510bab2018-02-22 01:51:49 +01002562 if (external) {
2563 mutex_lock(&chip->reg_lock);
2564 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2565 mutex_unlock(&chip->reg_lock);
2566
2567 if (err)
2568 return err;
2569 }
2570
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002571 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002572 if (!bus)
2573 return -ENOMEM;
2574
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002575 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002576 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002577 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002578 INIT_LIST_HEAD(&mdio_bus->list);
2579 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002580
Andrew Lunnb516d452016-06-04 21:17:06 +02002581 if (np) {
2582 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002583 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002584 } else {
2585 bus->name = "mv88e6xxx SMI";
2586 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2587 }
2588
2589 bus->read = mv88e6xxx_mdio_read;
2590 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002591 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002592
Andrew Lunn6f882842018-03-17 20:32:05 +01002593 if (!external) {
2594 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2595 if (err)
2596 return err;
2597 }
2598
Florian Fainelli00e798c2018-05-15 16:56:19 -07002599 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002600 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002601 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002602 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002603 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002604 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002605
2606 if (external)
2607 list_add_tail(&mdio_bus->list, &chip->mdios);
2608 else
2609 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002610
2611 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002612}
2613
Andrew Lunna3c53be52017-01-24 14:53:50 +01002614static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2615 { .compatible = "marvell,mv88e6xxx-mdio-external",
2616 .data = (void *)true },
2617 { },
2618};
2619
Andrew Lunn3126aee2017-12-07 01:05:57 +01002620static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2621
2622{
2623 struct mv88e6xxx_mdio_bus *mdio_bus;
2624 struct mii_bus *bus;
2625
2626 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2627 bus = mdio_bus->bus;
2628
Andrew Lunn6f882842018-03-17 20:32:05 +01002629 if (!mdio_bus->external)
2630 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2631
Andrew Lunn3126aee2017-12-07 01:05:57 +01002632 mdiobus_unregister(bus);
2633 }
2634}
2635
Andrew Lunna3c53be52017-01-24 14:53:50 +01002636static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2637 struct device_node *np)
2638{
2639 const struct of_device_id *match;
2640 struct device_node *child;
2641 int err;
2642
2643 /* Always register one mdio bus for the internal/default mdio
2644 * bus. This maybe represented in the device tree, but is
2645 * optional.
2646 */
2647 child = of_get_child_by_name(np, "mdio");
2648 err = mv88e6xxx_mdio_register(chip, child, false);
2649 if (err)
2650 return err;
2651
2652 /* Walk the device tree, and see if there are any other nodes
2653 * which say they are compatible with the external mdio
2654 * bus.
2655 */
2656 for_each_available_child_of_node(np, child) {
2657 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2658 if (match) {
2659 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002660 if (err) {
2661 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002662 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002663 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002664 }
2665 }
2666
2667 return 0;
2668}
2669
Vivien Didelot855b1932016-07-20 18:18:35 -04002670static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2671{
Vivien Didelot04bed142016-08-31 18:06:13 -04002672 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002673
2674 return chip->eeprom_len;
2675}
2676
Vivien Didelot855b1932016-07-20 18:18:35 -04002677static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2678 struct ethtool_eeprom *eeprom, u8 *data)
2679{
Vivien Didelot04bed142016-08-31 18:06:13 -04002680 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002681 int err;
2682
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002683 if (!chip->info->ops->get_eeprom)
2684 return -EOPNOTSUPP;
2685
Vivien Didelot855b1932016-07-20 18:18:35 -04002686 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002687 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002688 mutex_unlock(&chip->reg_lock);
2689
2690 if (err)
2691 return err;
2692
2693 eeprom->magic = 0xc3ec4951;
2694
2695 return 0;
2696}
2697
Vivien Didelot855b1932016-07-20 18:18:35 -04002698static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2699 struct ethtool_eeprom *eeprom, u8 *data)
2700{
Vivien Didelot04bed142016-08-31 18:06:13 -04002701 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002702 int err;
2703
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002704 if (!chip->info->ops->set_eeprom)
2705 return -EOPNOTSUPP;
2706
Vivien Didelot855b1932016-07-20 18:18:35 -04002707 if (eeprom->magic != 0xc3ec4951)
2708 return -EINVAL;
2709
2710 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002711 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002712 mutex_unlock(&chip->reg_lock);
2713
2714 return err;
2715}
2716
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002717static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002718 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002719 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2720 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002721 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002722 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002723 .phy_read = mv88e6185_phy_ppu_read,
2724 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002725 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002726 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002727 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002728 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002729 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002730 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002731 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002732 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002733 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002734 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002735 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002736 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002737 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002738 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002739 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002740 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2741 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002742 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002743 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2744 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002745 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002746 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002747 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002748 .ppu_enable = mv88e6185_g1_ppu_enable,
2749 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002750 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002751 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002752 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002753 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002754 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002755};
2756
2757static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002758 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002759 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2760 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002761 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002762 .phy_read = mv88e6185_phy_ppu_read,
2763 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002764 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002765 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002766 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002767 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002768 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002769 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002770 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002771 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002772 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002773 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002774 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2775 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002776 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002777 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002778 .ppu_enable = mv88e6185_g1_ppu_enable,
2779 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002780 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002781 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002782 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002783 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002784};
2785
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002786static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002787 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002788 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2789 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002790 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002791 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2792 .phy_read = mv88e6xxx_g2_smi_phy_read,
2793 .phy_write = mv88e6xxx_g2_smi_phy_write,
2794 .port_set_link = mv88e6xxx_port_set_link,
2795 .port_set_duplex = mv88e6xxx_port_set_duplex,
2796 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002797 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002798 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002799 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002800 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002801 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002802 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002803 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002804 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002805 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002806 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002807 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002808 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002809 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002810 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2811 .stats_get_strings = mv88e6095_stats_get_strings,
2812 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002813 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2814 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002815 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002816 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002817 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002818 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002819 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002820 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002821 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002822 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002823};
2824
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002825static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002826 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002827 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2828 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002829 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002830 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002831 .phy_read = mv88e6xxx_g2_smi_phy_read,
2832 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002833 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002834 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002835 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002836 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002837 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002838 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002839 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002840 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002841 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002842 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002843 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002844 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2845 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002846 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002847 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2848 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002849 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002850 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002851 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002852 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002853 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002854 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002855 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002856};
2857
2858static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002859 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002860 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2861 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002862 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002863 .phy_read = mv88e6185_phy_ppu_read,
2864 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002865 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002866 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002867 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002868 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002869 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002870 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002871 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002872 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002873 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002874 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002875 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002876 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002877 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002878 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002879 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002880 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002881 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2882 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002883 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002884 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2885 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002886 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002887 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002888 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04002889 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002890 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002891 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002892 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002893 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002894 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002895};
2896
Vivien Didelot990e27b2017-03-28 13:50:32 -04002897static const struct mv88e6xxx_ops mv88e6141_ops = {
2898 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002899 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2900 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002901 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002902 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
2903 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
2904 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2905 .phy_read = mv88e6xxx_g2_smi_phy_read,
2906 .phy_write = mv88e6xxx_g2_smi_phy_write,
2907 .port_set_link = mv88e6xxx_port_set_link,
2908 .port_set_duplex = mv88e6xxx_port_set_duplex,
2909 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02002910 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002911 .port_tag_remap = mv88e6095_port_tag_remap,
2912 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
2913 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
2914 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002915 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002916 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002917 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002918 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
2919 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002920 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002921 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002922 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002923 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002924 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
2925 .stats_get_strings = mv88e6320_stats_get_strings,
2926 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002927 .set_cpu_port = mv88e6390_g1_set_cpu_port,
2928 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002929 .watchdog_ops = &mv88e6390_watchdog_ops,
2930 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002931 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002932 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002933 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002934 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02002935 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01002936 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02002937 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04002938};
2939
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002940static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002941 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002942 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2943 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002944 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002945 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002946 .phy_read = mv88e6xxx_g2_smi_phy_read,
2947 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002948 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002949 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002950 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002951 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002952 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002953 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002954 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002955 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002956 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002957 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002958 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002959 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002960 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002961 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002962 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002963 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002964 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2965 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002966 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002967 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2968 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002969 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002970 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002971 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002972 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002973 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002974 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02002975 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02002976 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02002977 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002978};
2979
2980static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002981 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002982 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2983 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002984 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002985 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01002986 .phy_read = mv88e6165_phy_read,
2987 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002988 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002989 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002990 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002991 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002992 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002993 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002994 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002995 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002996 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002997 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2998 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002999 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003000 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3001 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003002 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003003 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003004 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003005 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003006 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003007 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003008 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003009 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003010 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003011};
3012
3013static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003014 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003015 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3016 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003017 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003018 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003019 .phy_read = mv88e6xxx_g2_smi_phy_read,
3020 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003021 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003022 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003023 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003024 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003025 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003026 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003027 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003028 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003029 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003030 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003031 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003032 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003033 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003034 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003035 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003036 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003037 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003038 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3039 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003040 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003041 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3042 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003043 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003044 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003045 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003046 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003047 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003048 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003049 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003050};
3051
3052static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003053 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003054 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3055 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003056 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003057 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3058 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003059 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003060 .phy_read = mv88e6xxx_g2_smi_phy_read,
3061 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003062 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003063 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003064 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003065 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003066 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003067 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003068 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003069 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003070 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003071 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003072 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003073 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003074 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003075 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003076 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003077 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003078 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003079 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3080 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003081 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003082 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3083 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003084 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003085 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003086 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003087 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003088 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003089 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003090 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003091 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003092 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003093 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003094};
3095
3096static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003097 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003098 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3099 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003100 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003101 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003102 .phy_read = mv88e6xxx_g2_smi_phy_read,
3103 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003104 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003105 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003106 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003107 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003108 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003109 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003110 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003111 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003112 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003113 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003114 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003115 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003116 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003117 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003118 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003119 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003120 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003121 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3122 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003123 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003124 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3125 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003126 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003127 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003128 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003129 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003130 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003131 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003132 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003133};
3134
3135static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003136 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003137 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3138 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003139 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003140 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3141 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003142 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003143 .phy_read = mv88e6xxx_g2_smi_phy_read,
3144 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003145 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003146 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003147 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003148 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003149 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003150 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003151 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003152 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003153 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003154 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003155 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003156 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003157 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003158 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003159 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003160 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003161 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003162 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3163 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003164 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003165 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3166 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003167 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003168 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003169 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003170 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003171 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003172 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003173 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003174 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003175 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3176 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003177 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003178 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003179};
3180
3181static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003182 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003183 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3184 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003185 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003186 .phy_read = mv88e6185_phy_ppu_read,
3187 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003188 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003189 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003190 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003191 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003192 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003193 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003194 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003195 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003196 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003197 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003198 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003199 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003200 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3201 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003202 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003203 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3204 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003205 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003206 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003207 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003208 .ppu_enable = mv88e6185_g1_ppu_enable,
3209 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003210 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003211 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003212 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003213 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003214};
3215
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003216static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003217 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003218 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003219 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3220 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003221 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3222 .phy_read = mv88e6xxx_g2_smi_phy_read,
3223 .phy_write = mv88e6xxx_g2_smi_phy_write,
3224 .port_set_link = mv88e6xxx_port_set_link,
3225 .port_set_duplex = mv88e6xxx_port_set_duplex,
3226 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3227 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003228 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003229 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003230 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003231 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003232 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003233 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003234 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003235 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003236 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003237 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003238 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003239 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3240 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003241 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003242 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3243 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003244 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003245 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003246 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003247 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003248 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003249 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3250 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003251 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003252 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3253 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003254 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003255 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003256};
3257
3258static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003259 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003260 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003261 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3262 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003263 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3264 .phy_read = mv88e6xxx_g2_smi_phy_read,
3265 .phy_write = mv88e6xxx_g2_smi_phy_write,
3266 .port_set_link = mv88e6xxx_port_set_link,
3267 .port_set_duplex = mv88e6xxx_port_set_duplex,
3268 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3269 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003270 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003271 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003272 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003273 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003274 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003275 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003276 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003277 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003278 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003279 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003280 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003281 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3282 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003283 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003284 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3285 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003286 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003287 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003288 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003289 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003290 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003291 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3292 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003293 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003294 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3295 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003296 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003297 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003298};
3299
3300static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003301 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003302 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003303 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3304 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003305 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3306 .phy_read = mv88e6xxx_g2_smi_phy_read,
3307 .phy_write = mv88e6xxx_g2_smi_phy_write,
3308 .port_set_link = mv88e6xxx_port_set_link,
3309 .port_set_duplex = mv88e6xxx_port_set_duplex,
3310 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3311 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003312 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003313 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003314 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003315 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003316 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003317 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003318 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003319 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003320 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003321 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003322 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003323 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3324 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003325 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003326 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3327 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003328 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003329 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003330 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003331 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003332 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003333 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3334 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003335 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003336 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3337 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003338 .avb_ops = &mv88e6390_avb_ops,
3339 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003340 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003341};
3342
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003343static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003344 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003345 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3346 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003347 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003348 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3349 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003350 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003351 .phy_read = mv88e6xxx_g2_smi_phy_read,
3352 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003353 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003354 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003355 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003356 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003357 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003358 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003359 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003360 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003361 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003362 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003363 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003364 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003365 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003366 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003367 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003368 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003369 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003370 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3371 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003372 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003373 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3374 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003375 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003376 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003377 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003378 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003379 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003380 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003381 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003382 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003383 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3384 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003385 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003386 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003387 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003388 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003389};
3390
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003391static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003392 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003393 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003394 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3395 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003396 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3397 .phy_read = mv88e6xxx_g2_smi_phy_read,
3398 .phy_write = mv88e6xxx_g2_smi_phy_write,
3399 .port_set_link = mv88e6xxx_port_set_link,
3400 .port_set_duplex = mv88e6xxx_port_set_duplex,
3401 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3402 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003403 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003404 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003405 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003406 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003407 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003408 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003409 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003410 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003411 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003412 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003413 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003414 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003415 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3416 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003417 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003418 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3419 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003420 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003421 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003422 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003423 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003424 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003425 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3426 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003427 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003428 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3429 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003430 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003431 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003432 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003433 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003434};
3435
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003436static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003437 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003438 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3439 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003440 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003441 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3442 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003443 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003444 .phy_read = mv88e6xxx_g2_smi_phy_read,
3445 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003446 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003447 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003448 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003449 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003450 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003451 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003452 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003453 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003454 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003455 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003456 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003457 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003458 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003459 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003460 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003461 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003462 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3463 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003464 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003465 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3466 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003467 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003468 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003469 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003470 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003471 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003472 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003473 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003474 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003475 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003476};
3477
3478static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003479 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003480 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3481 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003482 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003483 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3484 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003485 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003486 .phy_read = mv88e6xxx_g2_smi_phy_read,
3487 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003488 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003489 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003490 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003491 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003492 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003493 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003494 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003495 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003496 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003497 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003498 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003499 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003500 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003501 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003502 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003503 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003504 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3505 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003506 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003507 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3508 .set_egress_port = mv88e6095_g1_set_egress_port,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003509 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003510 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003511 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003512 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003513 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003514 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003515 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003516};
3517
Vivien Didelot16e329a2017-03-28 13:50:33 -04003518static const struct mv88e6xxx_ops mv88e6341_ops = {
3519 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003520 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3521 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003522 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003523 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3524 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3525 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3526 .phy_read = mv88e6xxx_g2_smi_phy_read,
3527 .phy_write = mv88e6xxx_g2_smi_phy_write,
3528 .port_set_link = mv88e6xxx_port_set_link,
3529 .port_set_duplex = mv88e6xxx_port_set_duplex,
3530 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003531 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003532 .port_tag_remap = mv88e6095_port_tag_remap,
3533 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3534 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3535 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003536 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003537 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003538 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003539 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3540 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003541 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003542 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003543 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003544 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003545 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3546 .stats_get_strings = mv88e6320_stats_get_strings,
3547 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003548 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3549 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003550 .watchdog_ops = &mv88e6390_watchdog_ops,
3551 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003552 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003553 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003554 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003555 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003556 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003557 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003558 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003559 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003560 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003561};
3562
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003563static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003564 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003565 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3566 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003567 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003568 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003569 .phy_read = mv88e6xxx_g2_smi_phy_read,
3570 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003571 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003572 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003573 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003574 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003575 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003576 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003577 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003578 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003579 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003580 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003581 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003582 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003583 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003584 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003585 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003586 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003587 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003588 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3589 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003590 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003591 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3592 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003593 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003594 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003595 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003596 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003597 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003598 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003599 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003600};
3601
3602static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003603 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003604 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3605 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003606 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003607 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003608 .phy_read = mv88e6xxx_g2_smi_phy_read,
3609 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003610 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003611 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003612 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003613 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003614 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003615 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003616 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003617 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003618 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003619 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003620 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003621 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003622 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003623 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003624 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003625 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003626 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003627 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3628 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003629 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003630 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3631 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003632 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003633 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003634 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003635 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003636 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003637 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003638 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003639 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003640 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003641};
3642
3643static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003644 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003645 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3646 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003647 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003648 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3649 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003650 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003651 .phy_read = mv88e6xxx_g2_smi_phy_read,
3652 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003653 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003654 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003655 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003656 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003657 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003658 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003659 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003660 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003661 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003662 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003663 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003664 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003665 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003666 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003667 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003668 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003669 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003670 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3671 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003672 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003673 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3674 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003675 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003676 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003677 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003678 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003679 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003680 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003681 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003682 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003683 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3684 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003685 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003686 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003687 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003688 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3689 .serdes_get_strings = mv88e6352_serdes_get_strings,
3690 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003691 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003692};
3693
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003694static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003695 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003696 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003697 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3698 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003699 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3700 .phy_read = mv88e6xxx_g2_smi_phy_read,
3701 .phy_write = mv88e6xxx_g2_smi_phy_write,
3702 .port_set_link = mv88e6xxx_port_set_link,
3703 .port_set_duplex = mv88e6xxx_port_set_duplex,
3704 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3705 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003706 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003707 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003708 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003709 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003710 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003711 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003712 .port_pause_limit = mv88e6390_port_pause_limit,
Andrew Lunnf39908d2017-02-04 20:02:50 +01003713 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003714 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003715 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003716 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003717 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003718 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003719 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003720 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3721 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003722 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003723 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3724 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003725 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003726 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003727 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003728 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003729 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003730 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3731 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003732 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003733 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3734 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003735 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003736 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003737 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003738 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003739};
3740
3741static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003742 /* MV88E6XXX_FAMILY_6390 */
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003743 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003744 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3745 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003746 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3747 .phy_read = mv88e6xxx_g2_smi_phy_read,
3748 .phy_write = mv88e6xxx_g2_smi_phy_write,
3749 .port_set_link = mv88e6xxx_port_set_link,
3750 .port_set_duplex = mv88e6xxx_port_set_duplex,
3751 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3752 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003753 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003754 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003755 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003756 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003757 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003758 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003759 .port_pause_limit = mv88e6390_port_pause_limit,
Martin Hundebøllbb0a2672017-07-19 08:17:02 +02003760 .port_set_cmode = mv88e6390x_port_set_cmode,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003761 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003762 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003763 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003764 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003765 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003766 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003767 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3768 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003769 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003770 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3771 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003772 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003773 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003774 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003775 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003776 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003777 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3778 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003779 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003780 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3781 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003782 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003783 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003784 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003785 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003786};
3787
Vivien Didelotf81ec902016-05-09 13:22:58 -04003788static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3789 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003790 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003791 .family = MV88E6XXX_FAMILY_6097,
3792 .name = "Marvell 88E6085",
3793 .num_databases = 4096,
3794 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003795 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003796 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003797 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003798 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003799 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003800 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003801 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003802 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003803 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003804 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003805 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003806 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003807 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003808 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003809 },
3810
3811 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003812 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003813 .family = MV88E6XXX_FAMILY_6095,
3814 .name = "Marvell 88E6095/88E6095F",
3815 .num_databases = 256,
3816 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003817 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003818 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003819 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003820 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003821 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003822 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003823 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003824 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003825 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003826 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003827 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003828 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003829 },
3830
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003831 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003832 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003833 .family = MV88E6XXX_FAMILY_6097,
3834 .name = "Marvell 88E6097/88E6097F",
3835 .num_databases = 4096,
3836 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003837 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003838 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003839 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003840 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003841 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003842 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003843 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003844 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003845 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003846 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003847 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003848 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003849 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003850 .ops = &mv88e6097_ops,
3851 },
3852
Vivien Didelotf81ec902016-05-09 13:22:58 -04003853 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003854 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003855 .family = MV88E6XXX_FAMILY_6165,
3856 .name = "Marvell 88E6123",
3857 .num_databases = 4096,
3858 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003859 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003860 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003861 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003862 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003863 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003864 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003865 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003866 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003867 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003868 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003869 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003870 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003871 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003872 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003873 },
3874
3875 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003876 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003877 .family = MV88E6XXX_FAMILY_6185,
3878 .name = "Marvell 88E6131",
3879 .num_databases = 256,
3880 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01003881 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003882 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003883 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003884 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003885 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003886 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003887 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003888 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05003889 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003890 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003891 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003892 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003893 },
3894
Vivien Didelot990e27b2017-03-28 13:50:32 -04003895 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003896 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003897 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01003898 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04003899 .num_databases = 4096,
3900 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003901 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003902 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003903 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003904 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003905 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003906 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003907 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003908 .age_time_coeff = 3750,
3909 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01003910 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003911 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04003912 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003913 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003914 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003915 .ops = &mv88e6141_ops,
3916 },
3917
Vivien Didelotf81ec902016-05-09 13:22:58 -04003918 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003919 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003920 .family = MV88E6XXX_FAMILY_6165,
3921 .name = "Marvell 88E6161",
3922 .num_databases = 4096,
3923 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003924 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003925 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003926 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003927 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003928 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003929 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003930 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003931 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003932 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003933 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003934 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003935 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02003936 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003937 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003938 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003939 },
3940
3941 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003942 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003943 .family = MV88E6XXX_FAMILY_6165,
3944 .name = "Marvell 88E6165",
3945 .num_databases = 4096,
3946 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01003947 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003948 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003949 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003950 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003951 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003952 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003953 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003954 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003955 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003956 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003957 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003958 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003959 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02003960 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003961 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003962 },
3963
3964 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003965 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003966 .family = MV88E6XXX_FAMILY_6351,
3967 .name = "Marvell 88E6171",
3968 .num_databases = 4096,
3969 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003970 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003971 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003972 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003973 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003974 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003975 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003976 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003977 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003978 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003979 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003980 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003981 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003982 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003983 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003984 },
3985
3986 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003987 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003988 .family = MV88E6XXX_FAMILY_6352,
3989 .name = "Marvell 88E6172",
3990 .num_databases = 4096,
3991 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01003992 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003993 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003994 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003995 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003996 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003997 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003998 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003999 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004000 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004001 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004002 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004003 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004004 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004005 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004006 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004007 },
4008
4009 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004010 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004011 .family = MV88E6XXX_FAMILY_6351,
4012 .name = "Marvell 88E6175",
4013 .num_databases = 4096,
4014 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004015 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004016 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004017 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004018 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004019 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004020 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004021 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004022 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004023 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004024 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004025 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004026 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004027 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004028 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004029 },
4030
4031 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004032 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004033 .family = MV88E6XXX_FAMILY_6352,
4034 .name = "Marvell 88E6176",
4035 .num_databases = 4096,
4036 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004037 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004038 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004039 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004040 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004041 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004042 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004043 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004044 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004045 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004046 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004047 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004048 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004049 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004050 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004051 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004052 },
4053
4054 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004055 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004056 .family = MV88E6XXX_FAMILY_6185,
4057 .name = "Marvell 88E6185",
4058 .num_databases = 256,
4059 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004060 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004061 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004062 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004063 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004064 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004065 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004066 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004067 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004068 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004069 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004070 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004071 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004072 },
4073
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004074 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004075 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004076 .family = MV88E6XXX_FAMILY_6390,
4077 .name = "Marvell 88E6190",
4078 .num_databases = 4096,
4079 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004080 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004081 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004082 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004083 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004084 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004085 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004086 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004087 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004088 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004089 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004090 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004091 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004092 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004093 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004094 .ops = &mv88e6190_ops,
4095 },
4096
4097 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004098 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004099 .family = MV88E6XXX_FAMILY_6390,
4100 .name = "Marvell 88E6190X",
4101 .num_databases = 4096,
4102 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004103 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004104 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004105 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004106 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004107 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004108 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004109 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004110 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004111 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004112 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004113 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004114 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004115 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004116 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004117 .ops = &mv88e6190x_ops,
4118 },
4119
4120 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004121 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004122 .family = MV88E6XXX_FAMILY_6390,
4123 .name = "Marvell 88E6191",
4124 .num_databases = 4096,
4125 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004126 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004127 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004128 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004129 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004130 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004131 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004132 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004133 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004134 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004135 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004136 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004137 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004138 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004139 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004140 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004141 },
4142
Vivien Didelotf81ec902016-05-09 13:22:58 -04004143 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004144 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004145 .family = MV88E6XXX_FAMILY_6352,
4146 .name = "Marvell 88E6240",
4147 .num_databases = 4096,
4148 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004149 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004150 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004151 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004152 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004153 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004154 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004155 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004156 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004157 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004158 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004159 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004160 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004161 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004162 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004163 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004164 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004165 },
4166
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004167 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004168 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004169 .family = MV88E6XXX_FAMILY_6390,
4170 .name = "Marvell 88E6290",
4171 .num_databases = 4096,
4172 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004173 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004174 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004175 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004176 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004177 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004178 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004179 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004180 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004181 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004182 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004183 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004184 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004185 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004186 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004187 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004188 .ops = &mv88e6290_ops,
4189 },
4190
Vivien Didelotf81ec902016-05-09 13:22:58 -04004191 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004192 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004193 .family = MV88E6XXX_FAMILY_6320,
4194 .name = "Marvell 88E6320",
4195 .num_databases = 4096,
4196 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004197 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004198 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004199 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004200 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004201 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004202 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004203 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004204 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004205 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004206 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004207 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004208 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004209 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004210 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004211 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004212 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004213 },
4214
4215 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004216 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004217 .family = MV88E6XXX_FAMILY_6320,
4218 .name = "Marvell 88E6321",
4219 .num_databases = 4096,
4220 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004221 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004222 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004223 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004224 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004225 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004226 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004227 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004228 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004229 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004230 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004231 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004232 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004233 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004234 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004235 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004236 },
4237
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004238 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004239 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004240 .family = MV88E6XXX_FAMILY_6341,
4241 .name = "Marvell 88E6341",
4242 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004243 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004244 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004245 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004246 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004247 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004248 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004249 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004250 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004251 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004252 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004253 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004254 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004255 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004256 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004257 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004258 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004259 .ops = &mv88e6341_ops,
4260 },
4261
Vivien Didelotf81ec902016-05-09 13:22:58 -04004262 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004263 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004264 .family = MV88E6XXX_FAMILY_6351,
4265 .name = "Marvell 88E6350",
4266 .num_databases = 4096,
4267 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004268 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004269 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004270 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004271 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004272 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004273 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004274 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004275 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004276 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004277 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004278 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004279 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004280 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004281 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004282 },
4283
4284 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004285 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004286 .family = MV88E6XXX_FAMILY_6351,
4287 .name = "Marvell 88E6351",
4288 .num_databases = 4096,
4289 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004290 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004291 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004292 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004293 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004294 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004295 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004296 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004297 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004298 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004299 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004300 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004301 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004302 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004303 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004304 },
4305
4306 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004307 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004308 .family = MV88E6XXX_FAMILY_6352,
4309 .name = "Marvell 88E6352",
4310 .num_databases = 4096,
4311 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004312 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004313 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004314 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004315 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004316 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004317 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004318 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004319 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004320 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004321 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004322 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004323 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004324 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004325 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004326 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004327 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004328 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004329 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004330 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004331 .family = MV88E6XXX_FAMILY_6390,
4332 .name = "Marvell 88E6390",
4333 .num_databases = 4096,
4334 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004335 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004336 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004337 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004338 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004339 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004340 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004341 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004342 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004343 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004344 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004345 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004346 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004347 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004348 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004349 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004350 .ops = &mv88e6390_ops,
4351 },
4352 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004353 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004354 .family = MV88E6XXX_FAMILY_6390,
4355 .name = "Marvell 88E6390X",
4356 .num_databases = 4096,
4357 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004358 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004359 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004360 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004361 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004362 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004363 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004364 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004365 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004366 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004367 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004368 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004369 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004370 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004371 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004372 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004373 .ops = &mv88e6390x_ops,
4374 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004375};
4376
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004377static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004378{
Vivien Didelota439c062016-04-17 13:23:58 -04004379 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004380
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004381 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4382 if (mv88e6xxx_table[i].prod_num == prod_num)
4383 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004384
Vivien Didelotb9b37712015-10-30 19:39:48 -04004385 return NULL;
4386}
4387
Vivien Didelotfad09c72016-06-21 12:28:20 -04004388static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004389{
4390 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004391 unsigned int prod_num, rev;
4392 u16 id;
4393 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004394
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004395 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004396 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004397 mutex_unlock(&chip->reg_lock);
4398 if (err)
4399 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004400
Vivien Didelot107fcc12017-06-12 12:37:36 -04004401 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4402 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004403
4404 info = mv88e6xxx_lookup_info(prod_num);
4405 if (!info)
4406 return -ENODEV;
4407
Vivien Didelotcaac8542016-06-20 13:14:09 -04004408 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004409 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004410
Vivien Didelotca070c12016-09-02 14:45:34 -04004411 err = mv88e6xxx_g2_require(chip);
4412 if (err)
4413 return err;
4414
Vivien Didelotfad09c72016-06-21 12:28:20 -04004415 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4416 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004417
4418 return 0;
4419}
4420
Vivien Didelotfad09c72016-06-21 12:28:20 -04004421static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004422{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004423 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004424
Vivien Didelotfad09c72016-06-21 12:28:20 -04004425 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4426 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004427 return NULL;
4428
Vivien Didelotfad09c72016-06-21 12:28:20 -04004429 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004430
Vivien Didelotfad09c72016-06-21 12:28:20 -04004431 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004432 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004433
Vivien Didelotfad09c72016-06-21 12:28:20 -04004434 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004435}
4436
Vivien Didelotfad09c72016-06-21 12:28:20 -04004437static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004438 struct mii_bus *bus, int sw_addr)
4439{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004440 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004441 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004442 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004443 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004444 else
4445 return -EINVAL;
4446
Vivien Didelotfad09c72016-06-21 12:28:20 -04004447 chip->bus = bus;
4448 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004449
4450 return 0;
4451}
4452
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004453static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4454 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004455{
Vivien Didelot04bed142016-08-31 18:06:13 -04004456 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004457
Andrew Lunn443d5a12016-12-03 04:35:18 +01004458 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004459}
4460
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004461#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004462static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4463 struct device *host_dev, int sw_addr,
4464 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004465{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004466 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004467 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004468 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004469
Vivien Didelota439c062016-04-17 13:23:58 -04004470 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004471 if (!bus)
4472 return NULL;
4473
Vivien Didelotfad09c72016-06-21 12:28:20 -04004474 chip = mv88e6xxx_alloc_chip(dsa_dev);
4475 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004476 return NULL;
4477
Vivien Didelotcaac8542016-06-20 13:14:09 -04004478 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004479 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004480
Vivien Didelotfad09c72016-06-21 12:28:20 -04004481 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004482 if (err)
4483 goto free;
4484
Vivien Didelotfad09c72016-06-21 12:28:20 -04004485 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004486 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004487 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004488
Andrew Lunndc30c352016-10-16 19:56:49 +02004489 mutex_lock(&chip->reg_lock);
4490 err = mv88e6xxx_switch_reset(chip);
4491 mutex_unlock(&chip->reg_lock);
4492 if (err)
4493 goto free;
4494
Vivien Didelote57e5e72016-08-15 17:19:00 -04004495 mv88e6xxx_phy_init(chip);
4496
Andrew Lunna3c53be52017-01-24 14:53:50 +01004497 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004498 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004499 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004500
Vivien Didelotfad09c72016-06-21 12:28:20 -04004501 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004502
Vivien Didelotfad09c72016-06-21 12:28:20 -04004503 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004504free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004505 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004506
4507 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004508}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004509#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004510
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004511static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004512 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004513{
4514 /* We don't need any dynamic resource from the kernel (yet),
4515 * so skip the prepare phase.
4516 */
4517
4518 return 0;
4519}
4520
4521static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004522 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004523{
Vivien Didelot04bed142016-08-31 18:06:13 -04004524 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004525
4526 mutex_lock(&chip->reg_lock);
4527 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004528 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004529 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4530 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004531 mutex_unlock(&chip->reg_lock);
4532}
4533
4534static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4535 const struct switchdev_obj_port_mdb *mdb)
4536{
Vivien Didelot04bed142016-08-31 18:06:13 -04004537 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004538 int err;
4539
4540 mutex_lock(&chip->reg_lock);
4541 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004542 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004543 mutex_unlock(&chip->reg_lock);
4544
4545 return err;
4546}
4547
Florian Fainellia82f67a2017-01-08 14:52:08 -08004548static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004549#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004550 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004551#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004552 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004553 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004554 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004555 .phylink_validate = mv88e6xxx_validate,
4556 .phylink_mac_link_state = mv88e6xxx_link_state,
4557 .phylink_mac_config = mv88e6xxx_mac_config,
4558 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4559 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004560 .get_strings = mv88e6xxx_get_strings,
4561 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4562 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004563 .port_enable = mv88e6xxx_port_enable,
4564 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004565 .get_mac_eee = mv88e6xxx_get_mac_eee,
4566 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004567 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004568 .get_eeprom = mv88e6xxx_get_eeprom,
4569 .set_eeprom = mv88e6xxx_set_eeprom,
4570 .get_regs_len = mv88e6xxx_get_regs_len,
4571 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004572 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004573 .port_bridge_join = mv88e6xxx_port_bridge_join,
4574 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4575 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004576 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004577 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4578 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4579 .port_vlan_add = mv88e6xxx_port_vlan_add,
4580 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004581 .port_fdb_add = mv88e6xxx_port_fdb_add,
4582 .port_fdb_del = mv88e6xxx_port_fdb_del,
4583 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004584 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4585 .port_mdb_add = mv88e6xxx_port_mdb_add,
4586 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004587 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4588 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004589 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4590 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4591 .port_txtstamp = mv88e6xxx_port_txtstamp,
4592 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4593 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004594};
4595
Florian Fainelliab3d4082017-01-08 14:52:07 -08004596static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4597 .ops = &mv88e6xxx_switch_ops,
4598};
4599
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004600static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004601{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004602 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004603 struct dsa_switch *ds;
4604
Vivien Didelot73b12042017-03-30 17:37:10 -04004605 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004606 if (!ds)
4607 return -ENOMEM;
4608
Vivien Didelotfad09c72016-06-21 12:28:20 -04004609 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004610 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004611 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004612 ds->ageing_time_min = chip->info->age_time_coeff;
4613 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004614
4615 dev_set_drvdata(dev, ds);
4616
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004617 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004618}
4619
Vivien Didelotfad09c72016-06-21 12:28:20 -04004620static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004621{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004622 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004623}
4624
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004625static const void *pdata_device_get_match_data(struct device *dev)
4626{
4627 const struct of_device_id *matches = dev->driver->of_match_table;
4628 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4629
4630 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4631 matches++) {
4632 if (!strcmp(pdata->compatible, matches->compatible))
4633 return matches->data;
4634 }
4635 return NULL;
4636}
4637
Vivien Didelot57d32312016-06-20 13:13:58 -04004638static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004639{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004640 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004641 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004642 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004643 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004644 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004645 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004646 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004647
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004648 if (!np && !pdata)
4649 return -EINVAL;
4650
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004651 if (np)
4652 compat_info = of_device_get_match_data(dev);
4653
4654 if (pdata) {
4655 compat_info = pdata_device_get_match_data(dev);
4656
4657 if (!pdata->netdev)
4658 return -EINVAL;
4659
4660 for (port = 0; port < DSA_MAX_PORTS; port++) {
4661 if (!(pdata->enabled_ports & (1 << port)))
4662 continue;
4663 if (strcmp(pdata->cd.port_names[port], "cpu"))
4664 continue;
4665 pdata->cd.netdev[port] = &pdata->netdev->dev;
4666 break;
4667 }
4668 }
4669
Vivien Didelotcaac8542016-06-20 13:14:09 -04004670 if (!compat_info)
4671 return -EINVAL;
4672
Vivien Didelotfad09c72016-06-21 12:28:20 -04004673 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004674 if (!chip) {
4675 err = -ENOMEM;
4676 goto out;
4677 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004678
Vivien Didelotfad09c72016-06-21 12:28:20 -04004679 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004680
Vivien Didelotfad09c72016-06-21 12:28:20 -04004681 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004682 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004683 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004684
Andrew Lunnb4308f02016-11-21 23:26:55 +01004685 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004686 if (IS_ERR(chip->reset)) {
4687 err = PTR_ERR(chip->reset);
4688 goto out;
4689 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004690
Vivien Didelotfad09c72016-06-21 12:28:20 -04004691 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004692 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004693 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004694
Vivien Didelote57e5e72016-08-15 17:19:00 -04004695 mv88e6xxx_phy_init(chip);
4696
Andrew Lunn00baabe2018-05-19 22:31:35 +02004697 if (chip->info->ops->get_eeprom) {
4698 if (np)
4699 of_property_read_u32(np, "eeprom-length",
4700 &chip->eeprom_len);
4701 else
4702 chip->eeprom_len = pdata->eeprom_len;
4703 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004704
Andrew Lunndc30c352016-10-16 19:56:49 +02004705 mutex_lock(&chip->reg_lock);
4706 err = mv88e6xxx_switch_reset(chip);
4707 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004708 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004709 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004710
Andrew Lunndc30c352016-10-16 19:56:49 +02004711 chip->irq = of_irq_get(np, 0);
4712 if (chip->irq == -EPROBE_DEFER) {
4713 err = chip->irq;
4714 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004715 }
4716
Andrew Lunn294d7112018-02-22 22:58:32 +01004717 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004718 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004719 * controllers
4720 */
4721 mutex_lock(&chip->reg_lock);
4722 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004723 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004724 else
4725 err = mv88e6xxx_irq_poll_setup(chip);
4726 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004727
Andrew Lunn294d7112018-02-22 22:58:32 +01004728 if (err)
4729 goto out;
4730
4731 if (chip->info->g2_irqs > 0) {
4732 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004733 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004734 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004735 }
4736
Andrew Lunn294d7112018-02-22 22:58:32 +01004737 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4738 if (err)
4739 goto out_g2_irq;
4740
4741 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4742 if (err)
4743 goto out_g1_atu_prob_irq;
4744
Andrew Lunna3c53be52017-01-24 14:53:50 +01004745 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004746 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004747 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004748
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004749 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004750 if (err)
4751 goto out_mdio;
4752
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004753 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004754
4755out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004756 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004757out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004758 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004759out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004760 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004761out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004762 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004763 mv88e6xxx_g2_irq_free(chip);
4764out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004765 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004766 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004767 else
4768 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004769out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004770 if (pdata)
4771 dev_put(pdata->netdev);
4772
Andrew Lunndc30c352016-10-16 19:56:49 +02004773 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004774}
4775
4776static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4777{
4778 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004779 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004780
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004781 if (chip->info->ptp_support) {
4782 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004783 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004784 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004785
Andrew Lunn930188c2016-08-22 16:01:03 +02004786 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004787 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004788 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004789
Andrew Lunn76f38f12018-03-17 20:21:09 +01004790 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4791 mv88e6xxx_g1_atu_prob_irq_free(chip);
4792
4793 if (chip->info->g2_irqs > 0)
4794 mv88e6xxx_g2_irq_free(chip);
4795
Andrew Lunn76f38f12018-03-17 20:21:09 +01004796 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004797 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004798 else
4799 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004800}
4801
4802static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004803 {
4804 .compatible = "marvell,mv88e6085",
4805 .data = &mv88e6xxx_table[MV88E6085],
4806 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004807 {
4808 .compatible = "marvell,mv88e6190",
4809 .data = &mv88e6xxx_table[MV88E6190],
4810 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004811 { /* sentinel */ },
4812};
4813
4814MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4815
4816static struct mdio_driver mv88e6xxx_driver = {
4817 .probe = mv88e6xxx_probe,
4818 .remove = mv88e6xxx_remove,
4819 .mdiodrv.driver = {
4820 .name = "mv88e6085",
4821 .of_match_table = mv88e6xxx_of_match,
4822 },
4823};
4824
Ben Hutchings98e67302011-11-25 14:36:19 +00004825static int __init mv88e6xxx_init(void)
4826{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004827 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004828 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004829}
4830module_init(mv88e6xxx_init);
4831
4832static void __exit mv88e6xxx_cleanup(void)
4833{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004834 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004835 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004836}
4837module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004838
4839MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4840MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4841MODULE_LICENSE("GPL");