blob: 669a7f13fdce4d27ca5513e1c3ee4873ecb8f893 [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
Andrew Lunnea890982019-01-09 00:24:03 +01002406/* The mv88e6390 has some hidden registers used for debug and
2407 * development. The errata also makes use of them.
2408 */
2409static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2410 int reg, u16 val)
2411{
2412 u16 ctrl;
2413 int err;
2414
2415 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2416 PORT_RESERVED_1A, val);
2417 if (err)
2418 return err;
2419
2420 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2421 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2422 reg;
2423
2424 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2425 PORT_RESERVED_1A, ctrl);
2426}
2427
2428static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2429{
2430 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2431 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2432}
2433
2434
2435static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2436 int reg, u16 *val)
2437{
2438 u16 ctrl;
2439 int err;
2440
2441 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2442 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2443 reg;
2444
2445 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2446 PORT_RESERVED_1A, ctrl);
2447 if (err)
2448 return err;
2449
2450 err = mv88e6390_hidden_wait(chip);
2451 if (err)
2452 return err;
2453
2454 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2455 PORT_RESERVED_1A, val);
2456}
2457
2458/* Check if the errata has already been applied. */
2459static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2460{
2461 int port;
2462 int err;
2463 u16 val;
2464
2465 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2466 err = mv88e6390_hidden_read(chip, port, 0, &val);
2467 if (err) {
2468 dev_err(chip->dev,
2469 "Error reading hidden register: %d\n", err);
2470 return false;
2471 }
2472 if (val != 0x01c0)
2473 return false;
2474 }
2475
2476 return true;
2477}
2478
2479/* The 6390 copper ports have an errata which require poking magic
2480 * values into undocumented hidden registers and then performing a
2481 * software reset.
2482 */
2483static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2484{
2485 int port;
2486 int err;
2487
2488 if (mv88e6390_setup_errata_applied(chip))
2489 return 0;
2490
2491 /* Set the ports into blocking mode */
2492 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2493 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2494 if (err)
2495 return err;
2496 }
2497
2498 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2499 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2500 if (err)
2501 return err;
2502 }
2503
2504 return mv88e6xxx_software_reset(chip);
2505}
2506
Vivien Didelotf81ec902016-05-09 13:22:58 -04002507static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002508{
Vivien Didelot04bed142016-08-31 18:06:13 -04002509 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002510 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002511 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002512 int i;
2513
Vivien Didelotfad09c72016-06-21 12:28:20 -04002514 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002515 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002516
Vivien Didelotfad09c72016-06-21 12:28:20 -04002517 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002518
Andrew Lunnea890982019-01-09 00:24:03 +01002519 if (chip->info->ops->setup_errata) {
2520 err = chip->info->ops->setup_errata(chip);
2521 if (err)
2522 goto unlock;
2523 }
2524
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002525 /* Cache the cmode of each port. */
2526 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2527 if (chip->info->ops->port_get_cmode) {
2528 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2529 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002530 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002531
2532 chip->ports[i].cmode = cmode;
2533 }
2534 }
2535
Vivien Didelot97299342016-07-18 20:45:30 -04002536 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002537 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002538 if (dsa_is_unused_port(ds, i))
2539 continue;
2540
Vivien Didelot97299342016-07-18 20:45:30 -04002541 err = mv88e6xxx_setup_port(chip, i);
2542 if (err)
2543 goto unlock;
2544 }
2545
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002546 err = mv88e6xxx_irl_setup(chip);
2547 if (err)
2548 goto unlock;
2549
Vivien Didelot04a69a12017-10-13 14:18:05 -04002550 err = mv88e6xxx_mac_setup(chip);
2551 if (err)
2552 goto unlock;
2553
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002554 err = mv88e6xxx_phy_setup(chip);
2555 if (err)
2556 goto unlock;
2557
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002558 err = mv88e6xxx_vtu_setup(chip);
2559 if (err)
2560 goto unlock;
2561
Vivien Didelot81228992017-03-30 17:37:08 -04002562 err = mv88e6xxx_pvt_setup(chip);
2563 if (err)
2564 goto unlock;
2565
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002566 err = mv88e6xxx_atu_setup(chip);
2567 if (err)
2568 goto unlock;
2569
Andrew Lunn87fa8862017-11-09 22:29:56 +01002570 err = mv88e6xxx_broadcast_setup(chip, 0);
2571 if (err)
2572 goto unlock;
2573
Vivien Didelot9e907d72017-07-17 13:03:43 -04002574 err = mv88e6xxx_pot_setup(chip);
2575 if (err)
2576 goto unlock;
2577
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002578 err = mv88e6xxx_rmu_setup(chip);
2579 if (err)
2580 goto unlock;
2581
Vivien Didelot51c901a2017-07-17 13:03:41 -04002582 err = mv88e6xxx_rsvd2cpu_setup(chip);
2583 if (err)
2584 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002585
Vivien Didelotb28f8722018-04-26 21:56:44 -04002586 err = mv88e6xxx_trunk_setup(chip);
2587 if (err)
2588 goto unlock;
2589
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002590 err = mv88e6xxx_devmap_setup(chip);
2591 if (err)
2592 goto unlock;
2593
Vivien Didelot93e18d62018-05-11 17:16:35 -04002594 err = mv88e6xxx_pri_setup(chip);
2595 if (err)
2596 goto unlock;
2597
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002598 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002599 if (chip->info->ptp_support) {
2600 err = mv88e6xxx_ptp_setup(chip);
2601 if (err)
2602 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002603
2604 err = mv88e6xxx_hwtstamp_setup(chip);
2605 if (err)
2606 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002607 }
2608
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002609 err = mv88e6xxx_stats_setup(chip);
2610 if (err)
2611 goto unlock;
2612
Vivien Didelot6b17e862015-08-13 12:52:18 -04002613unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002614 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002615
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002616 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002617}
2618
Vivien Didelote57e5e72016-08-15 17:19:00 -04002619static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002620{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002621 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2622 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002623 u16 val;
2624 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002625
Andrew Lunnee26a222017-01-24 14:53:48 +01002626 if (!chip->info->ops->phy_read)
2627 return -EOPNOTSUPP;
2628
Vivien Didelotfad09c72016-06-21 12:28:20 -04002629 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002630 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002631 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002632
Andrew Lunnda9f3302017-02-01 03:40:05 +01002633 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002634 /* Some internal PHYs don't have a model number. */
2635 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2636 /* Then there is the 6165 family. It gets is
2637 * PHYs correct. But it can also have two
2638 * SERDES interfaces in the PHY address
2639 * space. And these don't have a model
2640 * number. But they are not PHYs, so we don't
2641 * want to give them something a PHY driver
2642 * will recognise.
2643 *
2644 * Use the mv88e6390 family model number
2645 * instead, for anything which really could be
2646 * a PHY,
2647 */
2648 if (!(val & 0x3f0))
2649 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002650 }
2651
Vivien Didelote57e5e72016-08-15 17:19:00 -04002652 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002653}
2654
Vivien Didelote57e5e72016-08-15 17:19:00 -04002655static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002656{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002657 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2658 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002659 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002660
Andrew Lunnee26a222017-01-24 14:53:48 +01002661 if (!chip->info->ops->phy_write)
2662 return -EOPNOTSUPP;
2663
Vivien Didelotfad09c72016-06-21 12:28:20 -04002664 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002665 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002666 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002667
2668 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002669}
2670
Vivien Didelotfad09c72016-06-21 12:28:20 -04002671static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002672 struct device_node *np,
2673 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002674{
2675 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002676 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002677 struct mii_bus *bus;
2678 int err;
2679
Andrew Lunn2510bab2018-02-22 01:51:49 +01002680 if (external) {
2681 mutex_lock(&chip->reg_lock);
2682 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2683 mutex_unlock(&chip->reg_lock);
2684
2685 if (err)
2686 return err;
2687 }
2688
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002689 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002690 if (!bus)
2691 return -ENOMEM;
2692
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002693 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002694 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002695 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002696 INIT_LIST_HEAD(&mdio_bus->list);
2697 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002698
Andrew Lunnb516d452016-06-04 21:17:06 +02002699 if (np) {
2700 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002701 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002702 } else {
2703 bus->name = "mv88e6xxx SMI";
2704 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2705 }
2706
2707 bus->read = mv88e6xxx_mdio_read;
2708 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002709 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002710
Andrew Lunn6f882842018-03-17 20:32:05 +01002711 if (!external) {
2712 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2713 if (err)
2714 return err;
2715 }
2716
Florian Fainelli00e798c2018-05-15 16:56:19 -07002717 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002718 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002719 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002720 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002721 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002722 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002723
2724 if (external)
2725 list_add_tail(&mdio_bus->list, &chip->mdios);
2726 else
2727 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002728
2729 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002730}
2731
Andrew Lunna3c53be52017-01-24 14:53:50 +01002732static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2733 { .compatible = "marvell,mv88e6xxx-mdio-external",
2734 .data = (void *)true },
2735 { },
2736};
2737
Andrew Lunn3126aee2017-12-07 01:05:57 +01002738static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2739
2740{
2741 struct mv88e6xxx_mdio_bus *mdio_bus;
2742 struct mii_bus *bus;
2743
2744 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2745 bus = mdio_bus->bus;
2746
Andrew Lunn6f882842018-03-17 20:32:05 +01002747 if (!mdio_bus->external)
2748 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2749
Andrew Lunn3126aee2017-12-07 01:05:57 +01002750 mdiobus_unregister(bus);
2751 }
2752}
2753
Andrew Lunna3c53be52017-01-24 14:53:50 +01002754static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2755 struct device_node *np)
2756{
2757 const struct of_device_id *match;
2758 struct device_node *child;
2759 int err;
2760
2761 /* Always register one mdio bus for the internal/default mdio
2762 * bus. This maybe represented in the device tree, but is
2763 * optional.
2764 */
2765 child = of_get_child_by_name(np, "mdio");
2766 err = mv88e6xxx_mdio_register(chip, child, false);
2767 if (err)
2768 return err;
2769
2770 /* Walk the device tree, and see if there are any other nodes
2771 * which say they are compatible with the external mdio
2772 * bus.
2773 */
2774 for_each_available_child_of_node(np, child) {
2775 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2776 if (match) {
2777 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002778 if (err) {
2779 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002780 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002781 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002782 }
2783 }
2784
2785 return 0;
2786}
2787
Vivien Didelot855b1932016-07-20 18:18:35 -04002788static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2789{
Vivien Didelot04bed142016-08-31 18:06:13 -04002790 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002791
2792 return chip->eeprom_len;
2793}
2794
Vivien Didelot855b1932016-07-20 18:18:35 -04002795static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2796 struct ethtool_eeprom *eeprom, u8 *data)
2797{
Vivien Didelot04bed142016-08-31 18:06:13 -04002798 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002799 int err;
2800
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002801 if (!chip->info->ops->get_eeprom)
2802 return -EOPNOTSUPP;
2803
Vivien Didelot855b1932016-07-20 18:18:35 -04002804 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002805 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002806 mutex_unlock(&chip->reg_lock);
2807
2808 if (err)
2809 return err;
2810
2811 eeprom->magic = 0xc3ec4951;
2812
2813 return 0;
2814}
2815
Vivien Didelot855b1932016-07-20 18:18:35 -04002816static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2817 struct ethtool_eeprom *eeprom, u8 *data)
2818{
Vivien Didelot04bed142016-08-31 18:06:13 -04002819 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002820 int err;
2821
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002822 if (!chip->info->ops->set_eeprom)
2823 return -EOPNOTSUPP;
2824
Vivien Didelot855b1932016-07-20 18:18:35 -04002825 if (eeprom->magic != 0xc3ec4951)
2826 return -EINVAL;
2827
2828 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002829 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002830 mutex_unlock(&chip->reg_lock);
2831
2832 return err;
2833}
2834
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002835static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002836 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002837 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2838 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002839 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002840 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002841 .phy_read = mv88e6185_phy_ppu_read,
2842 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002843 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002844 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002845 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002846 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002847 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002848 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002849 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002850 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002851 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002852 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002853 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002854 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002855 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002856 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002857 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002858 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2859 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002860 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002861 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2862 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002863 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002864 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002865 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002866 .ppu_enable = mv88e6185_g1_ppu_enable,
2867 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002868 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002869 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002870 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002871 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002872 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002873};
2874
2875static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002876 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002877 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2878 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002879 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002880 .phy_read = mv88e6185_phy_ppu_read,
2881 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002882 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002883 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002884 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002885 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002886 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002887 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002888 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002889 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002890 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002891 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002892 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2893 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002894 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002895 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002896 .ppu_enable = mv88e6185_g1_ppu_enable,
2897 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002898 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002899 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002900 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002901 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002902};
2903
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002904static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002905 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002906 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2907 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002908 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002909 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2910 .phy_read = mv88e6xxx_g2_smi_phy_read,
2911 .phy_write = mv88e6xxx_g2_smi_phy_write,
2912 .port_set_link = mv88e6xxx_port_set_link,
2913 .port_set_duplex = mv88e6xxx_port_set_duplex,
2914 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002915 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002916 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002917 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002918 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002919 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002920 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002921 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002922 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002923 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002924 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002925 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002926 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002927 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002928 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2929 .stats_get_strings = mv88e6095_stats_get_strings,
2930 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002931 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2932 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002933 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002934 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002935 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002936 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002937 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002938 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002939 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002940 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002941};
2942
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002943static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002944 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002945 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2946 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002947 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002948 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002949 .phy_read = mv88e6xxx_g2_smi_phy_read,
2950 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002951 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002952 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002953 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002954 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002955 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002956 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002957 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002958 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002959 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002960 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002961 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002962 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2963 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002964 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002965 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2966 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002967 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002968 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002969 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002970 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002971 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002972 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002973 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002974};
2975
2976static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002977 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002978 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2979 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002980 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002981 .phy_read = mv88e6185_phy_ppu_read,
2982 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002983 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002984 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002985 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002986 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002987 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002988 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002989 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002990 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002991 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002992 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002993 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002994 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002995 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002996 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002997 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002998 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002999 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3000 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003001 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003002 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3003 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003004 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003005 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003006 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003007 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003008 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003009 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003010 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003011 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003012 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003013};
3014
Vivien Didelot990e27b2017-03-28 13:50:32 -04003015static const struct mv88e6xxx_ops mv88e6141_ops = {
3016 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003017 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3018 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003019 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003020 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3021 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3022 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3023 .phy_read = mv88e6xxx_g2_smi_phy_read,
3024 .phy_write = mv88e6xxx_g2_smi_phy_write,
3025 .port_set_link = mv88e6xxx_port_set_link,
3026 .port_set_duplex = mv88e6xxx_port_set_duplex,
3027 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003028 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003029 .port_tag_remap = mv88e6095_port_tag_remap,
3030 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3031 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3032 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003033 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003034 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003035 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003036 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3037 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003038 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003039 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003040 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003041 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003042 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3043 .stats_get_strings = mv88e6320_stats_get_strings,
3044 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003045 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3046 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003047 .watchdog_ops = &mv88e6390_watchdog_ops,
3048 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003049 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003050 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003051 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003052 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003053 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003054 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003055 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003056};
3057
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003058static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003059 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003060 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3061 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003062 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003063 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003064 .phy_read = mv88e6xxx_g2_smi_phy_read,
3065 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003066 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003067 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003068 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003069 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003070 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003071 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003072 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003073 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003074 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003075 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003076 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003077 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003078 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003079 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003080 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003081 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003082 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3083 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003084 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003085 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3086 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003087 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003088 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003089 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003090 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003091 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003092 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003093 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003094 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003095 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003096};
3097
3098static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003099 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003100 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3101 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003102 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003103 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003104 .phy_read = mv88e6165_phy_read,
3105 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003106 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003107 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003108 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003109 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003110 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003111 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003112 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003113 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003114 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003115 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3116 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003117 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003118 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3119 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003120 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003121 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003122 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003123 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003124 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003125 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003126 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003127 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003128 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003129};
3130
3131static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003132 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003133 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3134 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003135 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003136 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003137 .phy_read = mv88e6xxx_g2_smi_phy_read,
3138 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003139 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003140 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003141 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003142 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003143 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003144 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003145 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003146 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003147 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003148 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003149 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003150 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003151 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003152 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003153 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003154 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003155 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003156 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3157 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003158 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003159 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3160 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003161 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003162 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003163 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003164 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003165 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003166 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003167 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003168};
3169
3170static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003171 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003172 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3173 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003174 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003175 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3176 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003177 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003178 .phy_read = mv88e6xxx_g2_smi_phy_read,
3179 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003180 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003181 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003182 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003183 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003184 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003185 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003186 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003187 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003188 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003189 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003190 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003191 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003192 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003193 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003194 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003195 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003196 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003197 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3198 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003199 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003200 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3201 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003202 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003203 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003204 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003205 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003206 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003207 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003208 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003209 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003210 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003211 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003212};
3213
3214static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003215 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003216 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3217 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003218 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003219 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003220 .phy_read = mv88e6xxx_g2_smi_phy_read,
3221 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003222 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003223 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003224 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003225 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003226 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003227 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003228 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003229 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003230 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003231 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003232 .port_pause_limit = mv88e6097_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 Lunna605a0f2016-11-21 23:26:58 +01003237 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003238 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003239 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3240 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003241 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003242 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3243 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003244 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003245 .mgmt_rsvd2cpu = mv88e6352_g2_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 Didelotf1394b782017-05-01 14:05:22 -04003248 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003249 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003250 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003251};
3252
3253static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003254 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003255 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3256 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003257 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003258 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3259 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003260 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003261 .phy_read = mv88e6xxx_g2_smi_phy_read,
3262 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003263 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003264 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003265 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003266 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003267 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003268 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003269 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003270 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003271 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003272 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003273 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003274 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003275 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003276 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003277 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003278 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003279 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003280 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3281 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003282 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003283 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3284 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003285 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003286 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003287 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003288 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003289 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003290 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003291 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003292 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003293 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3294 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003295 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003296 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003297};
3298
3299static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003300 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003301 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3302 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003303 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003304 .phy_read = mv88e6185_phy_ppu_read,
3305 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003306 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003307 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003308 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003309 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003310 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003311 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003312 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003313 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003314 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003315 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003316 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003317 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003318 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3319 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003320 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003321 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3322 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003323 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003324 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003325 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003326 .ppu_enable = mv88e6185_g1_ppu_enable,
3327 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003328 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003329 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003330 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003331 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003332};
3333
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003334static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003335 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003336 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003337 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003338 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3339 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003340 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3341 .phy_read = mv88e6xxx_g2_smi_phy_read,
3342 .phy_write = mv88e6xxx_g2_smi_phy_write,
3343 .port_set_link = mv88e6xxx_port_set_link,
3344 .port_set_duplex = mv88e6xxx_port_set_duplex,
3345 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3346 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003347 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003348 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003349 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003350 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003351 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003352 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003353 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003354 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003355 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003356 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003357 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003358 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003359 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3360 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003361 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003362 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3363 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003364 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003365 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003366 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003367 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003368 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003369 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3370 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003371 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003372 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3373 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003374 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003375 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003376};
3377
3378static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003379 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003380 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003381 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003382 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3383 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003384 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3385 .phy_read = mv88e6xxx_g2_smi_phy_read,
3386 .phy_write = mv88e6xxx_g2_smi_phy_write,
3387 .port_set_link = mv88e6xxx_port_set_link,
3388 .port_set_duplex = mv88e6xxx_port_set_duplex,
3389 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3390 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003391 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003392 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003393 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003394 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003395 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003396 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003397 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003398 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003399 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003400 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003401 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003402 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003403 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3404 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003405 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003406 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3407 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003408 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003409 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003410 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003411 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003412 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003413 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3414 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003415 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003416 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3417 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003418 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003419 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003420};
3421
3422static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003423 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003424 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003425 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003426 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3427 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003428 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3429 .phy_read = mv88e6xxx_g2_smi_phy_read,
3430 .phy_write = mv88e6xxx_g2_smi_phy_write,
3431 .port_set_link = mv88e6xxx_port_set_link,
3432 .port_set_duplex = mv88e6xxx_port_set_duplex,
3433 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3434 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003435 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003436 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003437 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003438 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003439 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003440 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003441 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003442 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003443 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003444 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003445 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003446 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003447 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3448 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003449 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003450 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3451 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003452 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003453 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003454 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003455 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003456 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003457 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3458 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003459 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003460 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3461 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003462 .avb_ops = &mv88e6390_avb_ops,
3463 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003464 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003465};
3466
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003467static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003468 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003469 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3470 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003471 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003472 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3473 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003474 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003475 .phy_read = mv88e6xxx_g2_smi_phy_read,
3476 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003477 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003478 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003479 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003480 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003481 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003482 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003483 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003484 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003485 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003486 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003487 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003488 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003489 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003490 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003491 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003492 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003493 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003494 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3495 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003496 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003497 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3498 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003499 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003500 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003501 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003502 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003503 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003504 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003505 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003506 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003507 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3508 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003509 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003510 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003511 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003512 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003513};
3514
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003515static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003516 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003517 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003518 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003519 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3520 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003521 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3522 .phy_read = mv88e6xxx_g2_smi_phy_read,
3523 .phy_write = mv88e6xxx_g2_smi_phy_write,
3524 .port_set_link = mv88e6xxx_port_set_link,
3525 .port_set_duplex = mv88e6xxx_port_set_duplex,
3526 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3527 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003528 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003529 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003530 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003531 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003532 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003533 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003534 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003535 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003536 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003537 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003538 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003539 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003540 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3541 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003542 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003543 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3544 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003545 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003546 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003547 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003548 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003549 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003550 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3551 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003552 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003553 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3554 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003555 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003556 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003557 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003558 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003559};
3560
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003561static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003562 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003563 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3564 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003565 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003566 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3567 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
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,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003573 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003574 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003575 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003576 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003577 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003578 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003579 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003580 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003581 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003582 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003583 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003584 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003585 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003586 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003587 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3588 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003589 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003590 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3591 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003592 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003593 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003594 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003595 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003596 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003597 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003598 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003599 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003600 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003601 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003602};
3603
3604static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003605 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003606 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3607 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003608 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003609 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3610 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003611 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003612 .phy_read = mv88e6xxx_g2_smi_phy_read,
3613 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003614 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003615 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003616 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003617 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003618 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003619 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003620 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003621 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003622 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003623 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003624 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003625 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003626 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003627 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003628 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003629 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003630 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3631 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003632 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003633 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3634 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003635 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003636 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003637 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003638 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003639 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003640 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003641 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003642 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003643};
3644
Vivien Didelot16e329a2017-03-28 13:50:33 -04003645static const struct mv88e6xxx_ops mv88e6341_ops = {
3646 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003647 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3648 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003649 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003650 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3651 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3652 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3653 .phy_read = mv88e6xxx_g2_smi_phy_read,
3654 .phy_write = mv88e6xxx_g2_smi_phy_write,
3655 .port_set_link = mv88e6xxx_port_set_link,
3656 .port_set_duplex = mv88e6xxx_port_set_duplex,
3657 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003658 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003659 .port_tag_remap = mv88e6095_port_tag_remap,
3660 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3661 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3662 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003663 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003664 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003665 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003666 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3667 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003668 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003669 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003670 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003671 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003672 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3673 .stats_get_strings = mv88e6320_stats_get_strings,
3674 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003675 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3676 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003677 .watchdog_ops = &mv88e6390_watchdog_ops,
3678 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003679 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003680 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003681 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003682 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003683 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003684 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003685 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003686 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003687 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003688};
3689
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003690static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003691 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003692 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3693 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003694 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003695 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003696 .phy_read = mv88e6xxx_g2_smi_phy_read,
3697 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003698 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003699 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003700 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003701 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003702 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003703 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003704 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003705 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003706 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003707 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003708 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003709 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003710 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003711 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003712 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003713 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003714 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003715 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3716 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003717 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003718 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3719 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003720 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003721 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003722 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003723 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003724 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003725 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003726 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003727};
3728
3729static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003730 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003731 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3732 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003733 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003734 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003735 .phy_read = mv88e6xxx_g2_smi_phy_read,
3736 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003737 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003738 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003739 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003740 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003741 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003742 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003743 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003744 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003745 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003746 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003747 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003748 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003749 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003750 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003751 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003752 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003753 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003754 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3755 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003756 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003757 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3758 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003759 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003760 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003761 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003762 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003763 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003764 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003765 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003766 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003767 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003768};
3769
3770static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003771 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003772 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3773 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003774 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003775 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3776 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003777 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003778 .phy_read = mv88e6xxx_g2_smi_phy_read,
3779 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003780 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003781 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003782 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003783 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003784 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003785 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003786 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003787 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003788 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003789 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003790 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003791 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003792 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003793 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003794 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003795 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003796 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003797 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3798 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003799 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003800 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3801 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003802 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003803 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003804 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003805 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003806 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003807 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003808 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003809 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003810 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3811 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003812 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003813 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003814 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003815 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3816 .serdes_get_strings = mv88e6352_serdes_get_strings,
3817 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003818 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003819};
3820
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003821static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003822 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003823 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003824 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003825 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3826 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003827 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3828 .phy_read = mv88e6xxx_g2_smi_phy_read,
3829 .phy_write = mv88e6xxx_g2_smi_phy_write,
3830 .port_set_link = mv88e6xxx_port_set_link,
3831 .port_set_duplex = mv88e6xxx_port_set_duplex,
3832 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3833 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003834 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003835 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003836 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003837 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003838 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003839 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003840 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003841 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003842 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003843 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003844 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003845 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003846 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003847 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003848 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3849 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003850 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003851 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3852 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003853 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003854 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003855 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003856 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003857 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003858 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3859 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003860 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003861 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3862 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003863 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003864 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003865 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003866 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003867};
3868
3869static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003870 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003871 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003872 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003873 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3874 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003875 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3876 .phy_read = mv88e6xxx_g2_smi_phy_read,
3877 .phy_write = mv88e6xxx_g2_smi_phy_write,
3878 .port_set_link = mv88e6xxx_port_set_link,
3879 .port_set_duplex = mv88e6xxx_port_set_duplex,
3880 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3881 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003882 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003883 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003884 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003885 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003886 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003887 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003888 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003889 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003890 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003891 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003892 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003893 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003894 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003895 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003896 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3897 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003898 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003899 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3900 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003901 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003902 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003903 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003904 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003905 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003906 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3907 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003908 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003909 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3910 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003911 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003912 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003913 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003914 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003915};
3916
Vivien Didelotf81ec902016-05-09 13:22:58 -04003917static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3918 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003919 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003920 .family = MV88E6XXX_FAMILY_6097,
3921 .name = "Marvell 88E6085",
3922 .num_databases = 4096,
3923 .num_ports = 10,
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 = 8,
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 Lunn443d5a12016-12-03 04:35:18 +01003936 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003937 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003938 },
3939
3940 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003941 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003942 .family = MV88E6XXX_FAMILY_6095,
3943 .name = "Marvell 88E6095/88E6095F",
3944 .num_databases = 256,
3945 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003946 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003947 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003948 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003949 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003950 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003951 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003952 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003953 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003954 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003955 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003956 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003957 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003958 },
3959
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003960 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003961 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003962 .family = MV88E6XXX_FAMILY_6097,
3963 .name = "Marvell 88E6097/88E6097F",
3964 .num_databases = 4096,
3965 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003966 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003967 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003968 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003969 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003970 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003971 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003972 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003973 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003974 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003975 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003976 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003977 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003978 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003979 .ops = &mv88e6097_ops,
3980 },
3981
Vivien Didelotf81ec902016-05-09 13:22:58 -04003982 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003983 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003984 .family = MV88E6XXX_FAMILY_6165,
3985 .name = "Marvell 88E6123",
3986 .num_databases = 4096,
3987 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003988 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003989 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003990 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003991 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003992 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003993 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003994 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003995 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003996 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003997 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003998 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003999 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004000 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004001 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004002 },
4003
4004 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004005 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004006 .family = MV88E6XXX_FAMILY_6185,
4007 .name = "Marvell 88E6131",
4008 .num_databases = 256,
4009 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004010 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004011 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004012 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004013 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004014 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004015 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004016 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004017 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004018 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004019 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004020 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004021 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004022 },
4023
Vivien Didelot990e27b2017-03-28 13:50:32 -04004024 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004025 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004026 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004027 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004028 .num_databases = 4096,
4029 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004030 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004031 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004032 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004033 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004034 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004035 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004036 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004037 .age_time_coeff = 3750,
4038 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004039 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004040 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004041 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004042 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004043 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004044 .ops = &mv88e6141_ops,
4045 },
4046
Vivien Didelotf81ec902016-05-09 13:22:58 -04004047 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004048 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004049 .family = MV88E6XXX_FAMILY_6165,
4050 .name = "Marvell 88E6161",
4051 .num_databases = 4096,
4052 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004053 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004054 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004055 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004056 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004057 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004058 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004059 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004060 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004061 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004062 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004063 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004064 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004065 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004066 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004067 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004068 },
4069
4070 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004071 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004072 .family = MV88E6XXX_FAMILY_6165,
4073 .name = "Marvell 88E6165",
4074 .num_databases = 4096,
4075 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004076 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004077 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004078 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004079 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004080 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004081 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004082 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004083 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004084 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004085 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004086 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004087 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004088 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004089 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004090 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004091 },
4092
4093 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004094 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004095 .family = MV88E6XXX_FAMILY_6351,
4096 .name = "Marvell 88E6171",
4097 .num_databases = 4096,
4098 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004099 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004100 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004101 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004102 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004103 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004104 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004105 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004106 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004107 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004108 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004109 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004110 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004111 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004112 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004113 },
4114
4115 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004116 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004117 .family = MV88E6XXX_FAMILY_6352,
4118 .name = "Marvell 88E6172",
4119 .num_databases = 4096,
4120 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004121 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004122 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004123 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004124 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004125 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004126 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004127 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004128 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004129 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004130 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004131 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004132 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004133 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004134 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004135 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004136 },
4137
4138 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004139 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004140 .family = MV88E6XXX_FAMILY_6351,
4141 .name = "Marvell 88E6175",
4142 .num_databases = 4096,
4143 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004144 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004145 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004146 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004147 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004148 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004149 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004150 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004151 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004152 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004153 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004154 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004155 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004156 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004157 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004158 },
4159
4160 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004161 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004162 .family = MV88E6XXX_FAMILY_6352,
4163 .name = "Marvell 88E6176",
4164 .num_databases = 4096,
4165 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004166 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004167 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004168 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004169 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004170 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004171 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004172 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004173 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004174 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004175 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004176 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004177 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004178 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004179 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004180 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004181 },
4182
4183 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004184 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004185 .family = MV88E6XXX_FAMILY_6185,
4186 .name = "Marvell 88E6185",
4187 .num_databases = 256,
4188 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004189 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004190 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004191 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004192 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004193 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004194 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004195 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004196 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004197 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004198 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004199 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004200 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004201 },
4202
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004203 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004204 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004205 .family = MV88E6XXX_FAMILY_6390,
4206 .name = "Marvell 88E6190",
4207 .num_databases = 4096,
4208 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004209 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004210 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004211 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004212 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004213 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004214 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004215 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004216 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004217 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004218 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004219 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004220 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004221 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004222 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004223 .ops = &mv88e6190_ops,
4224 },
4225
4226 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004227 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004228 .family = MV88E6XXX_FAMILY_6390,
4229 .name = "Marvell 88E6190X",
4230 .num_databases = 4096,
4231 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004232 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004233 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004234 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004235 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004236 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004237 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004238 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004239 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004240 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004241 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004242 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004243 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004244 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004245 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004246 .ops = &mv88e6190x_ops,
4247 },
4248
4249 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004250 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004251 .family = MV88E6XXX_FAMILY_6390,
4252 .name = "Marvell 88E6191",
4253 .num_databases = 4096,
4254 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004255 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004256 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004257 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004258 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004259 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004260 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004261 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004262 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004263 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004264 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004265 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004266 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004267 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004268 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004269 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004270 },
4271
Vivien Didelotf81ec902016-05-09 13:22:58 -04004272 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004273 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004274 .family = MV88E6XXX_FAMILY_6352,
4275 .name = "Marvell 88E6240",
4276 .num_databases = 4096,
4277 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004278 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004279 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004280 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004281 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004282 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004283 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004284 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004285 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004286 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004287 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004288 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004289 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004290 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004291 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004292 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004293 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004294 },
4295
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004296 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004297 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004298 .family = MV88E6XXX_FAMILY_6390,
4299 .name = "Marvell 88E6290",
4300 .num_databases = 4096,
4301 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004302 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004303 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004304 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004305 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004306 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004307 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004308 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004309 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004310 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004311 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004312 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004313 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004314 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004315 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004316 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004317 .ops = &mv88e6290_ops,
4318 },
4319
Vivien Didelotf81ec902016-05-09 13:22:58 -04004320 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004321 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004322 .family = MV88E6XXX_FAMILY_6320,
4323 .name = "Marvell 88E6320",
4324 .num_databases = 4096,
4325 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004326 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004327 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004328 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004329 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004330 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004331 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004332 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004333 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004334 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004335 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004336 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004337 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004338 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004339 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004340 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004341 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004342 },
4343
4344 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004345 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004346 .family = MV88E6XXX_FAMILY_6320,
4347 .name = "Marvell 88E6321",
4348 .num_databases = 4096,
4349 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004350 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004351 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004352 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004353 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004354 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004355 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004356 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004357 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004358 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004359 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004360 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004361 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004362 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004363 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004364 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004365 },
4366
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004367 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004368 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004369 .family = MV88E6XXX_FAMILY_6341,
4370 .name = "Marvell 88E6341",
4371 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004372 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004373 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004374 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004375 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004376 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004377 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004378 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004379 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004380 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004381 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004382 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004383 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004384 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004385 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004386 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004387 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004388 .ops = &mv88e6341_ops,
4389 },
4390
Vivien Didelotf81ec902016-05-09 13:22:58 -04004391 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004392 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004393 .family = MV88E6XXX_FAMILY_6351,
4394 .name = "Marvell 88E6350",
4395 .num_databases = 4096,
4396 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004397 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004398 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004399 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004400 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004401 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004402 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004403 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004404 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004405 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004406 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004407 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004408 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004409 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004410 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004411 },
4412
4413 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004414 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004415 .family = MV88E6XXX_FAMILY_6351,
4416 .name = "Marvell 88E6351",
4417 .num_databases = 4096,
4418 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004419 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004420 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004421 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004422 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004423 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004424 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004425 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004426 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004427 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004428 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004429 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004430 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004431 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004432 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004433 },
4434
4435 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004436 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004437 .family = MV88E6XXX_FAMILY_6352,
4438 .name = "Marvell 88E6352",
4439 .num_databases = 4096,
4440 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004441 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004442 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004443 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004444 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004445 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004446 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004447 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004448 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004449 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004450 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004451 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004452 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004453 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004454 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004455 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004456 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004457 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004458 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004459 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004460 .family = MV88E6XXX_FAMILY_6390,
4461 .name = "Marvell 88E6390",
4462 .num_databases = 4096,
4463 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004464 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004465 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004466 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004467 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004468 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004469 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004470 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004471 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004472 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004473 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004474 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004475 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004476 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004477 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004478 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004479 .ops = &mv88e6390_ops,
4480 },
4481 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004482 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004483 .family = MV88E6XXX_FAMILY_6390,
4484 .name = "Marvell 88E6390X",
4485 .num_databases = 4096,
4486 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004487 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004488 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004489 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004490 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004491 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004492 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004493 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004494 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004495 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004496 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004497 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004498 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004499 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004500 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004501 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004502 .ops = &mv88e6390x_ops,
4503 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004504};
4505
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004506static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004507{
Vivien Didelota439c062016-04-17 13:23:58 -04004508 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004509
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004510 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4511 if (mv88e6xxx_table[i].prod_num == prod_num)
4512 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004513
Vivien Didelotb9b37712015-10-30 19:39:48 -04004514 return NULL;
4515}
4516
Vivien Didelotfad09c72016-06-21 12:28:20 -04004517static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004518{
4519 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004520 unsigned int prod_num, rev;
4521 u16 id;
4522 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004523
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004524 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004525 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004526 mutex_unlock(&chip->reg_lock);
4527 if (err)
4528 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004529
Vivien Didelot107fcc12017-06-12 12:37:36 -04004530 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4531 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004532
4533 info = mv88e6xxx_lookup_info(prod_num);
4534 if (!info)
4535 return -ENODEV;
4536
Vivien Didelotcaac8542016-06-20 13:14:09 -04004537 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004538 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004539
Vivien Didelotca070c12016-09-02 14:45:34 -04004540 err = mv88e6xxx_g2_require(chip);
4541 if (err)
4542 return err;
4543
Vivien Didelotfad09c72016-06-21 12:28:20 -04004544 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4545 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004546
4547 return 0;
4548}
4549
Vivien Didelotfad09c72016-06-21 12:28:20 -04004550static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004551{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004552 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004553
Vivien Didelotfad09c72016-06-21 12:28:20 -04004554 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4555 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004556 return NULL;
4557
Vivien Didelotfad09c72016-06-21 12:28:20 -04004558 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004559
Vivien Didelotfad09c72016-06-21 12:28:20 -04004560 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004561 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004562
Vivien Didelotfad09c72016-06-21 12:28:20 -04004563 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004564}
4565
Vivien Didelotfad09c72016-06-21 12:28:20 -04004566static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004567 struct mii_bus *bus, int sw_addr)
4568{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004569 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004570 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004571 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004572 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004573 else
4574 return -EINVAL;
4575
Vivien Didelotfad09c72016-06-21 12:28:20 -04004576 chip->bus = bus;
4577 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004578
4579 return 0;
4580}
4581
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004582static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4583 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004584{
Vivien Didelot04bed142016-08-31 18:06:13 -04004585 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004586
Andrew Lunn443d5a12016-12-03 04:35:18 +01004587 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004588}
4589
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004590#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004591static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4592 struct device *host_dev, int sw_addr,
4593 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004594{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004595 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004596 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004597 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004598
Vivien Didelota439c062016-04-17 13:23:58 -04004599 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004600 if (!bus)
4601 return NULL;
4602
Vivien Didelotfad09c72016-06-21 12:28:20 -04004603 chip = mv88e6xxx_alloc_chip(dsa_dev);
4604 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004605 return NULL;
4606
Vivien Didelotcaac8542016-06-20 13:14:09 -04004607 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004608 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004609
Vivien Didelotfad09c72016-06-21 12:28:20 -04004610 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004611 if (err)
4612 goto free;
4613
Vivien Didelotfad09c72016-06-21 12:28:20 -04004614 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004615 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004616 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004617
Andrew Lunndc30c352016-10-16 19:56:49 +02004618 mutex_lock(&chip->reg_lock);
4619 err = mv88e6xxx_switch_reset(chip);
4620 mutex_unlock(&chip->reg_lock);
4621 if (err)
4622 goto free;
4623
Vivien Didelote57e5e72016-08-15 17:19:00 -04004624 mv88e6xxx_phy_init(chip);
4625
Andrew Lunna3c53be52017-01-24 14:53:50 +01004626 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004627 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004628 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004629
Vivien Didelotfad09c72016-06-21 12:28:20 -04004630 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004631
Vivien Didelotfad09c72016-06-21 12:28:20 -04004632 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004633free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004634 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004635
4636 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004637}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004638#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004639
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004640static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004641 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004642{
4643 /* We don't need any dynamic resource from the kernel (yet),
4644 * so skip the prepare phase.
4645 */
4646
4647 return 0;
4648}
4649
4650static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004651 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004652{
Vivien Didelot04bed142016-08-31 18:06:13 -04004653 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004654
4655 mutex_lock(&chip->reg_lock);
4656 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004657 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004658 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4659 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004660 mutex_unlock(&chip->reg_lock);
4661}
4662
4663static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4664 const struct switchdev_obj_port_mdb *mdb)
4665{
Vivien Didelot04bed142016-08-31 18:06:13 -04004666 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004667 int err;
4668
4669 mutex_lock(&chip->reg_lock);
4670 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004671 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004672 mutex_unlock(&chip->reg_lock);
4673
4674 return err;
4675}
4676
Florian Fainellia82f67a2017-01-08 14:52:08 -08004677static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004678#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004679 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004680#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004681 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004682 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004683 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004684 .phylink_validate = mv88e6xxx_validate,
4685 .phylink_mac_link_state = mv88e6xxx_link_state,
4686 .phylink_mac_config = mv88e6xxx_mac_config,
4687 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4688 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004689 .get_strings = mv88e6xxx_get_strings,
4690 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4691 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004692 .port_enable = mv88e6xxx_port_enable,
4693 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004694 .get_mac_eee = mv88e6xxx_get_mac_eee,
4695 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004696 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004697 .get_eeprom = mv88e6xxx_get_eeprom,
4698 .set_eeprom = mv88e6xxx_set_eeprom,
4699 .get_regs_len = mv88e6xxx_get_regs_len,
4700 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004701 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004702 .port_bridge_join = mv88e6xxx_port_bridge_join,
4703 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4704 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004705 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004706 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4707 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4708 .port_vlan_add = mv88e6xxx_port_vlan_add,
4709 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004710 .port_fdb_add = mv88e6xxx_port_fdb_add,
4711 .port_fdb_del = mv88e6xxx_port_fdb_del,
4712 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004713 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4714 .port_mdb_add = mv88e6xxx_port_mdb_add,
4715 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004716 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4717 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004718 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4719 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4720 .port_txtstamp = mv88e6xxx_port_txtstamp,
4721 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4722 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004723};
4724
Florian Fainelliab3d4082017-01-08 14:52:07 -08004725static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4726 .ops = &mv88e6xxx_switch_ops,
4727};
4728
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004729static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004730{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004731 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004732 struct dsa_switch *ds;
4733
Vivien Didelot73b12042017-03-30 17:37:10 -04004734 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004735 if (!ds)
4736 return -ENOMEM;
4737
Vivien Didelotfad09c72016-06-21 12:28:20 -04004738 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004739 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004740 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004741 ds->ageing_time_min = chip->info->age_time_coeff;
4742 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004743
4744 dev_set_drvdata(dev, ds);
4745
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004746 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004747}
4748
Vivien Didelotfad09c72016-06-21 12:28:20 -04004749static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004750{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004751 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004752}
4753
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004754static const void *pdata_device_get_match_data(struct device *dev)
4755{
4756 const struct of_device_id *matches = dev->driver->of_match_table;
4757 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4758
4759 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4760 matches++) {
4761 if (!strcmp(pdata->compatible, matches->compatible))
4762 return matches->data;
4763 }
4764 return NULL;
4765}
4766
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004767/* There is no suspend to RAM support at DSA level yet, the switch configuration
4768 * would be lost after a power cycle so prevent it to be suspended.
4769 */
4770static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4771{
4772 return -EOPNOTSUPP;
4773}
4774
4775static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4776{
4777 return 0;
4778}
4779
4780static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4781
Vivien Didelot57d32312016-06-20 13:13:58 -04004782static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004783{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004784 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004785 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004786 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004787 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004788 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004789 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004790 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004791
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004792 if (!np && !pdata)
4793 return -EINVAL;
4794
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004795 if (np)
4796 compat_info = of_device_get_match_data(dev);
4797
4798 if (pdata) {
4799 compat_info = pdata_device_get_match_data(dev);
4800
4801 if (!pdata->netdev)
4802 return -EINVAL;
4803
4804 for (port = 0; port < DSA_MAX_PORTS; port++) {
4805 if (!(pdata->enabled_ports & (1 << port)))
4806 continue;
4807 if (strcmp(pdata->cd.port_names[port], "cpu"))
4808 continue;
4809 pdata->cd.netdev[port] = &pdata->netdev->dev;
4810 break;
4811 }
4812 }
4813
Vivien Didelotcaac8542016-06-20 13:14:09 -04004814 if (!compat_info)
4815 return -EINVAL;
4816
Vivien Didelotfad09c72016-06-21 12:28:20 -04004817 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004818 if (!chip) {
4819 err = -ENOMEM;
4820 goto out;
4821 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004822
Vivien Didelotfad09c72016-06-21 12:28:20 -04004823 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004824
Vivien Didelotfad09c72016-06-21 12:28:20 -04004825 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004826 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004827 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004828
Andrew Lunnb4308f02016-11-21 23:26:55 +01004829 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004830 if (IS_ERR(chip->reset)) {
4831 err = PTR_ERR(chip->reset);
4832 goto out;
4833 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004834
Vivien Didelotfad09c72016-06-21 12:28:20 -04004835 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004836 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004837 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004838
Vivien Didelote57e5e72016-08-15 17:19:00 -04004839 mv88e6xxx_phy_init(chip);
4840
Andrew Lunn00baabe2018-05-19 22:31:35 +02004841 if (chip->info->ops->get_eeprom) {
4842 if (np)
4843 of_property_read_u32(np, "eeprom-length",
4844 &chip->eeprom_len);
4845 else
4846 chip->eeprom_len = pdata->eeprom_len;
4847 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004848
Andrew Lunndc30c352016-10-16 19:56:49 +02004849 mutex_lock(&chip->reg_lock);
4850 err = mv88e6xxx_switch_reset(chip);
4851 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004852 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004853 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004854
Andrew Lunndc30c352016-10-16 19:56:49 +02004855 chip->irq = of_irq_get(np, 0);
4856 if (chip->irq == -EPROBE_DEFER) {
4857 err = chip->irq;
4858 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004859 }
4860
Andrew Lunn294d7112018-02-22 22:58:32 +01004861 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004862 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004863 * controllers
4864 */
4865 mutex_lock(&chip->reg_lock);
4866 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004867 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004868 else
4869 err = mv88e6xxx_irq_poll_setup(chip);
4870 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004871
Andrew Lunn294d7112018-02-22 22:58:32 +01004872 if (err)
4873 goto out;
4874
4875 if (chip->info->g2_irqs > 0) {
4876 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004877 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004878 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004879 }
4880
Andrew Lunn294d7112018-02-22 22:58:32 +01004881 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4882 if (err)
4883 goto out_g2_irq;
4884
4885 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4886 if (err)
4887 goto out_g1_atu_prob_irq;
4888
Andrew Lunna3c53be52017-01-24 14:53:50 +01004889 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004890 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004891 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004892
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004893 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004894 if (err)
4895 goto out_mdio;
4896
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004897 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004898
4899out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004900 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004901out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004902 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004903out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004904 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004905out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004906 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004907 mv88e6xxx_g2_irq_free(chip);
4908out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004909 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004910 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004911 else
4912 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004913out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004914 if (pdata)
4915 dev_put(pdata->netdev);
4916
Andrew Lunndc30c352016-10-16 19:56:49 +02004917 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004918}
4919
4920static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4921{
4922 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004923 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004924
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004925 if (chip->info->ptp_support) {
4926 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004927 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004928 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004929
Andrew Lunn930188c2016-08-22 16:01:03 +02004930 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004931 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004932 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004933
Andrew Lunn76f38f12018-03-17 20:21:09 +01004934 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4935 mv88e6xxx_g1_atu_prob_irq_free(chip);
4936
4937 if (chip->info->g2_irqs > 0)
4938 mv88e6xxx_g2_irq_free(chip);
4939
Andrew Lunn76f38f12018-03-17 20:21:09 +01004940 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004941 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004942 else
4943 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004944}
4945
4946static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004947 {
4948 .compatible = "marvell,mv88e6085",
4949 .data = &mv88e6xxx_table[MV88E6085],
4950 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004951 {
4952 .compatible = "marvell,mv88e6190",
4953 .data = &mv88e6xxx_table[MV88E6190],
4954 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004955 { /* sentinel */ },
4956};
4957
4958MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4959
4960static struct mdio_driver mv88e6xxx_driver = {
4961 .probe = mv88e6xxx_probe,
4962 .remove = mv88e6xxx_remove,
4963 .mdiodrv.driver = {
4964 .name = "mv88e6085",
4965 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004966 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004967 },
4968};
4969
Ben Hutchings98e67302011-11-25 14:36:19 +00004970static int __init mv88e6xxx_init(void)
4971{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004972 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004973 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004974}
4975module_init(mv88e6xxx_init);
4976
4977static void __exit mv88e6xxx_cleanup(void)
4978{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004979 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004980 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004981}
4982module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004983
4984MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4985MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4986MODULE_LICENSE("GPL");