blob: 39c780363764086da30e0ca26d206d3f674dde97 [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{
Andrew Lunnec260162019-02-08 22:25:44 +0100650 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200651 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100652 phylink_set(mask, 2500baseT_Full);
653 }
Russell King6c422e32018-08-09 15:38:39 +0200654
655 /* No ethtool bits for 200Mbps */
656 phylink_set(mask, 1000baseT_Full);
657 phylink_set(mask, 1000baseX_Full);
658
659 mv88e6065_phylink_validate(chip, port, mask, state);
660}
661
662static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
663 unsigned long *mask,
664 struct phylink_link_state *state)
665{
666 if (port >= 9) {
667 phylink_set(mask, 10000baseT_Full);
668 phylink_set(mask, 10000baseKR_Full);
669 }
670
671 mv88e6390_phylink_validate(chip, port, mask, state);
672}
673
Russell Kingc9a23562018-05-10 13:17:35 -0700674static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
675 unsigned long *supported,
676 struct phylink_link_state *state)
677{
Russell King6c422e32018-08-09 15:38:39 +0200678 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
679 struct mv88e6xxx_chip *chip = ds->priv;
680
681 /* Allow all the expected bits */
682 phylink_set(mask, Autoneg);
683 phylink_set(mask, Pause);
684 phylink_set_port_modes(mask);
685
686 if (chip->info->ops->phylink_validate)
687 chip->info->ops->phylink_validate(chip, port, mask, state);
688
689 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
690 bitmap_and(state->advertising, state->advertising, mask,
691 __ETHTOOL_LINK_MODE_MASK_NBITS);
692
693 /* We can only operate at 2500BaseX or 1000BaseX. If requested
694 * to advertise both, only report advertising at 2500BaseX.
695 */
696 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700697}
698
699static int mv88e6xxx_link_state(struct dsa_switch *ds, int port,
700 struct phylink_link_state *state)
701{
702 struct mv88e6xxx_chip *chip = ds->priv;
703 int err;
704
705 mutex_lock(&chip->reg_lock);
Russell King6c422e32018-08-09 15:38:39 +0200706 if (chip->info->ops->port_link_state)
707 err = chip->info->ops->port_link_state(chip, port, state);
708 else
709 err = -EOPNOTSUPP;
Russell Kingc9a23562018-05-10 13:17:35 -0700710 mutex_unlock(&chip->reg_lock);
711
712 return err;
713}
714
715static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
716 unsigned int mode,
717 const struct phylink_link_state *state)
718{
719 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn54186b92018-08-09 15:38:37 +0200720 int speed, duplex, link, pause, err;
Russell Kingc9a23562018-05-10 13:17:35 -0700721
Marek Vasutd700ec42018-09-12 00:15:24 +0200722 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700723 return;
724
725 if (mode == MLO_AN_FIXED) {
726 link = LINK_FORCED_UP;
727 speed = state->speed;
728 duplex = state->duplex;
Marek Vasutd700ec42018-09-12 00:15:24 +0200729 } else if (!mv88e6xxx_phy_is_internal(ds, port)) {
730 link = state->link;
731 speed = state->speed;
732 duplex = state->duplex;
Russell Kingc9a23562018-05-10 13:17:35 -0700733 } else {
734 speed = SPEED_UNFORCED;
735 duplex = DUPLEX_UNFORCED;
736 link = LINK_UNFORCED;
737 }
Andrew Lunn54186b92018-08-09 15:38:37 +0200738 pause = !!phylink_test(state->advertising, Pause);
Russell Kingc9a23562018-05-10 13:17:35 -0700739
740 mutex_lock(&chip->reg_lock);
Andrew Lunn54186b92018-08-09 15:38:37 +0200741 err = mv88e6xxx_port_setup_mac(chip, port, link, speed, duplex, pause,
Russell Kingc9a23562018-05-10 13:17:35 -0700742 state->interface);
743 mutex_unlock(&chip->reg_lock);
744
745 if (err && err != -EOPNOTSUPP)
746 dev_err(ds->dev, "p%d: failed to configure MAC\n", port);
747}
748
749static void mv88e6xxx_mac_link_force(struct dsa_switch *ds, int port, int link)
750{
751 struct mv88e6xxx_chip *chip = ds->priv;
752 int err;
753
754 mutex_lock(&chip->reg_lock);
755 err = chip->info->ops->port_set_link(chip, port, link);
756 mutex_unlock(&chip->reg_lock);
757
758 if (err)
759 dev_err(chip->dev, "p%d: failed to force MAC link\n", port);
760}
761
762static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
763 unsigned int mode,
764 phy_interface_t interface)
765{
766 if (mode == MLO_AN_FIXED)
767 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_DOWN);
768}
769
770static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
771 unsigned int mode, phy_interface_t interface,
772 struct phy_device *phydev)
773{
774 if (mode == MLO_AN_FIXED)
775 mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
776}
777
Andrew Lunna605a0f2016-11-21 23:26:58 +0100778static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000779{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100780 if (!chip->info->ops->stats_snapshot)
781 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000782
Andrew Lunna605a0f2016-11-21 23:26:58 +0100783 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000784}
785
Andrew Lunne413e7e2015-04-02 04:06:38 +0200786static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100787 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
788 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
789 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
790 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
791 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
792 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
793 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
794 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
795 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
796 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
797 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
798 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
799 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
800 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
801 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
802 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
803 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
804 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
805 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
806 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
807 { "single", 4, 0x14, STATS_TYPE_BANK0, },
808 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
809 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
810 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
811 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
812 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
813 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
814 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
815 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
816 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
817 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
818 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
819 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
820 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
821 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
822 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
823 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
824 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
825 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
826 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
827 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
828 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
829 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
830 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
831 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
832 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
833 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
834 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
835 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
836 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
837 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
838 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
839 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
840 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
841 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
842 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
843 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
844 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
845 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200846};
847
Vivien Didelotfad09c72016-06-21 12:28:20 -0400848static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100849 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100850 int port, u16 bank1_select,
851 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200852{
Andrew Lunn80c46272015-06-20 18:42:30 +0200853 u32 low;
854 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100855 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200856 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200857 u64 value;
858
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100859 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100860 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200861 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
862 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800863 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200864
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200865 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100866 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200867 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
868 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800869 return U64_MAX;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200870 high = reg;
Andrew Lunn80c46272015-06-20 18:42:30 +0200871 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100872 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100873 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100874 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100875 /* fall through */
876 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100877 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100878 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100879 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100880 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500881 break;
882 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800883 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200884 }
885 value = (((u64)high) << 16) | low;
886 return value;
887}
888
Andrew Lunn436fe172018-03-01 02:02:29 +0100889static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
890 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100891{
892 struct mv88e6xxx_hw_stat *stat;
893 int i, j;
894
895 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
896 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100897 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100898 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
899 ETH_GSTRING_LEN);
900 j++;
901 }
902 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100903
904 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100905}
906
Andrew Lunn436fe172018-03-01 02:02:29 +0100907static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
908 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100909{
Andrew Lunn436fe172018-03-01 02:02:29 +0100910 return mv88e6xxx_stats_get_strings(chip, data,
911 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100912}
913
Andrew Lunn436fe172018-03-01 02:02:29 +0100914static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
915 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100916{
Andrew Lunn436fe172018-03-01 02:02:29 +0100917 return mv88e6xxx_stats_get_strings(chip, data,
918 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100919}
920
Andrew Lunn65f60e42018-03-28 23:50:28 +0200921static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
922 "atu_member_violation",
923 "atu_miss_violation",
924 "atu_full_violation",
925 "vtu_member_violation",
926 "vtu_miss_violation",
927};
928
929static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
930{
931 unsigned int i;
932
933 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
934 strlcpy(data + i * ETH_GSTRING_LEN,
935 mv88e6xxx_atu_vtu_stats_strings[i],
936 ETH_GSTRING_LEN);
937}
938
Andrew Lunndfafe442016-11-21 23:27:02 +0100939static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700940 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100941{
Vivien Didelot04bed142016-08-31 18:06:13 -0400942 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100943 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100944
Florian Fainelli89f09042018-04-25 12:12:50 -0700945 if (stringset != ETH_SS_STATS)
946 return;
947
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100948 mutex_lock(&chip->reg_lock);
949
Andrew Lunndfafe442016-11-21 23:27:02 +0100950 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100951 count = chip->info->ops->stats_get_strings(chip, data);
952
953 if (chip->info->ops->serdes_get_strings) {
954 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200955 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100956 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100957
Andrew Lunn65f60e42018-03-28 23:50:28 +0200958 data += count * ETH_GSTRING_LEN;
959 mv88e6xxx_atu_vtu_get_strings(data);
960
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100961 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +0100962}
963
964static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
965 int types)
966{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100967 struct mv88e6xxx_hw_stat *stat;
968 int i, j;
969
970 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
971 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100972 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100973 j++;
974 }
975 return j;
976}
977
Andrew Lunndfafe442016-11-21 23:27:02 +0100978static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
979{
980 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
981 STATS_TYPE_PORT);
982}
983
984static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
985{
986 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
987 STATS_TYPE_BANK1);
988}
989
Florian Fainelli89f09042018-04-25 12:12:50 -0700990static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100991{
992 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100993 int serdes_count = 0;
994 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100995
Florian Fainelli89f09042018-04-25 12:12:50 -0700996 if (sset != ETH_SS_STATS)
997 return 0;
998
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100999 mutex_lock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001000 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001001 count = chip->info->ops->stats_get_sset_count(chip);
1002 if (count < 0)
1003 goto out;
1004
1005 if (chip->info->ops->serdes_get_sset_count)
1006 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1007 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001008 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001009 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001010 goto out;
1011 }
1012 count += serdes_count;
1013 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1014
Andrew Lunn436fe172018-03-01 02:02:29 +01001015out:
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001016 mutex_unlock(&chip->reg_lock);
Andrew Lunndfafe442016-11-21 23:27:02 +01001017
Andrew Lunn436fe172018-03-01 02:02:29 +01001018 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001019}
1020
Andrew Lunn436fe172018-03-01 02:02:29 +01001021static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1022 uint64_t *data, int types,
1023 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001024{
1025 struct mv88e6xxx_hw_stat *stat;
1026 int i, j;
1027
1028 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1029 stat = &mv88e6xxx_hw_stats[i];
1030 if (stat->type & types) {
Andrew Lunn377cda12018-02-15 14:38:34 +01001031 mutex_lock(&chip->reg_lock);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001032 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1033 bank1_select,
1034 histogram);
Andrew Lunn377cda12018-02-15 14:38:34 +01001035 mutex_unlock(&chip->reg_lock);
1036
Andrew Lunn052f9472016-11-21 23:27:03 +01001037 j++;
1038 }
1039 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001040 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001041}
1042
Andrew Lunn436fe172018-03-01 02:02:29 +01001043static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1044 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001045{
1046 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001047 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001048 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001049}
1050
Andrew Lunn436fe172018-03-01 02:02:29 +01001051static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1052 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001053{
1054 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001055 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001056 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1057 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001058}
1059
Andrew Lunn436fe172018-03-01 02:02:29 +01001060static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1061 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001062{
1063 return mv88e6xxx_stats_get_stats(chip, port, data,
1064 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001065 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1066 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001067}
1068
Andrew Lunn65f60e42018-03-28 23:50:28 +02001069static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1070 uint64_t *data)
1071{
1072 *data++ = chip->ports[port].atu_member_violation;
1073 *data++ = chip->ports[port].atu_miss_violation;
1074 *data++ = chip->ports[port].atu_full_violation;
1075 *data++ = chip->ports[port].vtu_member_violation;
1076 *data++ = chip->ports[port].vtu_miss_violation;
1077}
1078
Andrew Lunn052f9472016-11-21 23:27:03 +01001079static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1080 uint64_t *data)
1081{
Andrew Lunn436fe172018-03-01 02:02:29 +01001082 int count = 0;
1083
Andrew Lunn052f9472016-11-21 23:27:03 +01001084 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001085 count = chip->info->ops->stats_get_stats(chip, port, data);
1086
Andrew Lunn65f60e42018-03-28 23:50:28 +02001087 mutex_lock(&chip->reg_lock);
Andrew Lunn436fe172018-03-01 02:02:29 +01001088 if (chip->info->ops->serdes_get_stats) {
1089 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001090 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001091 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001092 data += count;
1093 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
1094 mutex_unlock(&chip->reg_lock);
Andrew Lunn052f9472016-11-21 23:27:03 +01001095}
1096
Vivien Didelotf81ec902016-05-09 13:22:58 -04001097static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1098 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001099{
Vivien Didelot04bed142016-08-31 18:06:13 -04001100 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001101 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001102
Vivien Didelotfad09c72016-06-21 12:28:20 -04001103 mutex_lock(&chip->reg_lock);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001104
Andrew Lunna605a0f2016-11-21 23:26:58 +01001105 ret = mv88e6xxx_stats_snapshot(chip, port);
Andrew Lunn377cda12018-02-15 14:38:34 +01001106 mutex_unlock(&chip->reg_lock);
1107
1108 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001109 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001110
1111 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001112
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001113}
Ben Hutchings98e67302011-11-25 14:36:19 +00001114
Vivien Didelotf81ec902016-05-09 13:22:58 -04001115static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001116{
1117 return 32 * sizeof(u16);
1118}
1119
Vivien Didelotf81ec902016-05-09 13:22:58 -04001120static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1121 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001122{
Vivien Didelot04bed142016-08-31 18:06:13 -04001123 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001124 int err;
1125 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001126 u16 *p = _p;
1127 int i;
1128
Vivien Didelota5f39322018-12-17 16:05:21 -05001129 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001130
1131 memset(p, 0xff, 32 * sizeof(u16));
1132
Vivien Didelotfad09c72016-06-21 12:28:20 -04001133 mutex_lock(&chip->reg_lock);
Vivien Didelot23062512016-05-09 13:22:45 -04001134
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001135 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001136
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001137 err = mv88e6xxx_port_read(chip, port, i, &reg);
1138 if (!err)
1139 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001140 }
Vivien Didelot23062512016-05-09 13:22:45 -04001141
Vivien Didelotfad09c72016-06-21 12:28:20 -04001142 mutex_unlock(&chip->reg_lock);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001143}
1144
Vivien Didelot08f50062017-08-01 16:32:41 -04001145static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1146 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001147{
Vivien Didelot5480db62017-08-01 16:32:40 -04001148 /* Nothing to do on the port's MAC */
1149 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001150}
1151
Vivien Didelot08f50062017-08-01 16:32:41 -04001152static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1153 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001154{
Vivien Didelot5480db62017-08-01 16:32:40 -04001155 /* Nothing to do on the port's MAC */
1156 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001157}
1158
Vivien Didelote5887a22017-03-30 17:37:11 -04001159static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001160{
Vivien Didelote5887a22017-03-30 17:37:11 -04001161 struct dsa_switch *ds = NULL;
1162 struct net_device *br;
1163 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001164 int i;
1165
Vivien Didelote5887a22017-03-30 17:37:11 -04001166 if (dev < DSA_MAX_SWITCHES)
1167 ds = chip->ds->dst->ds[dev];
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001168
Vivien Didelote5887a22017-03-30 17:37:11 -04001169 /* Prevent frames from unknown switch or port */
1170 if (!ds || port >= ds->num_ports)
1171 return 0;
1172
1173 /* Frames from DSA links and CPU ports can egress any local port */
1174 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
1175 return mv88e6xxx_port_mask(chip);
1176
1177 br = ds->ports[port].bridge_dev;
1178 pvlan = 0;
1179
1180 /* Frames from user ports can egress any local DSA links and CPU ports,
1181 * as well as any local member of their bridge group.
1182 */
1183 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1184 if (dsa_is_cpu_port(chip->ds, i) ||
1185 dsa_is_dsa_port(chip->ds, i) ||
Vivien Didelotc8652c82017-10-16 11:12:19 -04001186 (br && dsa_to_port(chip->ds, i)->bridge_dev == br))
Vivien Didelote5887a22017-03-30 17:37:11 -04001187 pvlan |= BIT(i);
1188
1189 return pvlan;
1190}
1191
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001192static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001193{
1194 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001195
1196 /* prevent frames from going back out of the port they came in on */
1197 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001198
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001199 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001200}
1201
Vivien Didelotf81ec902016-05-09 13:22:58 -04001202static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1203 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001204{
Vivien Didelot04bed142016-08-31 18:06:13 -04001205 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001206 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001207
Vivien Didelotfad09c72016-06-21 12:28:20 -04001208 mutex_lock(&chip->reg_lock);
Vivien Didelotf894c292017-06-08 18:34:10 -04001209 err = mv88e6xxx_port_set_state(chip, port, state);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001210 mutex_unlock(&chip->reg_lock);
Vivien Didelot553eb542016-05-13 20:38:23 -04001211
1212 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001213 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001214}
1215
Vivien Didelot93e18d62018-05-11 17:16:35 -04001216static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1217{
1218 int err;
1219
1220 if (chip->info->ops->ieee_pri_map) {
1221 err = chip->info->ops->ieee_pri_map(chip);
1222 if (err)
1223 return err;
1224 }
1225
1226 if (chip->info->ops->ip_pri_map) {
1227 err = chip->info->ops->ip_pri_map(chip);
1228 if (err)
1229 return err;
1230 }
1231
1232 return 0;
1233}
1234
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001235static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1236{
1237 int target, port;
1238 int err;
1239
1240 if (!chip->info->global2_addr)
1241 return 0;
1242
1243 /* Initialize the routing port to the 32 possible target devices */
1244 for (target = 0; target < 32; target++) {
1245 port = 0x1f;
1246 if (target < DSA_MAX_SWITCHES)
1247 if (chip->ds->rtable[target] != DSA_RTABLE_NONE)
1248 port = chip->ds->rtable[target];
1249
1250 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1251 if (err)
1252 return err;
1253 }
1254
Vivien Didelot02317e62018-05-09 11:38:49 -04001255 if (chip->info->ops->set_cascade_port) {
1256 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1257 err = chip->info->ops->set_cascade_port(chip, port);
1258 if (err)
1259 return err;
1260 }
1261
Vivien Didelot23c98912018-05-09 11:38:50 -04001262 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1263 if (err)
1264 return err;
1265
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001266 return 0;
1267}
1268
Vivien Didelotb28f8722018-04-26 21:56:44 -04001269static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1270{
1271 /* Clear all trunk masks and mapping */
1272 if (chip->info->global2_addr)
1273 return mv88e6xxx_g2_trunk_clear(chip);
1274
1275 return 0;
1276}
1277
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001278static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1279{
1280 if (chip->info->ops->rmu_disable)
1281 return chip->info->ops->rmu_disable(chip);
1282
1283 return 0;
1284}
1285
Vivien Didelot9e907d72017-07-17 13:03:43 -04001286static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1287{
1288 if (chip->info->ops->pot_clear)
1289 return chip->info->ops->pot_clear(chip);
1290
1291 return 0;
1292}
1293
Vivien Didelot51c901a2017-07-17 13:03:41 -04001294static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1295{
1296 if (chip->info->ops->mgmt_rsvd2cpu)
1297 return chip->info->ops->mgmt_rsvd2cpu(chip);
1298
1299 return 0;
1300}
1301
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001302static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1303{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001304 int err;
1305
Vivien Didelotdaefc942017-03-11 16:12:54 -05001306 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1307 if (err)
1308 return err;
1309
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001310 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1311 if (err)
1312 return err;
1313
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001314 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1315}
1316
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001317static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1318{
1319 int port;
1320 int err;
1321
1322 if (!chip->info->ops->irl_init_all)
1323 return 0;
1324
1325 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1326 /* Disable ingress rate limiting by resetting all per port
1327 * ingress rate limit resources to their initial state.
1328 */
1329 err = chip->info->ops->irl_init_all(chip, port);
1330 if (err)
1331 return err;
1332 }
1333
1334 return 0;
1335}
1336
Vivien Didelot04a69a12017-10-13 14:18:05 -04001337static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1338{
1339 if (chip->info->ops->set_switch_mac) {
1340 u8 addr[ETH_ALEN];
1341
1342 eth_random_addr(addr);
1343
1344 return chip->info->ops->set_switch_mac(chip, addr);
1345 }
1346
1347 return 0;
1348}
1349
Vivien Didelot17a15942017-03-30 17:37:09 -04001350static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1351{
1352 u16 pvlan = 0;
1353
1354 if (!mv88e6xxx_has_pvt(chip))
1355 return -EOPNOTSUPP;
1356
1357 /* Skip the local source device, which uses in-chip port VLAN */
1358 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001359 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001360
1361 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1362}
1363
Vivien Didelot81228992017-03-30 17:37:08 -04001364static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1365{
Vivien Didelot17a15942017-03-30 17:37:09 -04001366 int dev, port;
1367 int err;
1368
Vivien Didelot81228992017-03-30 17:37:08 -04001369 if (!mv88e6xxx_has_pvt(chip))
1370 return 0;
1371
1372 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1373 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1374 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001375 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1376 if (err)
1377 return err;
1378
1379 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1380 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1381 err = mv88e6xxx_pvt_map(chip, dev, port);
1382 if (err)
1383 return err;
1384 }
1385 }
1386
1387 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001388}
1389
Vivien Didelot749efcb2016-09-22 16:49:24 -04001390static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1391{
1392 struct mv88e6xxx_chip *chip = ds->priv;
1393 int err;
1394
1395 mutex_lock(&chip->reg_lock);
Vivien Didelote606ca32017-03-11 16:12:55 -05001396 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001397 mutex_unlock(&chip->reg_lock);
1398
1399 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001400 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001401}
1402
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001403static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1404{
1405 if (!chip->info->max_vid)
1406 return 0;
1407
1408 return mv88e6xxx_g1_vtu_flush(chip);
1409}
1410
Vivien Didelotf1394b782017-05-01 14:05:22 -04001411static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1412 struct mv88e6xxx_vtu_entry *entry)
1413{
1414 if (!chip->info->ops->vtu_getnext)
1415 return -EOPNOTSUPP;
1416
1417 return chip->info->ops->vtu_getnext(chip, entry);
1418}
1419
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001420static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1421 struct mv88e6xxx_vtu_entry *entry)
1422{
1423 if (!chip->info->ops->vtu_loadpurge)
1424 return -EOPNOTSUPP;
1425
1426 return chip->info->ops->vtu_loadpurge(chip, entry);
1427}
1428
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001429static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001430{
1431 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001432 struct mv88e6xxx_vtu_entry vlan = {
1433 .vid = chip->info->max_vid,
1434 };
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001435 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001436
1437 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1438
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001439 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001440 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001441 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001442 if (err)
1443 return err;
1444
1445 set_bit(*fid, fid_bitmap);
1446 }
1447
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001448 /* Set every FID bit used by the VLAN entries */
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001449 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001450 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001451 if (err)
1452 return err;
1453
1454 if (!vlan.valid)
1455 break;
1456
1457 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001458 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001459
1460 /* The reset value 0x000 is used to indicate that multiple address
1461 * databases are not needed. Return the next positive available.
1462 */
1463 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001464 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001465 return -ENOSPC;
1466
1467 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001468 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001469}
1470
Vivien Didelot567aa592017-05-01 14:05:25 -04001471static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1472 struct mv88e6xxx_vtu_entry *entry, bool new)
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001473{
1474 int err;
1475
1476 if (!vid)
1477 return -EINVAL;
1478
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001479 entry->vid = vid - 1;
1480 entry->valid = false;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001481
Vivien Didelotf1394b782017-05-01 14:05:22 -04001482 err = mv88e6xxx_vtu_getnext(chip, entry);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001483 if (err)
1484 return err;
1485
Vivien Didelot567aa592017-05-01 14:05:25 -04001486 if (entry->vid == vid && entry->valid)
1487 return 0;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001488
Vivien Didelot567aa592017-05-01 14:05:25 -04001489 if (new) {
1490 int i;
1491
1492 /* Initialize a fresh VLAN entry */
1493 memset(entry, 0, sizeof(*entry));
1494 entry->valid = true;
1495 entry->vid = vid;
1496
Vivien Didelot553a7682017-06-07 18:12:16 -04001497 /* Exclude all ports */
Vivien Didelot567aa592017-05-01 14:05:25 -04001498 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
Vivien Didelot553a7682017-06-07 18:12:16 -04001499 entry->member[i] =
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001500 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot567aa592017-05-01 14:05:25 -04001501
1502 return mv88e6xxx_atu_new(chip, &entry->fid);
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001503 }
1504
Vivien Didelot567aa592017-05-01 14:05:25 -04001505 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1506 return -EOPNOTSUPP;
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001507}
1508
Vivien Didelotda9c3592016-02-12 12:09:40 -05001509static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1510 u16 vid_begin, u16 vid_end)
1511{
Vivien Didelot04bed142016-08-31 18:06:13 -04001512 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot3afb4bd2017-05-01 14:05:16 -04001513 struct mv88e6xxx_vtu_entry vlan = {
1514 .vid = vid_begin - 1,
1515 };
Vivien Didelotda9c3592016-02-12 12:09:40 -05001516 int i, err;
1517
Andrew Lunndb06ae412017-09-25 23:32:20 +02001518 /* DSA and CPU ports have to be members of multiple vlans */
1519 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1520 return 0;
1521
Vivien Didelotda9c3592016-02-12 12:09:40 -05001522 if (!vid_begin)
1523 return -EOPNOTSUPP;
1524
Vivien Didelotfad09c72016-06-21 12:28:20 -04001525 mutex_lock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001526
Vivien Didelotda9c3592016-02-12 12:09:40 -05001527 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001528 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001529 if (err)
1530 goto unlock;
1531
1532 if (!vlan.valid)
1533 break;
1534
1535 if (vlan.vid > vid_end)
1536 break;
1537
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001538 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001539 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1540 continue;
1541
Andrew Lunncd886462017-11-09 22:29:53 +01001542 if (!ds->ports[i].slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001543 continue;
1544
Vivien Didelotbd00e052017-05-01 14:05:11 -04001545 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001546 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001547 continue;
1548
Vivien Didelotc8652c82017-10-16 11:12:19 -04001549 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelotfae8a252017-01-27 15:29:42 -05001550 ds->ports[port].bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001551 break; /* same bridge, check next VLAN */
1552
Vivien Didelotc8652c82017-10-16 11:12:19 -04001553 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001554 continue;
1555
Andrew Lunn743fcc22017-11-09 22:29:54 +01001556 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1557 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001558 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelotda9c3592016-02-12 12:09:40 -05001559 err = -EOPNOTSUPP;
1560 goto unlock;
1561 }
1562 } while (vlan.vid < vid_end);
1563
1564unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001565 mutex_unlock(&chip->reg_lock);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001566
1567 return err;
1568}
1569
Vivien Didelotf81ec902016-05-09 13:22:58 -04001570static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1571 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001572{
Vivien Didelot04bed142016-08-31 18:06:13 -04001573 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001574 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1575 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001576 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001577
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001578 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001579 return -EOPNOTSUPP;
1580
Vivien Didelotfad09c72016-06-21 12:28:20 -04001581 mutex_lock(&chip->reg_lock);
Vivien Didelot385a0992016-11-04 03:23:31 +01001582 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001583 mutex_unlock(&chip->reg_lock);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001584
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001585 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001586}
1587
Vivien Didelot57d32312016-06-20 13:13:58 -04001588static int
1589mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001590 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001591{
Vivien Didelot04bed142016-08-31 18:06:13 -04001592 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001593 int err;
1594
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001595 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001596 return -EOPNOTSUPP;
1597
Vivien Didelotda9c3592016-02-12 12:09:40 -05001598 /* If the requested port doesn't belong to the same bridge as the VLAN
1599 * members, do not support it (yet) and fallback to software VLAN.
1600 */
1601 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1602 vlan->vid_end);
1603 if (err)
1604 return err;
1605
Vivien Didelot76e398a2015-11-01 12:33:55 -05001606 /* We don't need any dynamic resource from the kernel (yet),
1607 * so skip the prepare phase.
1608 */
1609 return 0;
1610}
1611
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001612static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1613 const unsigned char *addr, u16 vid,
1614 u8 state)
1615{
1616 struct mv88e6xxx_vtu_entry vlan;
1617 struct mv88e6xxx_atu_entry entry;
1618 int err;
1619
1620 /* Null VLAN ID corresponds to the port private database */
1621 if (vid == 0)
1622 err = mv88e6xxx_port_get_fid(chip, port, &vlan.fid);
1623 else
1624 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
1625 if (err)
1626 return err;
1627
1628 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1629 ether_addr_copy(entry.mac, addr);
1630 eth_addr_dec(entry.mac);
1631
1632 err = mv88e6xxx_g1_atu_getnext(chip, vlan.fid, &entry);
1633 if (err)
1634 return err;
1635
1636 /* Initialize a fresh ATU entry if it isn't found */
1637 if (entry.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED ||
1638 !ether_addr_equal(entry.mac, addr)) {
1639 memset(&entry, 0, sizeof(entry));
1640 ether_addr_copy(entry.mac, addr);
1641 }
1642
1643 /* Purge the ATU entry only if no port is using it anymore */
1644 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED) {
1645 entry.portvec &= ~BIT(port);
1646 if (!entry.portvec)
1647 entry.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
1648 } else {
1649 entry.portvec |= BIT(port);
1650 entry.state = state;
1651 }
1652
1653 return mv88e6xxx_g1_atu_loadpurge(chip, vlan.fid, &entry);
1654}
1655
Andrew Lunn87fa8862017-11-09 22:29:56 +01001656static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1657 u16 vid)
1658{
1659 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1660 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1661
1662 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1663}
1664
1665static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1666{
1667 int port;
1668 int err;
1669
1670 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1671 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1672 if (err)
1673 return err;
1674 }
1675
1676 return 0;
1677}
1678
Vivien Didelotfad09c72016-06-21 12:28:20 -04001679static int _mv88e6xxx_port_vlan_add(struct mv88e6xxx_chip *chip, int port,
Vivien Didelotc91498e2017-06-07 18:12:13 -04001680 u16 vid, u8 member)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001681{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001682 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001683 int err;
1684
Vivien Didelot567aa592017-05-01 14:05:25 -04001685 err = mv88e6xxx_vtu_get(chip, vid, &vlan, true);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001686 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001687 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001688
Vivien Didelotc91498e2017-06-07 18:12:13 -04001689 vlan.member[port] = member;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001690
Andrew Lunn87fa8862017-11-09 22:29:56 +01001691 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1692 if (err)
1693 return err;
1694
1695 return mv88e6xxx_broadcast_setup(chip, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001696}
1697
Vivien Didelotf81ec902016-05-09 13:22:58 -04001698static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001699 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001700{
Vivien Didelot04bed142016-08-31 18:06:13 -04001701 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001702 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1703 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001704 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001705 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001706
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001707 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001708 return;
1709
Vivien Didelotc91498e2017-06-07 18:12:13 -04001710 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001711 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001712 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001713 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001714 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001715 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001716
Vivien Didelotfad09c72016-06-21 12:28:20 -04001717 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001718
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001719 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Vivien Didelotc91498e2017-06-07 18:12:13 -04001720 if (_mv88e6xxx_port_vlan_add(chip, port, vid, member))
Vivien Didelot774439e52017-06-08 18:34:08 -04001721 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1722 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001723
Vivien Didelot77064f32016-11-04 03:23:30 +01001724 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001725 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1726 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001727
Vivien Didelotfad09c72016-06-21 12:28:20 -04001728 mutex_unlock(&chip->reg_lock);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001729}
1730
Vivien Didelotfad09c72016-06-21 12:28:20 -04001731static int _mv88e6xxx_port_vlan_del(struct mv88e6xxx_chip *chip,
Andrew Lunn158bc062016-04-28 21:24:06 -04001732 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001733{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001734 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001735 int i, err;
1736
Vivien Didelot567aa592017-05-01 14:05:25 -04001737 err = mv88e6xxx_vtu_get(chip, vid, &vlan, false);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001738 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001739 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001740
Vivien Didelot2fb5ef02016-02-26 13:16:01 -05001741 /* Tell switchdev if this VLAN is handled in software */
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001742 if (vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05001743 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001744
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001745 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001746
1747 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001748 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001749 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001750 if (vlan.member[i] !=
1751 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04001752 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001753 break;
1754 }
1755 }
1756
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001757 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001758 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001759 return err;
1760
Vivien Didelote606ca32017-03-11 16:12:55 -05001761 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001762}
1763
Vivien Didelotf81ec902016-05-09 13:22:58 -04001764static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
1765 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001766{
Vivien Didelot04bed142016-08-31 18:06:13 -04001767 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001768 u16 pvid, vid;
1769 int err = 0;
1770
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001771 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001772 return -EOPNOTSUPP;
1773
Vivien Didelotfad09c72016-06-21 12:28:20 -04001774 mutex_lock(&chip->reg_lock);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001775
Vivien Didelot77064f32016-11-04 03:23:30 +01001776 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001777 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001778 goto unlock;
1779
Vivien Didelot76e398a2015-11-01 12:33:55 -05001780 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04001781 err = _mv88e6xxx_port_vlan_del(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001782 if (err)
1783 goto unlock;
1784
1785 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01001786 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001787 if (err)
1788 goto unlock;
1789 }
1790 }
1791
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001792unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04001793 mutex_unlock(&chip->reg_lock);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001794
1795 return err;
1796}
1797
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001798static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
1799 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07001800{
Vivien Didelot04bed142016-08-31 18:06:13 -04001801 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001802 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04001803
Vivien Didelotfad09c72016-06-21 12:28:20 -04001804 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001805 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1806 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001807 mutex_unlock(&chip->reg_lock);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03001808
1809 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001810}
1811
Vivien Didelotf81ec902016-05-09 13:22:58 -04001812static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001813 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07001814{
Vivien Didelot04bed142016-08-31 18:06:13 -04001815 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001816 int err;
David S. Millercdf09692015-08-11 12:00:37 -07001817
Vivien Didelotfad09c72016-06-21 12:28:20 -04001818 mutex_lock(&chip->reg_lock);
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03001819 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04001820 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001821 mutex_unlock(&chip->reg_lock);
David S. Millercdf09692015-08-11 12:00:37 -07001822
Vivien Didelot83dabd12016-08-31 11:50:04 -04001823 return err;
David S. Millercdf09692015-08-11 12:00:37 -07001824}
1825
Vivien Didelot83dabd12016-08-31 11:50:04 -04001826static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
1827 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001828 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001829{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001830 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001831 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001832 int err;
1833
Vivien Didelot27c0e602017-06-15 12:14:01 -04001834 addr.state = MV88E6XXX_G1_ATU_DATA_STATE_UNUSED;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001835 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001836
1837 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001838 mutex_lock(&chip->reg_lock);
Vivien Didelotdabc1a92017-03-11 16:12:53 -05001839 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Andrew Lunna61e5402018-02-15 14:38:35 +01001840 mutex_unlock(&chip->reg_lock);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001841 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001842 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001843
Vivien Didelot27c0e602017-06-15 12:14:01 -04001844 if (addr.state == MV88E6XXX_G1_ATU_DATA_STATE_UNUSED)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001845 break;
1846
Vivien Didelot01bd96c2017-03-11 16:12:57 -05001847 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001848 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001849
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001850 if (!is_unicast_ether_addr(addr.mac))
1851 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04001852
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001853 is_static = (addr.state ==
1854 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
1855 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001856 if (err)
1857 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05001858 } while (!is_broadcast_ether_addr(addr.mac));
1859
1860 return err;
1861}
1862
Vivien Didelot83dabd12016-08-31 11:50:04 -04001863static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001864 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04001865{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001866 struct mv88e6xxx_vtu_entry vlan = {
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001867 .vid = chip->info->max_vid,
Vivien Didelot83dabd12016-08-31 11:50:04 -04001868 };
1869 u16 fid;
1870 int err;
1871
1872 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Andrew Lunna61e5402018-02-15 14:38:35 +01001873 mutex_lock(&chip->reg_lock);
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001874 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Andrew Lunna61e5402018-02-15 14:38:35 +01001875 mutex_unlock(&chip->reg_lock);
1876
Vivien Didelot83dabd12016-08-31 11:50:04 -04001877 if (err)
1878 return err;
1879
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001880 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001881 if (err)
1882 return err;
1883
1884 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot83dabd12016-08-31 11:50:04 -04001885 do {
Andrew Lunna61e5402018-02-15 14:38:35 +01001886 mutex_lock(&chip->reg_lock);
Vivien Didelotf1394b782017-05-01 14:05:22 -04001887 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Andrew Lunna61e5402018-02-15 14:38:35 +01001888 mutex_unlock(&chip->reg_lock);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001889 if (err)
1890 return err;
1891
1892 if (!vlan.valid)
1893 break;
1894
1895 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001896 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001897 if (err)
1898 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001899 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04001900
1901 return err;
1902}
1903
Vivien Didelotf81ec902016-05-09 13:22:58 -04001904static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03001905 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04001906{
Vivien Didelot04bed142016-08-31 18:06:13 -04001907 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotf33475b2015-10-22 09:34:41 -04001908
Andrew Lunna61e5402018-02-15 14:38:35 +01001909 return mv88e6xxx_port_db_dump(chip, port, cb, data);
Vivien Didelotf33475b2015-10-22 09:34:41 -04001910}
1911
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001912static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
1913 struct net_device *br)
1914{
Vivien Didelote96a6e02017-03-30 17:37:13 -04001915 struct dsa_switch *ds;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001916 int port;
Vivien Didelote96a6e02017-03-30 17:37:13 -04001917 int dev;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001918 int err;
1919
1920 /* Remap the Port VLAN of each local bridge group member */
1921 for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) {
1922 if (chip->ds->ports[port].bridge_dev == br) {
1923 err = mv88e6xxx_port_vlan_map(chip, port);
1924 if (err)
1925 return err;
1926 }
1927 }
1928
Vivien Didelote96a6e02017-03-30 17:37:13 -04001929 if (!mv88e6xxx_has_pvt(chip))
1930 return 0;
1931
1932 /* Remap the Port VLAN of each cross-chip bridge group member */
1933 for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) {
1934 ds = chip->ds->dst->ds[dev];
1935 if (!ds)
1936 break;
1937
1938 for (port = 0; port < ds->num_ports; ++port) {
1939 if (ds->ports[port].bridge_dev == br) {
1940 err = mv88e6xxx_pvt_map(chip, dev, port);
1941 if (err)
1942 return err;
1943 }
1944 }
1945 }
1946
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001947 return 0;
1948}
1949
Vivien Didelotf81ec902016-05-09 13:22:58 -04001950static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05001951 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001952{
Vivien Didelot04bed142016-08-31 18:06:13 -04001953 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001954 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001955
Vivien Didelotfad09c72016-06-21 12:28:20 -04001956 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001957 err = mv88e6xxx_bridge_map(chip, br);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001958 mutex_unlock(&chip->reg_lock);
Vivien Didelota6692752016-02-12 12:09:39 -05001959
Vivien Didelot466dfa02016-02-26 13:16:05 -05001960 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001961}
1962
Vivien Didelotf123f2f2017-01-27 15:29:41 -05001963static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
1964 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05001965{
Vivien Didelot04bed142016-08-31 18:06:13 -04001966 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05001967
Vivien Didelotfad09c72016-06-21 12:28:20 -04001968 mutex_lock(&chip->reg_lock);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001969 if (mv88e6xxx_bridge_map(chip, br) ||
1970 mv88e6xxx_port_vlan_map(chip, port))
1971 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vivien Didelotfad09c72016-06-21 12:28:20 -04001972 mutex_unlock(&chip->reg_lock);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05001973}
1974
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001975static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
1976 int port, struct net_device *br)
1977{
1978 struct mv88e6xxx_chip *chip = ds->priv;
1979 int err;
1980
1981 if (!mv88e6xxx_has_pvt(chip))
1982 return 0;
1983
1984 mutex_lock(&chip->reg_lock);
1985 err = mv88e6xxx_pvt_map(chip, dev, port);
1986 mutex_unlock(&chip->reg_lock);
1987
1988 return err;
1989}
1990
1991static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
1992 int port, struct net_device *br)
1993{
1994 struct mv88e6xxx_chip *chip = ds->priv;
1995
1996 if (!mv88e6xxx_has_pvt(chip))
1997 return;
1998
1999 mutex_lock(&chip->reg_lock);
2000 if (mv88e6xxx_pvt_map(chip, dev, port))
2001 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
2002 mutex_unlock(&chip->reg_lock);
2003}
2004
Vivien Didelot17e708b2016-12-05 17:30:27 -05002005static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2006{
2007 if (chip->info->ops->reset)
2008 return chip->info->ops->reset(chip);
2009
2010 return 0;
2011}
2012
Vivien Didelot309eca62016-12-05 17:30:26 -05002013static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2014{
2015 struct gpio_desc *gpiod = chip->reset;
2016
2017 /* If there is a GPIO connected to the reset pin, toggle it */
2018 if (gpiod) {
2019 gpiod_set_value_cansleep(gpiod, 1);
2020 usleep_range(10000, 20000);
2021 gpiod_set_value_cansleep(gpiod, 0);
2022 usleep_range(10000, 20000);
2023 }
2024}
2025
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002026static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2027{
2028 int i, err;
2029
2030 /* Set all ports to the Disabled state */
2031 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002032 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002033 if (err)
2034 return err;
2035 }
2036
2037 /* Wait for transmit queues to drain,
2038 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2039 */
2040 usleep_range(2000, 4000);
2041
2042 return 0;
2043}
2044
Vivien Didelotfad09c72016-06-21 12:28:20 -04002045static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002046{
Vivien Didelota935c052016-09-29 12:21:53 -04002047 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002048
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002049 err = mv88e6xxx_disable_ports(chip);
2050 if (err)
2051 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002052
Vivien Didelot309eca62016-12-05 17:30:26 -05002053 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002054
Vivien Didelot17e708b2016-12-05 17:30:27 -05002055 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002056}
2057
Vivien Didelot43145572017-03-11 16:12:59 -05002058static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002059 enum mv88e6xxx_frame_mode frame,
2060 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002061{
2062 int err;
2063
Vivien Didelot43145572017-03-11 16:12:59 -05002064 if (!chip->info->ops->port_set_frame_mode)
2065 return -EOPNOTSUPP;
2066
2067 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002068 if (err)
2069 return err;
2070
Vivien Didelot43145572017-03-11 16:12:59 -05002071 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2072 if (err)
2073 return err;
2074
2075 if (chip->info->ops->port_set_ether_type)
2076 return chip->info->ops->port_set_ether_type(chip, port, etype);
2077
2078 return 0;
2079}
2080
2081static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2082{
2083 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002084 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002085 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002086}
2087
2088static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2089{
2090 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002091 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002092 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002093}
2094
2095static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2096{
2097 return mv88e6xxx_set_port_mode(chip, port,
2098 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002099 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2100 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002101}
2102
2103static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2104{
2105 if (dsa_is_dsa_port(chip->ds, port))
2106 return mv88e6xxx_set_port_mode_dsa(chip, port);
2107
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002108 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002109 return mv88e6xxx_set_port_mode_normal(chip, port);
2110
2111 /* Setup CPU port mode depending on its supported tag format */
2112 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2113 return mv88e6xxx_set_port_mode_dsa(chip, port);
2114
2115 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2116 return mv88e6xxx_set_port_mode_edsa(chip, port);
2117
2118 return -EINVAL;
2119}
2120
Vivien Didelotea698f42017-03-11 16:12:50 -05002121static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2122{
2123 bool message = dsa_is_dsa_port(chip->ds, port);
2124
2125 return mv88e6xxx_port_set_message_port(chip, port, message);
2126}
2127
Vivien Didelot601aeed2017-03-11 16:13:00 -05002128static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2129{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002130 struct dsa_switch *ds = chip->ds;
2131 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002132
2133 /* Upstream ports flood frames with unknown unicast or multicast DA */
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002134 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002135 if (chip->info->ops->port_set_egress_floods)
2136 return chip->info->ops->port_set_egress_floods(chip, port,
2137 flood, flood);
2138
2139 return 0;
2140}
2141
Andrew Lunn6d917822017-05-26 01:03:21 +02002142static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2143 bool on)
2144{
Vivien Didelot523a8902017-05-26 18:02:42 -04002145 if (chip->info->ops->serdes_power)
2146 return chip->info->ops->serdes_power(chip, port, on);
Andrew Lunn6d917822017-05-26 01:03:21 +02002147
Vivien Didelot523a8902017-05-26 18:02:42 -04002148 return 0;
Andrew Lunn6d917822017-05-26 01:03:21 +02002149}
2150
Vivien Didelotfa371c82017-12-05 15:34:10 -05002151static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2152{
2153 struct dsa_switch *ds = chip->ds;
2154 int upstream_port;
2155 int err;
2156
Vivien Didelot07073c72017-12-05 15:34:13 -05002157 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002158 if (chip->info->ops->port_set_upstream_port) {
2159 err = chip->info->ops->port_set_upstream_port(chip, port,
2160 upstream_port);
2161 if (err)
2162 return err;
2163 }
2164
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002165 if (port == upstream_port) {
2166 if (chip->info->ops->set_cpu_port) {
2167 err = chip->info->ops->set_cpu_port(chip,
2168 upstream_port);
2169 if (err)
2170 return err;
2171 }
2172
2173 if (chip->info->ops->set_egress_port) {
2174 err = chip->info->ops->set_egress_port(chip,
2175 upstream_port);
2176 if (err)
2177 return err;
2178 }
2179 }
2180
Vivien Didelotfa371c82017-12-05 15:34:10 -05002181 return 0;
2182}
2183
Vivien Didelotfad09c72016-06-21 12:28:20 -04002184static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002185{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002186 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002187 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002188 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002189
Andrew Lunn7b898462018-08-09 15:38:47 +02002190 chip->ports[port].chip = chip;
2191 chip->ports[port].port = port;
2192
Vivien Didelotd78343d2016-11-04 03:23:36 +01002193 /* MAC Forcing register: don't force link, speed, duplex or flow control
2194 * state to any particular values on physical ports, but force the CPU
2195 * port and all DSA ports to their maximum bandwidth and full duplex.
2196 */
2197 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2198 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2199 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002200 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002201 PHY_INTERFACE_MODE_NA);
2202 else
2203 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2204 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002205 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002206 PHY_INTERFACE_MODE_NA);
2207 if (err)
2208 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002209
2210 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2211 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2212 * tunneling, determine priority by looking at 802.1p and IP
2213 * priority fields (IP prio has precedence), and set STP state
2214 * to Forwarding.
2215 *
2216 * If this is the CPU link, use DSA or EDSA tagging depending
2217 * on which tagging mode was configured.
2218 *
2219 * If this is a link to another switch, use DSA tagging mode.
2220 *
2221 * If this is the upstream port for this switch, enable
2222 * forwarding of unknown unicasts and multicasts.
2223 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002224 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2225 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2226 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2227 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002228 if (err)
2229 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002230
Vivien Didelot601aeed2017-03-11 16:13:00 -05002231 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002232 if (err)
2233 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002234
Vivien Didelot601aeed2017-03-11 16:13:00 -05002235 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002236 if (err)
2237 return err;
2238
Andrew Lunn04aca992017-05-26 01:03:24 +02002239 /* Enable the SERDES interface for DSA and CPU ports. Normal
2240 * ports SERDES are enabled when the port is enabled, thus
2241 * saving a bit of power.
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002242 */
Andrew Lunn04aca992017-05-26 01:03:24 +02002243 if ((dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))) {
2244 err = mv88e6xxx_serdes_power(chip, port, true);
2245 if (err)
2246 return err;
2247 }
Patrick Uiterwijk13a7ebb2016-03-30 01:39:41 +00002248
Vivien Didelot8efdda42015-08-13 12:52:23 -04002249 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002250 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002251 * untagged frames on this port, do a destination address lookup on all
2252 * received packets as usual, disable ARP mirroring and don't send a
2253 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002254 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002255 err = mv88e6xxx_port_set_map_da(chip, port);
2256 if (err)
2257 return err;
2258
Vivien Didelotfa371c82017-12-05 15:34:10 -05002259 err = mv88e6xxx_setup_upstream_port(chip, port);
2260 if (err)
2261 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002262
Andrew Lunna23b2962017-02-04 20:15:28 +01002263 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002264 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002265 if (err)
2266 return err;
2267
Vivien Didelotcd782652017-06-08 18:34:13 -04002268 if (chip->info->ops->port_set_jumbo_size) {
2269 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002270 if (err)
2271 return err;
2272 }
2273
Andrew Lunn54d792f2015-05-06 01:09:47 +02002274 /* Port Association Vector: when learning source addresses
2275 * of packets, add the address to the address database using
2276 * a port bitmap that has only the bit for this port set and
2277 * the other bits clear.
2278 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002279 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002280 /* Disable learning for CPU port */
2281 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002282 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002283
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002284 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2285 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002286 if (err)
2287 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002288
2289 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002290 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2291 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002292 if (err)
2293 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002294
Vivien Didelot08984322017-06-08 18:34:12 -04002295 if (chip->info->ops->port_pause_limit) {
2296 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002297 if (err)
2298 return err;
2299 }
2300
Vivien Didelotc8c94892017-03-11 16:13:01 -05002301 if (chip->info->ops->port_disable_learn_limit) {
2302 err = chip->info->ops->port_disable_learn_limit(chip, port);
2303 if (err)
2304 return err;
2305 }
2306
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002307 if (chip->info->ops->port_disable_pri_override) {
2308 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002309 if (err)
2310 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002311 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002312
Andrew Lunnef0a7312016-12-03 04:35:16 +01002313 if (chip->info->ops->port_tag_remap) {
2314 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002315 if (err)
2316 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002317 }
2318
Andrew Lunnef70b112016-12-03 04:45:18 +01002319 if (chip->info->ops->port_egress_rate_limiting) {
2320 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002321 if (err)
2322 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002323 }
2324
Vivien Didelotea698f42017-03-11 16:12:50 -05002325 err = mv88e6xxx_setup_message_port(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002326 if (err)
2327 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002328
Vivien Didelot207afda2016-04-14 14:42:09 -04002329 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002330 * database, and allow bidirectional communication between the
2331 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002332 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002333 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002334 if (err)
2335 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002336
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002337 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002338 if (err)
2339 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002340
2341 /* Default VLAN ID and priority: don't set a default VLAN
2342 * ID, and set the default packet priority to zero.
2343 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002344 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002345}
2346
Andrew Lunn04aca992017-05-26 01:03:24 +02002347static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2348 struct phy_device *phydev)
2349{
2350 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002351 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002352
2353 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002354
Vivien Didelot523a8902017-05-26 18:02:42 -04002355 err = mv88e6xxx_serdes_power(chip, port, true);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002356
2357 if (!err && chip->info->ops->serdes_irq_setup)
2358 err = chip->info->ops->serdes_irq_setup(chip, port);
2359
Andrew Lunn04aca992017-05-26 01:03:24 +02002360 mutex_unlock(&chip->reg_lock);
2361
2362 return err;
2363}
2364
2365static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port,
2366 struct phy_device *phydev)
2367{
2368 struct mv88e6xxx_chip *chip = ds->priv;
2369
2370 mutex_lock(&chip->reg_lock);
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002371
2372 if (chip->info->ops->serdes_irq_free)
2373 chip->info->ops->serdes_irq_free(chip, port);
2374
Vivien Didelot523a8902017-05-26 18:02:42 -04002375 if (mv88e6xxx_serdes_power(chip, port, false))
2376 dev_err(chip->dev, "failed to power off SERDES\n");
Andrew Lunnefd1ba62018-08-09 15:38:48 +02002377
Andrew Lunn04aca992017-05-26 01:03:24 +02002378 mutex_unlock(&chip->reg_lock);
2379}
2380
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002381static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2382 unsigned int ageing_time)
2383{
Vivien Didelot04bed142016-08-31 18:06:13 -04002384 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002385 int err;
2386
2387 mutex_lock(&chip->reg_lock);
Vivien Didelot720c6342017-03-11 16:12:48 -05002388 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002389 mutex_unlock(&chip->reg_lock);
2390
2391 return err;
2392}
2393
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002394static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002395{
2396 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002397
Andrew Lunnde2273872016-11-21 23:27:01 +01002398 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002399 if (chip->info->ops->stats_set_histogram) {
2400 err = chip->info->ops->stats_set_histogram(chip);
2401 if (err)
2402 return err;
2403 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002404
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002405 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002406}
2407
Andrew Lunnea890982019-01-09 00:24:03 +01002408/* The mv88e6390 has some hidden registers used for debug and
2409 * development. The errata also makes use of them.
2410 */
2411static int mv88e6390_hidden_write(struct mv88e6xxx_chip *chip, int port,
2412 int reg, u16 val)
2413{
2414 u16 ctrl;
2415 int err;
2416
2417 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_DATA_PORT,
2418 PORT_RESERVED_1A, val);
2419 if (err)
2420 return err;
2421
2422 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_WRITE |
2423 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2424 reg;
2425
2426 return mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2427 PORT_RESERVED_1A, ctrl);
2428}
2429
2430static int mv88e6390_hidden_wait(struct mv88e6xxx_chip *chip)
2431{
2432 return mv88e6xxx_wait(chip, PORT_RESERVED_1A_CTRL_PORT,
2433 PORT_RESERVED_1A, PORT_RESERVED_1A_BUSY);
2434}
2435
2436
2437static int mv88e6390_hidden_read(struct mv88e6xxx_chip *chip, int port,
2438 int reg, u16 *val)
2439{
2440 u16 ctrl;
2441 int err;
2442
2443 ctrl = PORT_RESERVED_1A_BUSY | PORT_RESERVED_1A_READ |
2444 PORT_RESERVED_1A_BLOCK | port << PORT_RESERVED_1A_PORT_SHIFT |
2445 reg;
2446
2447 err = mv88e6xxx_port_write(chip, PORT_RESERVED_1A_CTRL_PORT,
2448 PORT_RESERVED_1A, ctrl);
2449 if (err)
2450 return err;
2451
2452 err = mv88e6390_hidden_wait(chip);
2453 if (err)
2454 return err;
2455
2456 return mv88e6xxx_port_read(chip, PORT_RESERVED_1A_DATA_PORT,
2457 PORT_RESERVED_1A, val);
2458}
2459
2460/* Check if the errata has already been applied. */
2461static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2462{
2463 int port;
2464 int err;
2465 u16 val;
2466
2467 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2468 err = mv88e6390_hidden_read(chip, port, 0, &val);
2469 if (err) {
2470 dev_err(chip->dev,
2471 "Error reading hidden register: %d\n", err);
2472 return false;
2473 }
2474 if (val != 0x01c0)
2475 return false;
2476 }
2477
2478 return true;
2479}
2480
2481/* The 6390 copper ports have an errata which require poking magic
2482 * values into undocumented hidden registers and then performing a
2483 * software reset.
2484 */
2485static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2486{
2487 int port;
2488 int err;
2489
2490 if (mv88e6390_setup_errata_applied(chip))
2491 return 0;
2492
2493 /* Set the ports into blocking mode */
2494 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2495 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2496 if (err)
2497 return err;
2498 }
2499
2500 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2501 err = mv88e6390_hidden_write(chip, port, 0, 0x01c0);
2502 if (err)
2503 return err;
2504 }
2505
2506 return mv88e6xxx_software_reset(chip);
2507}
2508
Vivien Didelotf81ec902016-05-09 13:22:58 -04002509static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002510{
Vivien Didelot04bed142016-08-31 18:06:13 -04002511 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002512 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002513 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002514 int i;
2515
Vivien Didelotfad09c72016-06-21 12:28:20 -04002516 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002517 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002518
Vivien Didelotfad09c72016-06-21 12:28:20 -04002519 mutex_lock(&chip->reg_lock);
Vivien Didelot552238b2016-05-09 13:22:49 -04002520
Andrew Lunnea890982019-01-09 00:24:03 +01002521 if (chip->info->ops->setup_errata) {
2522 err = chip->info->ops->setup_errata(chip);
2523 if (err)
2524 goto unlock;
2525 }
2526
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002527 /* Cache the cmode of each port. */
2528 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2529 if (chip->info->ops->port_get_cmode) {
2530 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2531 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002532 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002533
2534 chip->ports[i].cmode = cmode;
2535 }
2536 }
2537
Vivien Didelot97299342016-07-18 20:45:30 -04002538 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002539 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelot91dee142017-10-26 11:22:52 -04002540 if (dsa_is_unused_port(ds, i))
2541 continue;
2542
Vivien Didelot97299342016-07-18 20:45:30 -04002543 err = mv88e6xxx_setup_port(chip, i);
2544 if (err)
2545 goto unlock;
2546 }
2547
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002548 err = mv88e6xxx_irl_setup(chip);
2549 if (err)
2550 goto unlock;
2551
Vivien Didelot04a69a12017-10-13 14:18:05 -04002552 err = mv88e6xxx_mac_setup(chip);
2553 if (err)
2554 goto unlock;
2555
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002556 err = mv88e6xxx_phy_setup(chip);
2557 if (err)
2558 goto unlock;
2559
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002560 err = mv88e6xxx_vtu_setup(chip);
2561 if (err)
2562 goto unlock;
2563
Vivien Didelot81228992017-03-30 17:37:08 -04002564 err = mv88e6xxx_pvt_setup(chip);
2565 if (err)
2566 goto unlock;
2567
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002568 err = mv88e6xxx_atu_setup(chip);
2569 if (err)
2570 goto unlock;
2571
Andrew Lunn87fa8862017-11-09 22:29:56 +01002572 err = mv88e6xxx_broadcast_setup(chip, 0);
2573 if (err)
2574 goto unlock;
2575
Vivien Didelot9e907d72017-07-17 13:03:43 -04002576 err = mv88e6xxx_pot_setup(chip);
2577 if (err)
2578 goto unlock;
2579
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002580 err = mv88e6xxx_rmu_setup(chip);
2581 if (err)
2582 goto unlock;
2583
Vivien Didelot51c901a2017-07-17 13:03:41 -04002584 err = mv88e6xxx_rsvd2cpu_setup(chip);
2585 if (err)
2586 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002587
Vivien Didelotb28f8722018-04-26 21:56:44 -04002588 err = mv88e6xxx_trunk_setup(chip);
2589 if (err)
2590 goto unlock;
2591
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002592 err = mv88e6xxx_devmap_setup(chip);
2593 if (err)
2594 goto unlock;
2595
Vivien Didelot93e18d62018-05-11 17:16:35 -04002596 err = mv88e6xxx_pri_setup(chip);
2597 if (err)
2598 goto unlock;
2599
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002600 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002601 if (chip->info->ptp_support) {
2602 err = mv88e6xxx_ptp_setup(chip);
2603 if (err)
2604 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002605
2606 err = mv88e6xxx_hwtstamp_setup(chip);
2607 if (err)
2608 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002609 }
2610
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002611 err = mv88e6xxx_stats_setup(chip);
2612 if (err)
2613 goto unlock;
2614
Vivien Didelot6b17e862015-08-13 12:52:18 -04002615unlock:
Vivien Didelotfad09c72016-06-21 12:28:20 -04002616 mutex_unlock(&chip->reg_lock);
Andrew Lunndb687a52015-06-20 21:31:29 +02002617
Andrew Lunn48ace4e2016-04-14 23:47:12 +02002618 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002619}
2620
Vivien Didelote57e5e72016-08-15 17:19:00 -04002621static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002622{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002623 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2624 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002625 u16 val;
2626 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002627
Andrew Lunnee26a222017-01-24 14:53:48 +01002628 if (!chip->info->ops->phy_read)
2629 return -EOPNOTSUPP;
2630
Vivien Didelotfad09c72016-06-21 12:28:20 -04002631 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002632 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002633 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002634
Andrew Lunnda9f3302017-02-01 03:40:05 +01002635 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01002636 /* Some internal PHYs don't have a model number. */
2637 if (chip->info->family != MV88E6XXX_FAMILY_6165)
2638 /* Then there is the 6165 family. It gets is
2639 * PHYs correct. But it can also have two
2640 * SERDES interfaces in the PHY address
2641 * space. And these don't have a model
2642 * number. But they are not PHYs, so we don't
2643 * want to give them something a PHY driver
2644 * will recognise.
2645 *
2646 * Use the mv88e6390 family model number
2647 * instead, for anything which really could be
2648 * a PHY,
2649 */
2650 if (!(val & 0x3f0))
2651 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01002652 }
2653
Vivien Didelote57e5e72016-08-15 17:19:00 -04002654 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002655}
2656
Vivien Didelote57e5e72016-08-15 17:19:00 -04002657static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002658{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002659 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2660 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002661 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002662
Andrew Lunnee26a222017-01-24 14:53:48 +01002663 if (!chip->info->ops->phy_write)
2664 return -EOPNOTSUPP;
2665
Vivien Didelotfad09c72016-06-21 12:28:20 -04002666 mutex_lock(&chip->reg_lock);
Andrew Lunnee26a222017-01-24 14:53:48 +01002667 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Vivien Didelotfad09c72016-06-21 12:28:20 -04002668 mutex_unlock(&chip->reg_lock);
Vivien Didelote57e5e72016-08-15 17:19:00 -04002669
2670 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002671}
2672
Vivien Didelotfad09c72016-06-21 12:28:20 -04002673static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01002674 struct device_node *np,
2675 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02002676{
2677 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002678 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02002679 struct mii_bus *bus;
2680 int err;
2681
Andrew Lunn2510bab2018-02-22 01:51:49 +01002682 if (external) {
2683 mutex_lock(&chip->reg_lock);
2684 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
2685 mutex_unlock(&chip->reg_lock);
2686
2687 if (err)
2688 return err;
2689 }
2690
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002691 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02002692 if (!bus)
2693 return -ENOMEM;
2694
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002695 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002696 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002697 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002698 INIT_LIST_HEAD(&mdio_bus->list);
2699 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002700
Andrew Lunnb516d452016-06-04 21:17:06 +02002701 if (np) {
2702 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05002703 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002704 } else {
2705 bus->name = "mv88e6xxx SMI";
2706 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
2707 }
2708
2709 bus->read = mv88e6xxx_mdio_read;
2710 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04002711 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02002712
Andrew Lunn6f882842018-03-17 20:32:05 +01002713 if (!external) {
2714 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
2715 if (err)
2716 return err;
2717 }
2718
Florian Fainelli00e798c2018-05-15 16:56:19 -07002719 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02002720 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04002721 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01002722 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002723 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02002724 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002725
2726 if (external)
2727 list_add_tail(&mdio_bus->list, &chip->mdios);
2728 else
2729 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02002730
2731 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02002732}
2733
Andrew Lunna3c53be52017-01-24 14:53:50 +01002734static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
2735 { .compatible = "marvell,mv88e6xxx-mdio-external",
2736 .data = (void *)true },
2737 { },
2738};
2739
Andrew Lunn3126aee2017-12-07 01:05:57 +01002740static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
2741
2742{
2743 struct mv88e6xxx_mdio_bus *mdio_bus;
2744 struct mii_bus *bus;
2745
2746 list_for_each_entry(mdio_bus, &chip->mdios, list) {
2747 bus = mdio_bus->bus;
2748
Andrew Lunn6f882842018-03-17 20:32:05 +01002749 if (!mdio_bus->external)
2750 mv88e6xxx_g2_irq_mdio_free(chip, bus);
2751
Andrew Lunn3126aee2017-12-07 01:05:57 +01002752 mdiobus_unregister(bus);
2753 }
2754}
2755
Andrew Lunna3c53be52017-01-24 14:53:50 +01002756static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
2757 struct device_node *np)
2758{
2759 const struct of_device_id *match;
2760 struct device_node *child;
2761 int err;
2762
2763 /* Always register one mdio bus for the internal/default mdio
2764 * bus. This maybe represented in the device tree, but is
2765 * optional.
2766 */
2767 child = of_get_child_by_name(np, "mdio");
2768 err = mv88e6xxx_mdio_register(chip, child, false);
2769 if (err)
2770 return err;
2771
2772 /* Walk the device tree, and see if there are any other nodes
2773 * which say they are compatible with the external mdio
2774 * bus.
2775 */
2776 for_each_available_child_of_node(np, child) {
2777 match = of_match_node(mv88e6xxx_mdio_external_match, child);
2778 if (match) {
2779 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01002780 if (err) {
2781 mv88e6xxx_mdios_unregister(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01002782 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01002783 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01002784 }
2785 }
2786
2787 return 0;
2788}
2789
Vivien Didelot855b1932016-07-20 18:18:35 -04002790static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
2791{
Vivien Didelot04bed142016-08-31 18:06:13 -04002792 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002793
2794 return chip->eeprom_len;
2795}
2796
Vivien Didelot855b1932016-07-20 18:18:35 -04002797static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
2798 struct ethtool_eeprom *eeprom, u8 *data)
2799{
Vivien Didelot04bed142016-08-31 18:06:13 -04002800 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002801 int err;
2802
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002803 if (!chip->info->ops->get_eeprom)
2804 return -EOPNOTSUPP;
2805
Vivien Didelot855b1932016-07-20 18:18:35 -04002806 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002807 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002808 mutex_unlock(&chip->reg_lock);
2809
2810 if (err)
2811 return err;
2812
2813 eeprom->magic = 0xc3ec4951;
2814
2815 return 0;
2816}
2817
Vivien Didelot855b1932016-07-20 18:18:35 -04002818static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
2819 struct ethtool_eeprom *eeprom, u8 *data)
2820{
Vivien Didelot04bed142016-08-31 18:06:13 -04002821 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04002822 int err;
2823
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002824 if (!chip->info->ops->set_eeprom)
2825 return -EOPNOTSUPP;
2826
Vivien Didelot855b1932016-07-20 18:18:35 -04002827 if (eeprom->magic != 0xc3ec4951)
2828 return -EINVAL;
2829
2830 mutex_lock(&chip->reg_lock);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04002831 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Vivien Didelot855b1932016-07-20 18:18:35 -04002832 mutex_unlock(&chip->reg_lock);
2833
2834 return err;
2835}
2836
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002837static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002838 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002839 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2840 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002841 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002842 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002843 .phy_read = mv88e6185_phy_ppu_read,
2844 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002845 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002846 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002847 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002848 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002849 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002850 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002851 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01002852 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002853 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002854 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002855 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002856 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002857 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002858 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002859 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002860 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2861 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002862 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002863 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2864 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002865 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002866 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002867 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002868 .ppu_enable = mv88e6185_g1_ppu_enable,
2869 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002870 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002871 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002872 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002873 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002874 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002875};
2876
2877static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002878 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002879 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2880 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002881 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002882 .phy_read = mv88e6185_phy_ppu_read,
2883 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002884 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002885 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002886 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002887 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002888 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01002889 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Russell King6c422e32018-08-09 15:38:39 +02002890 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002891 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002892 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002893 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002894 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2895 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002896 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002897 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05002898 .ppu_enable = mv88e6185_g1_ppu_enable,
2899 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002900 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002901 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002902 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002903 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002904};
2905
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002906static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01002907 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002908 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2909 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002910 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002911 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
2912 .phy_read = mv88e6xxx_g2_smi_phy_read,
2913 .phy_write = mv88e6xxx_g2_smi_phy_write,
2914 .port_set_link = mv88e6xxx_port_set_link,
2915 .port_set_duplex = mv88e6xxx_port_set_duplex,
2916 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002917 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002918 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002919 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002920 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04002921 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002922 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002923 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002924 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002925 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002926 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002927 .port_get_cmode = mv88e6185_port_get_cmode,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002928 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002929 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002930 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2931 .stats_get_strings = mv88e6095_stats_get_strings,
2932 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002933 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2934 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01002935 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002936 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002937 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002938 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002939 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002940 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002941 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002942 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01002943};
2944
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002945static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002946 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002947 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2948 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002949 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002950 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02002951 .phy_read = mv88e6xxx_g2_smi_phy_read,
2952 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002953 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002954 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002955 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002956 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002957 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05002958 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002959 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02002960 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002961 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02002962 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002963 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01002964 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
2965 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01002966 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04002967 .set_cpu_port = mv88e6095_g1_set_cpu_port,
2968 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01002969 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04002970 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04002971 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05002972 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04002973 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002974 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02002975 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04002976};
2977
2978static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01002979 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04002980 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
2981 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04002982 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04002983 .phy_read = mv88e6185_phy_ppu_read,
2984 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01002985 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01002986 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01002987 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01002988 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002989 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05002990 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01002991 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01002992 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04002993 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01002994 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04002995 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02002996 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02002997 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002998 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01002999 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003000 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003001 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3002 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003003 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003004 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3005 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003006 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003007 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003008 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003009 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003010 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003011 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003012 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003013 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003014 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003015};
3016
Vivien Didelot990e27b2017-03-28 13:50:32 -04003017static const struct mv88e6xxx_ops mv88e6141_ops = {
3018 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003019 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3020 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003021 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003022 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3023 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3024 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3025 .phy_read = mv88e6xxx_g2_smi_phy_read,
3026 .phy_write = mv88e6xxx_g2_smi_phy_write,
3027 .port_set_link = mv88e6xxx_port_set_link,
3028 .port_set_duplex = mv88e6xxx_port_set_duplex,
3029 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003030 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003031 .port_tag_remap = mv88e6095_port_tag_remap,
3032 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3033 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3034 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003035 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003036 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003037 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003038 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3039 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003040 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003041 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003042 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003043 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003044 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3045 .stats_get_strings = mv88e6320_stats_get_strings,
3046 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003047 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3048 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003049 .watchdog_ops = &mv88e6390_watchdog_ops,
3050 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003051 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003052 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003053 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003054 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003055 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003056 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003057 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003058};
3059
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003060static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003061 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003062 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3063 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003064 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003065 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003066 .phy_read = mv88e6xxx_g2_smi_phy_read,
3067 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003068 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003069 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003070 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003071 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003072 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003073 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003074 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003075 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003076 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003077 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003078 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003079 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003080 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003081 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003082 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003083 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003084 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3085 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003086 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003087 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3088 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003089 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003090 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003091 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003092 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003093 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003094 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003095 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003096 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003097 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003098};
3099
3100static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003101 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003102 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3103 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003104 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003105 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003106 .phy_read = mv88e6165_phy_read,
3107 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003108 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003109 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003110 .port_set_speed = mv88e6185_port_set_speed,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003111 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003112 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003113 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003114 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003115 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003116 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003117 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3118 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003119 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003120 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3121 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003122 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003123 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003124 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003125 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003126 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003127 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003128 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003129 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003130 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003131};
3132
3133static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003134 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003135 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3136 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003137 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003138 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003139 .phy_read = mv88e6xxx_g2_smi_phy_read,
3140 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003141 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003142 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003143 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003144 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003145 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003146 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003147 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003148 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003149 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003150 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003151 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003152 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003153 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003154 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003155 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003156 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003157 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003158 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3159 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003160 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003161 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3162 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003163 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003164 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003165 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003166 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003167 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003168 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003169 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003170};
3171
3172static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003173 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003174 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3175 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003176 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003177 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3178 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003179 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003180 .phy_read = mv88e6xxx_g2_smi_phy_read,
3181 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003182 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003183 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003184 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003185 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003186 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003187 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003188 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003189 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003190 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003191 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003192 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003193 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003194 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003195 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003196 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003197 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003198 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003199 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3200 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003201 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003202 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3203 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003204 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003205 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003206 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003207 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003208 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003209 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003210 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003211 .serdes_power = mv88e6352_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003212 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003213 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003214};
3215
3216static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003217 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003218 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3219 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003220 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003221 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003222 .phy_read = mv88e6xxx_g2_smi_phy_read,
3223 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003224 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003225 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003226 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003227 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003228 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003229 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003230 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003231 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003232 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003233 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003234 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003235 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003236 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003237 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003238 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003239 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003240 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003241 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3242 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003243 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003244 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3245 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003246 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003247 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003248 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003249 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003250 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003251 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003252 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003253};
3254
3255static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003256 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003257 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3258 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003259 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003260 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3261 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003262 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003263 .phy_read = mv88e6xxx_g2_smi_phy_read,
3264 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003265 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003266 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003267 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003268 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003269 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003270 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003271 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003272 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003273 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003274 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003275 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003276 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003277 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003278 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003279 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003280 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003281 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003282 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3283 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003284 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003285 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3286 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003287 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003288 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003289 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003290 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003291 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003292 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003293 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003294 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003295 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3296 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003297 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003298 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003299};
3300
3301static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003302 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003303 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3304 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003305 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003306 .phy_read = mv88e6185_phy_ppu_read,
3307 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003308 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003309 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003310 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003311 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003312 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003313 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003314 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003315 .port_set_pause = mv88e6185_port_set_pause,
Russell King6c422e32018-08-09 15:38:39 +02003316 .port_link_state = mv88e6185_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003317 .port_get_cmode = mv88e6185_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003318 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003319 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003320 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3321 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003322 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003323 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3324 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003325 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003326 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003327 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003328 .ppu_enable = mv88e6185_g1_ppu_enable,
3329 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003330 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003331 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003332 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003333 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003334};
3335
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003336static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003337 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003338 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003339 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003340 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3341 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003342 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3343 .phy_read = mv88e6xxx_g2_smi_phy_read,
3344 .phy_write = mv88e6xxx_g2_smi_phy_write,
3345 .port_set_link = mv88e6xxx_port_set_link,
3346 .port_set_duplex = mv88e6xxx_port_set_duplex,
3347 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3348 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003349 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003350 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003351 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003352 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003353 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003354 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003355 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003356 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003357 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003358 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003359 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003360 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003361 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3362 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003363 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003364 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3365 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003366 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003367 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003368 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003369 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003370 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003371 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3372 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003373 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003374 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3375 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003376 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003377 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003378};
3379
3380static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003381 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003382 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003383 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003384 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3385 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003386 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3387 .phy_read = mv88e6xxx_g2_smi_phy_read,
3388 .phy_write = mv88e6xxx_g2_smi_phy_write,
3389 .port_set_link = mv88e6xxx_port_set_link,
3390 .port_set_duplex = mv88e6xxx_port_set_duplex,
3391 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3392 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003393 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003394 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003395 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003396 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003397 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003398 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003399 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003400 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003401 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003402 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003403 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003404 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003405 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3406 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003407 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003408 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3409 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003410 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003411 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003412 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003413 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003414 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003415 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3416 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003417 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003418 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3419 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003420 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003421 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003422};
3423
3424static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003425 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003426 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003427 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003428 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3429 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003430 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3431 .phy_read = mv88e6xxx_g2_smi_phy_read,
3432 .phy_write = mv88e6xxx_g2_smi_phy_write,
3433 .port_set_link = mv88e6xxx_port_set_link,
3434 .port_set_duplex = mv88e6xxx_port_set_duplex,
3435 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3436 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003437 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003438 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003439 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003440 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003441 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003442 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003443 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003444 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003445 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003446 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003447 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003448 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003449 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3450 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003451 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003452 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3453 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003454 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003455 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003456 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003457 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003458 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003459 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3460 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003461 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003462 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3463 .serdes_irq_free = mv88e6390_serdes_irq_free,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003464 .avb_ops = &mv88e6390_avb_ops,
3465 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003466 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003467};
3468
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003469static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003470 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003471 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3472 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003473 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003474 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3475 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003476 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003477 .phy_read = mv88e6xxx_g2_smi_phy_read,
3478 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003479 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003480 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003481 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003482 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003483 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003484 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003485 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003486 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003487 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003488 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003489 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003490 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003491 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003492 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003493 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003494 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003495 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003496 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3497 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003498 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003499 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3500 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003501 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003502 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003503 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003504 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003505 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003506 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003507 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003508 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003509 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3510 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003511 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003512 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003513 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003514 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003515};
3516
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003517static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003518 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003519 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003520 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003521 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3522 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003523 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3524 .phy_read = mv88e6xxx_g2_smi_phy_read,
3525 .phy_write = mv88e6xxx_g2_smi_phy_write,
3526 .port_set_link = mv88e6xxx_port_set_link,
3527 .port_set_duplex = mv88e6xxx_port_set_duplex,
3528 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3529 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003530 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003531 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003532 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003533 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003534 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003535 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003536 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003537 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003538 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003539 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003540 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003541 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003542 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3543 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003544 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003545 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3546 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003547 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003548 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003549 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003550 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003551 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003552 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3553 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003554 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003555 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3556 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003557 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003558 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003559 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003560 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003561};
3562
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003563static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003564 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003565 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3566 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003567 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003568 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3569 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003570 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003571 .phy_read = mv88e6xxx_g2_smi_phy_read,
3572 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003573 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003574 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003575 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003576 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003577 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003578 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003579 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003580 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003581 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003582 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003583 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003584 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003585 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003586 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003587 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003588 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003589 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3590 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003591 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003592 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3593 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003594 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003595 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003596 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003597 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003598 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003599 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003600 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003601 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003602 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003603 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003604};
3605
3606static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04003607 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003608 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3609 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003610 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003611 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3612 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003613 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003614 .phy_read = mv88e6xxx_g2_smi_phy_read,
3615 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003616 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003617 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003618 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003619 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003620 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003621 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003622 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003623 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003624 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003625 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003626 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003627 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003628 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003629 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003630 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003631 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003632 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3633 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003634 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003635 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3636 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01003637 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003638 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003639 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003640 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003641 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003642 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003643 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003644 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003645};
3646
Vivien Didelot16e329a2017-03-28 13:50:33 -04003647static const struct mv88e6xxx_ops mv88e6341_ops = {
3648 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003649 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3650 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003651 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003652 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3653 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3654 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3655 .phy_read = mv88e6xxx_g2_smi_phy_read,
3656 .phy_write = mv88e6xxx_g2_smi_phy_write,
3657 .port_set_link = mv88e6xxx_port_set_link,
3658 .port_set_duplex = mv88e6xxx_port_set_duplex,
3659 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Marek Behún26422342018-10-13 14:40:31 +02003660 .port_set_speed = mv88e6341_port_set_speed,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003661 .port_tag_remap = mv88e6095_port_tag_remap,
3662 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3663 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3664 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003665 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003666 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003667 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003668 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3669 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003670 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003671 .port_get_cmode = mv88e6352_port_get_cmode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003672 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003673 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003674 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3675 .stats_get_strings = mv88e6320_stats_get_strings,
3676 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003677 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3678 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003679 .watchdog_ops = &mv88e6390_watchdog_ops,
3680 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003681 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003682 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003683 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003684 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6751e7c2018-07-31 19:19:50 +02003685 .serdes_power = mv88e6341_serdes_power,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003686 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003687 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003688 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003689 .phylink_validate = mv88e6390_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04003690};
3691
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003692static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003693 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003694 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3695 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003696 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003697 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003698 .phy_read = mv88e6xxx_g2_smi_phy_read,
3699 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003700 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003701 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003702 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003703 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003704 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003705 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003706 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003707 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003708 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003709 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003710 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003711 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003712 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003713 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003714 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003715 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003716 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003717 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3718 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003719 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003720 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3721 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003722 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003723 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003724 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003725 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003726 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003727 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003728 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003729};
3730
3731static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003732 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003733 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3734 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003735 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003736 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003737 .phy_read = mv88e6xxx_g2_smi_phy_read,
3738 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003739 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003740 .port_set_duplex = mv88e6xxx_port_set_duplex,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003741 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003742 .port_set_speed = mv88e6185_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003743 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003744 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003745 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003746 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003747 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003748 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003749 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003750 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003751 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003752 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003753 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003754 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003755 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003756 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3757 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003758 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003759 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3760 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003761 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003762 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003763 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003764 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003765 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003766 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003767 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003768 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003769 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003770};
3771
3772static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003773 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003774 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3775 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003776 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003777 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3778 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003779 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003780 .phy_read = mv88e6xxx_g2_smi_phy_read,
3781 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003782 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot7f1ae072016-11-04 03:23:33 +01003783 .port_set_duplex = mv88e6xxx_port_set_duplex,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003784 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Vivien Didelot96a2b402016-11-04 03:23:35 +01003785 .port_set_speed = mv88e6352_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003786 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003787 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003788 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003789 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003790 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003791 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003792 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003793 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003794 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003795 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003796 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003797 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003798 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003799 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3800 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003801 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003802 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3803 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003804 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003805 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003806 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003807 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003808 .rmu_disable = mv88e6352_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003809 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003810 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunn6d917822017-05-26 01:03:21 +02003811 .serdes_power = mv88e6352_serdes_power,
Andrew Lunn43821722018-09-02 18:13:15 +02003812 .serdes_irq_setup = mv88e6352_serdes_irq_setup,
3813 .serdes_irq_free = mv88e6352_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003814 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003815 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003816 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01003817 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
3818 .serdes_get_strings = mv88e6352_serdes_get_strings,
3819 .serdes_get_stats = mv88e6352_serdes_get_stats,
Russell King6c422e32018-08-09 15:38:39 +02003820 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003821};
3822
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003823static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003824 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003825 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003826 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003827 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3828 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003829 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3830 .phy_read = mv88e6xxx_g2_smi_phy_read,
3831 .phy_write = mv88e6xxx_g2_smi_phy_write,
3832 .port_set_link = mv88e6xxx_port_set_link,
3833 .port_set_duplex = mv88e6xxx_port_set_duplex,
3834 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3835 .port_set_speed = mv88e6390_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003836 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003837 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003838 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003839 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003840 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003841 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003842 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003843 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003844 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003845 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003846 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003847 .port_set_cmode = mv88e6390_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003848 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003849 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003850 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3851 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003852 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003853 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3854 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003855 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003856 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003857 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003858 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003859 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003860 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3861 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003862 .serdes_power = mv88e6390_serdes_power,
Andrew Lunnefd1ba62018-08-09 15:38:48 +02003863 .serdes_irq_setup = mv88e6390_serdes_irq_setup,
3864 .serdes_irq_free = mv88e6390_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003865 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003866 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003867 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003868 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003869};
3870
3871static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003872 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003873 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003874 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003875 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3876 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003877 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3878 .phy_read = mv88e6xxx_g2_smi_phy_read,
3879 .phy_write = mv88e6xxx_g2_smi_phy_write,
3880 .port_set_link = mv88e6xxx_port_set_link,
3881 .port_set_duplex = mv88e6xxx_port_set_duplex,
3882 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
3883 .port_set_speed = mv88e6390x_port_set_speed,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003884 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003885 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003886 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003887 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003888 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003889 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003890 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003891 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003892 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Russell King6c422e32018-08-09 15:38:39 +02003893 .port_link_state = mv88e6352_port_link_state,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003894 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01003895 .port_set_cmode = mv88e6390x_port_set_cmode,
Andrew Lunn79523472016-11-21 23:27:00 +01003896 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003897 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003898 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3899 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003900 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003901 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3902 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003903 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003904 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003905 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003906 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003907 .rmu_disable = mv88e6390_g1_rmu_disable,
Vivien Didelot931d1822017-05-01 14:05:27 -04003908 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3909 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn07ffbd72018-08-09 15:38:41 +02003910 .serdes_power = mv88e6390x_serdes_power,
Andrew Lunn2defda12018-11-11 00:32:17 +01003911 .serdes_irq_setup = mv88e6390x_serdes_irq_setup,
3912 .serdes_irq_free = mv88e6390x_serdes_irq_free,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003913 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003914 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003915 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003916 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003917};
3918
Vivien Didelotf81ec902016-05-09 13:22:58 -04003919static const struct mv88e6xxx_info mv88e6xxx_table[] = {
3920 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003921 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003922 .family = MV88E6XXX_FAMILY_6097,
3923 .name = "Marvell 88E6085",
3924 .num_databases = 4096,
3925 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01003926 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003927 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003928 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003929 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003930 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003931 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003932 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003933 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003934 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003935 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003936 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003937 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003938 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003939 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003940 },
3941
3942 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003943 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003944 .family = MV88E6XXX_FAMILY_6095,
3945 .name = "Marvell 88E6095/88E6095F",
3946 .num_databases = 256,
3947 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003948 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003949 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003950 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003951 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003952 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003953 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003954 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003955 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05003956 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003957 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01003958 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003959 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003960 },
3961
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003962 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003963 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003964 .family = MV88E6XXX_FAMILY_6097,
3965 .name = "Marvell 88E6097/88E6097F",
3966 .num_databases = 4096,
3967 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01003968 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003969 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003970 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003971 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003972 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003973 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003974 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01003975 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003976 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003977 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04003978 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04003979 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01003980 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003981 .ops = &mv88e6097_ops,
3982 },
3983
Vivien Didelotf81ec902016-05-09 13:22:58 -04003984 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04003985 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04003986 .family = MV88E6XXX_FAMILY_6165,
3987 .name = "Marvell 88E6123",
3988 .num_databases = 4096,
3989 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01003990 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04003991 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04003992 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02003993 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04003994 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04003995 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04003996 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02003997 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04003998 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05003999 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004000 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004001 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004002 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004003 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004004 },
4005
4006 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004007 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004008 .family = MV88E6XXX_FAMILY_6185,
4009 .name = "Marvell 88E6131",
4010 .num_databases = 256,
4011 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004012 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004013 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004014 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004015 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004016 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004017 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004018 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004019 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004020 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004021 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004022 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004023 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004024 },
4025
Vivien Didelot990e27b2017-03-28 13:50:32 -04004026 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004027 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004028 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004029 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004030 .num_databases = 4096,
4031 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004032 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004033 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004034 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004035 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004036 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004037 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004038 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004039 .age_time_coeff = 3750,
4040 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004041 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004042 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004043 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004044 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004045 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004046 .ops = &mv88e6141_ops,
4047 },
4048
Vivien Didelotf81ec902016-05-09 13:22:58 -04004049 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004050 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004051 .family = MV88E6XXX_FAMILY_6165,
4052 .name = "Marvell 88E6161",
4053 .num_databases = 4096,
4054 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004055 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004056 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004057 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004058 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004059 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004060 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004061 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004062 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004063 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004064 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004065 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004066 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004067 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004068 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004069 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004070 },
4071
4072 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004073 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004074 .family = MV88E6XXX_FAMILY_6165,
4075 .name = "Marvell 88E6165",
4076 .num_databases = 4096,
4077 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004078 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004079 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004080 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004081 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004082 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004083 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004084 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004085 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004086 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004087 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004088 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004089 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004090 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004091 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004092 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004093 },
4094
4095 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004096 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004097 .family = MV88E6XXX_FAMILY_6351,
4098 .name = "Marvell 88E6171",
4099 .num_databases = 4096,
4100 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004101 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004102 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004103 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004104 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004105 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004106 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004107 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004108 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004109 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004110 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004111 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004112 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004113 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004114 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004115 },
4116
4117 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004118 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004119 .family = MV88E6XXX_FAMILY_6352,
4120 .name = "Marvell 88E6172",
4121 .num_databases = 4096,
4122 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004123 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004124 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004125 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004126 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004127 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004128 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004129 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004130 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004131 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004132 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004133 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004134 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004135 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004136 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004137 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004138 },
4139
4140 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004141 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004142 .family = MV88E6XXX_FAMILY_6351,
4143 .name = "Marvell 88E6175",
4144 .num_databases = 4096,
4145 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004146 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004147 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004148 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004149 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004150 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004151 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004152 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004153 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004154 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004155 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004156 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004157 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004158 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004159 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004160 },
4161
4162 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004163 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004164 .family = MV88E6XXX_FAMILY_6352,
4165 .name = "Marvell 88E6176",
4166 .num_databases = 4096,
4167 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004168 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004169 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004170 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004171 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004172 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004173 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004174 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004175 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004176 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004177 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004178 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004179 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004180 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004181 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004182 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004183 },
4184
4185 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004186 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004187 .family = MV88E6XXX_FAMILY_6185,
4188 .name = "Marvell 88E6185",
4189 .num_databases = 256,
4190 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004191 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004192 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004193 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004194 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004195 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004196 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004197 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004198 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004199 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004200 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004201 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004202 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004203 },
4204
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004205 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004206 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004207 .family = MV88E6XXX_FAMILY_6390,
4208 .name = "Marvell 88E6190",
4209 .num_databases = 4096,
4210 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004211 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004212 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004213 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004214 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004215 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004216 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004217 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004218 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004219 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004220 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004221 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004222 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004223 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004224 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004225 .ops = &mv88e6190_ops,
4226 },
4227
4228 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004229 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004230 .family = MV88E6XXX_FAMILY_6390,
4231 .name = "Marvell 88E6190X",
4232 .num_databases = 4096,
4233 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004234 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004235 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004236 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004237 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004238 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004239 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004240 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004241 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004242 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004243 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004244 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004245 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004246 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004247 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004248 .ops = &mv88e6190x_ops,
4249 },
4250
4251 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004252 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004253 .family = MV88E6XXX_FAMILY_6390,
4254 .name = "Marvell 88E6191",
4255 .num_databases = 4096,
4256 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004257 .num_internal_phys = 11,
Vivien Didelot931d1822017-05-01 14:05:27 -04004258 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004259 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004260 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004261 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004262 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004263 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004264 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004265 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004266 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004267 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004268 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004269 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004270 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004271 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004272 },
4273
Vivien Didelotf81ec902016-05-09 13:22:58 -04004274 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004275 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004276 .family = MV88E6XXX_FAMILY_6352,
4277 .name = "Marvell 88E6240",
4278 .num_databases = 4096,
4279 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004280 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004281 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004282 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004283 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004284 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004285 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004286 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004287 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004288 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004289 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004290 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004291 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004292 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004293 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004294 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004295 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004296 },
4297
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004298 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004299 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004300 .family = MV88E6XXX_FAMILY_6390,
4301 .name = "Marvell 88E6290",
4302 .num_databases = 4096,
4303 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004304 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004305 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004306 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004307 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004308 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004309 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004310 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004311 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004312 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004313 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004314 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004315 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004316 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004317 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004318 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004319 .ops = &mv88e6290_ops,
4320 },
4321
Vivien Didelotf81ec902016-05-09 13:22:58 -04004322 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004323 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004324 .family = MV88E6XXX_FAMILY_6320,
4325 .name = "Marvell 88E6320",
4326 .num_databases = 4096,
4327 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004328 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004329 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004330 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004331 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004332 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004333 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004334 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004335 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004336 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004337 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004338 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004339 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004340 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004341 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004342 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004343 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004344 },
4345
4346 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004347 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004348 .family = MV88E6XXX_FAMILY_6320,
4349 .name = "Marvell 88E6321",
4350 .num_databases = 4096,
4351 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004352 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004353 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004354 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004355 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004356 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004357 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004358 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004359 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004360 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004361 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004362 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004363 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004364 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004365 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004366 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004367 },
4368
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004369 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004370 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004371 .family = MV88E6XXX_FAMILY_6341,
4372 .name = "Marvell 88E6341",
4373 .num_databases = 4096,
Andrew Lunnbc393152018-03-17 20:32:04 +01004374 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004375 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004376 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004377 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004378 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004379 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004380 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004381 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004382 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05004383 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004384 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004385 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004386 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004387 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004388 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004389 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01004390 .ops = &mv88e6341_ops,
4391 },
4392
Vivien Didelotf81ec902016-05-09 13:22:58 -04004393 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004394 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004395 .family = MV88E6XXX_FAMILY_6351,
4396 .name = "Marvell 88E6350",
4397 .num_databases = 4096,
4398 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004399 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004400 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004401 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004402 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004403 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004404 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004405 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004406 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004407 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004408 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004409 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004410 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004411 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004412 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004413 },
4414
4415 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004416 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004417 .family = MV88E6XXX_FAMILY_6351,
4418 .name = "Marvell 88E6351",
4419 .num_databases = 4096,
4420 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004421 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004422 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004423 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004424 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004425 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004426 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004427 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004428 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004429 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004430 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004431 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004432 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004433 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004434 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004435 },
4436
4437 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004438 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004439 .family = MV88E6XXX_FAMILY_6352,
4440 .name = "Marvell 88E6352",
4441 .num_databases = 4096,
4442 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004443 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004444 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004445 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004446 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004447 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004448 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004449 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004450 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004451 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004452 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004453 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004454 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004455 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004456 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004457 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004458 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004459 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004460 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004461 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004462 .family = MV88E6XXX_FAMILY_6390,
4463 .name = "Marvell 88E6390",
4464 .num_databases = 4096,
4465 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004466 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004467 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004468 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004469 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004470 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004471 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004472 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004473 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004474 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004475 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004476 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004477 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004478 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004479 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004480 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004481 .ops = &mv88e6390_ops,
4482 },
4483 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004484 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004485 .family = MV88E6XXX_FAMILY_6390,
4486 .name = "Marvell 88E6390X",
4487 .num_databases = 4096,
4488 .num_ports = 11, /* 10 + Z80 */
Andrew Lunnbc393152018-03-17 20:32:04 +01004489 .num_internal_phys = 11,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004490 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004491 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004492 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004493 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004494 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004495 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004496 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004497 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004498 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004499 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004500 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004501 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004502 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004503 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004504 .ops = &mv88e6390x_ops,
4505 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04004506};
4507
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004508static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04004509{
Vivien Didelota439c062016-04-17 13:23:58 -04004510 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04004511
Vivien Didelot5f7c0362016-06-20 13:14:04 -04004512 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
4513 if (mv88e6xxx_table[i].prod_num == prod_num)
4514 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04004515
Vivien Didelotb9b37712015-10-30 19:39:48 -04004516 return NULL;
4517}
4518
Vivien Didelotfad09c72016-06-21 12:28:20 -04004519static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004520{
4521 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004522 unsigned int prod_num, rev;
4523 u16 id;
4524 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004525
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004526 mutex_lock(&chip->reg_lock);
Vivien Didelot107fcc12017-06-12 12:37:36 -04004527 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04004528 mutex_unlock(&chip->reg_lock);
4529 if (err)
4530 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004531
Vivien Didelot107fcc12017-06-12 12:37:36 -04004532 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
4533 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004534
4535 info = mv88e6xxx_lookup_info(prod_num);
4536 if (!info)
4537 return -ENODEV;
4538
Vivien Didelotcaac8542016-06-20 13:14:09 -04004539 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004540 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004541
Vivien Didelotca070c12016-09-02 14:45:34 -04004542 err = mv88e6xxx_g2_require(chip);
4543 if (err)
4544 return err;
4545
Vivien Didelotfad09c72016-06-21 12:28:20 -04004546 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
4547 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004548
4549 return 0;
4550}
4551
Vivien Didelotfad09c72016-06-21 12:28:20 -04004552static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04004553{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004554 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004555
Vivien Didelotfad09c72016-06-21 12:28:20 -04004556 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
4557 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004558 return NULL;
4559
Vivien Didelotfad09c72016-06-21 12:28:20 -04004560 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04004561
Vivien Didelotfad09c72016-06-21 12:28:20 -04004562 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004563 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelot469d7292016-06-20 13:14:06 -04004564
Vivien Didelotfad09c72016-06-21 12:28:20 -04004565 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04004566}
4567
Vivien Didelotfad09c72016-06-21 12:28:20 -04004568static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004569 struct mii_bus *bus, int sw_addr)
4570{
Vivien Didelot914b32f2016-06-20 13:14:11 -04004571 if (sw_addr == 0)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004572 chip->smi_ops = &mv88e6xxx_smi_single_chip_ops;
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004573 else if (chip->info->multi_chip)
Vivien Didelotfad09c72016-06-21 12:28:20 -04004574 chip->smi_ops = &mv88e6xxx_smi_multi_chip_ops;
Vivien Didelot914b32f2016-06-20 13:14:11 -04004575 else
4576 return -EINVAL;
4577
Vivien Didelotfad09c72016-06-21 12:28:20 -04004578 chip->bus = bus;
4579 chip->sw_addr = sw_addr;
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004580
4581 return 0;
4582}
4583
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08004584static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
4585 int port)
Andrew Lunn7b314362016-08-22 16:01:01 +02004586{
Vivien Didelot04bed142016-08-31 18:06:13 -04004587 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02004588
Andrew Lunn443d5a12016-12-03 04:35:18 +01004589 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02004590}
4591
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004592#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004593static const char *mv88e6xxx_drv_probe(struct device *dsa_dev,
4594 struct device *host_dev, int sw_addr,
4595 void **priv)
Andrew Lunna77d43f2016-04-13 02:40:42 +02004596{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004597 struct mv88e6xxx_chip *chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004598 struct mii_bus *bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02004599 int err;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004600
Vivien Didelota439c062016-04-17 13:23:58 -04004601 bus = dsa_host_dev_to_mii_bus(host_dev);
Andrew Lunnc1569132016-04-13 02:40:45 +02004602 if (!bus)
4603 return NULL;
4604
Vivien Didelotfad09c72016-06-21 12:28:20 -04004605 chip = mv88e6xxx_alloc_chip(dsa_dev);
4606 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04004607 return NULL;
4608
Vivien Didelotcaac8542016-06-20 13:14:09 -04004609 /* Legacy SMI probing will only support chips similar to 88E6085 */
Vivien Didelotfad09c72016-06-21 12:28:20 -04004610 chip->info = &mv88e6xxx_table[MV88E6085];
Vivien Didelotcaac8542016-06-20 13:14:09 -04004611
Vivien Didelotfad09c72016-06-21 12:28:20 -04004612 err = mv88e6xxx_smi_init(chip, bus, sw_addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004613 if (err)
4614 goto free;
4615
Vivien Didelotfad09c72016-06-21 12:28:20 -04004616 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004617 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004618 goto free;
Vivien Didelota439c062016-04-17 13:23:58 -04004619
Andrew Lunndc30c352016-10-16 19:56:49 +02004620 mutex_lock(&chip->reg_lock);
4621 err = mv88e6xxx_switch_reset(chip);
4622 mutex_unlock(&chip->reg_lock);
4623 if (err)
4624 goto free;
4625
Vivien Didelote57e5e72016-08-15 17:19:00 -04004626 mv88e6xxx_phy_init(chip);
4627
Andrew Lunna3c53be52017-01-24 14:53:50 +01004628 err = mv88e6xxx_mdios_register(chip, NULL);
Andrew Lunnb516d452016-06-04 21:17:06 +02004629 if (err)
Vivien Didelot469d7292016-06-20 13:14:06 -04004630 goto free;
Andrew Lunnb516d452016-06-04 21:17:06 +02004631
Vivien Didelotfad09c72016-06-21 12:28:20 -04004632 *priv = chip;
Vivien Didelota439c062016-04-17 13:23:58 -04004633
Vivien Didelotfad09c72016-06-21 12:28:20 -04004634 return chip->info->name;
Vivien Didelot469d7292016-06-20 13:14:06 -04004635free:
Vivien Didelotfad09c72016-06-21 12:28:20 -04004636 devm_kfree(dsa_dev, chip);
Vivien Didelot469d7292016-06-20 13:14:06 -04004637
4638 return NULL;
Andrew Lunna77d43f2016-04-13 02:40:42 +02004639}
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004640#endif
Andrew Lunna77d43f2016-04-13 02:40:42 +02004641
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004642static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004643 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004644{
4645 /* We don't need any dynamic resource from the kernel (yet),
4646 * so skip the prepare phase.
4647 */
4648
4649 return 0;
4650}
4651
4652static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05004653 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004654{
Vivien Didelot04bed142016-08-31 18:06:13 -04004655 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004656
4657 mutex_lock(&chip->reg_lock);
4658 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004659 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04004660 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
4661 port);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004662 mutex_unlock(&chip->reg_lock);
4663}
4664
4665static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
4666 const struct switchdev_obj_port_mdb *mdb)
4667{
Vivien Didelot04bed142016-08-31 18:06:13 -04004668 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004669 int err;
4670
4671 mutex_lock(&chip->reg_lock);
4672 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04004673 MV88E6XXX_G1_ATU_DATA_STATE_UNUSED);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004674 mutex_unlock(&chip->reg_lock);
4675
4676 return err;
4677}
4678
Florian Fainellia82f67a2017-01-08 14:52:08 -08004679static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004680#if IS_ENABLED(CONFIG_NET_DSA_LEGACY)
Andrew Lunnfcdce7d2016-05-10 23:27:20 +02004681 .probe = mv88e6xxx_drv_probe,
Florian Fainelli2a93c1a2017-12-06 15:03:33 -08004682#endif
Andrew Lunn7b314362016-08-22 16:01:01 +02004683 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004684 .setup = mv88e6xxx_setup,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004685 .adjust_link = mv88e6xxx_adjust_link,
Russell Kingc9a23562018-05-10 13:17:35 -07004686 .phylink_validate = mv88e6xxx_validate,
4687 .phylink_mac_link_state = mv88e6xxx_link_state,
4688 .phylink_mac_config = mv88e6xxx_mac_config,
4689 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
4690 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004691 .get_strings = mv88e6xxx_get_strings,
4692 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
4693 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02004694 .port_enable = mv88e6xxx_port_enable,
4695 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04004696 .get_mac_eee = mv88e6xxx_get_mac_eee,
4697 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004698 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004699 .get_eeprom = mv88e6xxx_get_eeprom,
4700 .set_eeprom = mv88e6xxx_set_eeprom,
4701 .get_regs_len = mv88e6xxx_get_regs_len,
4702 .get_regs = mv88e6xxx_get_regs,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04004703 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004704 .port_bridge_join = mv88e6xxx_port_bridge_join,
4705 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
4706 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04004707 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004708 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
4709 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
4710 .port_vlan_add = mv88e6xxx_port_vlan_add,
4711 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004712 .port_fdb_add = mv88e6xxx_port_fdb_add,
4713 .port_fdb_del = mv88e6xxx_port_fdb_del,
4714 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04004715 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
4716 .port_mdb_add = mv88e6xxx_port_mdb_add,
4717 .port_mdb_del = mv88e6xxx_port_mdb_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04004718 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
4719 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004720 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
4721 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
4722 .port_txtstamp = mv88e6xxx_port_txtstamp,
4723 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
4724 .get_ts_info = mv88e6xxx_get_ts_info,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004725};
4726
Florian Fainelliab3d4082017-01-08 14:52:07 -08004727static struct dsa_switch_driver mv88e6xxx_switch_drv = {
4728 .ops = &mv88e6xxx_switch_ops,
4729};
4730
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004731static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004732{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004733 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004734 struct dsa_switch *ds;
4735
Vivien Didelot73b12042017-03-30 17:37:10 -04004736 ds = dsa_switch_alloc(dev, mv88e6xxx_num_ports(chip));
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004737 if (!ds)
4738 return -ENOMEM;
4739
Vivien Didelotfad09c72016-06-21 12:28:20 -04004740 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004741 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04004742 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04004743 ds->ageing_time_min = chip->info->age_time_coeff;
4744 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004745
4746 dev_set_drvdata(dev, ds);
4747
Vivien Didelot23c9ee42017-05-26 18:12:51 -04004748 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004749}
4750
Vivien Didelotfad09c72016-06-21 12:28:20 -04004751static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004752{
Vivien Didelotfad09c72016-06-21 12:28:20 -04004753 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04004754}
4755
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004756static const void *pdata_device_get_match_data(struct device *dev)
4757{
4758 const struct of_device_id *matches = dev->driver->of_match_table;
4759 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
4760
4761 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
4762 matches++) {
4763 if (!strcmp(pdata->compatible, matches->compatible))
4764 return matches->data;
4765 }
4766 return NULL;
4767}
4768
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004769/* There is no suspend to RAM support at DSA level yet, the switch configuration
4770 * would be lost after a power cycle so prevent it to be suspended.
4771 */
4772static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
4773{
4774 return -EOPNOTSUPP;
4775}
4776
4777static int __maybe_unused mv88e6xxx_resume(struct device *dev)
4778{
4779 return 0;
4780}
4781
4782static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
4783
Vivien Didelot57d32312016-06-20 13:13:58 -04004784static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004785{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004786 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04004787 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004788 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004789 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04004790 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004791 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02004792 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004793
Andrew Lunn7bb8c992018-05-31 00:15:42 +02004794 if (!np && !pdata)
4795 return -EINVAL;
4796
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004797 if (np)
4798 compat_info = of_device_get_match_data(dev);
4799
4800 if (pdata) {
4801 compat_info = pdata_device_get_match_data(dev);
4802
4803 if (!pdata->netdev)
4804 return -EINVAL;
4805
4806 for (port = 0; port < DSA_MAX_PORTS; port++) {
4807 if (!(pdata->enabled_ports & (1 << port)))
4808 continue;
4809 if (strcmp(pdata->cd.port_names[port], "cpu"))
4810 continue;
4811 pdata->cd.netdev[port] = &pdata->netdev->dev;
4812 break;
4813 }
4814 }
4815
Vivien Didelotcaac8542016-06-20 13:14:09 -04004816 if (!compat_info)
4817 return -EINVAL;
4818
Vivien Didelotfad09c72016-06-21 12:28:20 -04004819 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004820 if (!chip) {
4821 err = -ENOMEM;
4822 goto out;
4823 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004824
Vivien Didelotfad09c72016-06-21 12:28:20 -04004825 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04004826
Vivien Didelotfad09c72016-06-21 12:28:20 -04004827 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04004828 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004829 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004830
Andrew Lunnb4308f02016-11-21 23:26:55 +01004831 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004832 if (IS_ERR(chip->reset)) {
4833 err = PTR_ERR(chip->reset);
4834 goto out;
4835 }
Andrew Lunnb4308f02016-11-21 23:26:55 +01004836
Vivien Didelotfad09c72016-06-21 12:28:20 -04004837 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04004838 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004839 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004840
Vivien Didelote57e5e72016-08-15 17:19:00 -04004841 mv88e6xxx_phy_init(chip);
4842
Andrew Lunn00baabe2018-05-19 22:31:35 +02004843 if (chip->info->ops->get_eeprom) {
4844 if (np)
4845 of_property_read_u32(np, "eeprom-length",
4846 &chip->eeprom_len);
4847 else
4848 chip->eeprom_len = pdata->eeprom_len;
4849 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02004850
Andrew Lunndc30c352016-10-16 19:56:49 +02004851 mutex_lock(&chip->reg_lock);
4852 err = mv88e6xxx_switch_reset(chip);
4853 mutex_unlock(&chip->reg_lock);
Andrew Lunnb516d452016-06-04 21:17:06 +02004854 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02004855 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02004856
Andrew Lunndc30c352016-10-16 19:56:49 +02004857 chip->irq = of_irq_get(np, 0);
4858 if (chip->irq == -EPROBE_DEFER) {
4859 err = chip->irq;
4860 goto out;
Andrew Lunn83c0afa2016-06-04 21:17:07 +02004861 }
4862
Andrew Lunn294d7112018-02-22 22:58:32 +01004863 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01004864 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01004865 * controllers
4866 */
4867 mutex_lock(&chip->reg_lock);
4868 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004869 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004870 else
4871 err = mv88e6xxx_irq_poll_setup(chip);
4872 mutex_unlock(&chip->reg_lock);
Andrew Lunndc30c352016-10-16 19:56:49 +02004873
Andrew Lunn294d7112018-02-22 22:58:32 +01004874 if (err)
4875 goto out;
4876
4877 if (chip->info->g2_irqs > 0) {
4878 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004879 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01004880 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004881 }
4882
Andrew Lunn294d7112018-02-22 22:58:32 +01004883 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
4884 if (err)
4885 goto out_g2_irq;
4886
4887 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
4888 if (err)
4889 goto out_g1_atu_prob_irq;
4890
Andrew Lunna3c53be52017-01-24 14:53:50 +01004891 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02004892 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01004893 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02004894
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08004895 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004896 if (err)
4897 goto out_mdio;
4898
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004899 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02004900
4901out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01004902 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01004903out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004904 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01004905out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004906 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004907out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004908 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02004909 mv88e6xxx_g2_irq_free(chip);
4910out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01004911 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004912 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01004913 else
4914 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004915out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02004916 if (pdata)
4917 dev_put(pdata->netdev);
4918
Andrew Lunndc30c352016-10-16 19:56:49 +02004919 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004920}
4921
4922static void mv88e6xxx_remove(struct mdio_device *mdiodev)
4923{
4924 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04004925 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004926
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004927 if (chip->info->ptp_support) {
4928 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004929 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01004930 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004931
Andrew Lunn930188c2016-08-22 16:01:03 +02004932 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04004933 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01004934 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02004935
Andrew Lunn76f38f12018-03-17 20:21:09 +01004936 mv88e6xxx_g1_vtu_prob_irq_free(chip);
4937 mv88e6xxx_g1_atu_prob_irq_free(chip);
4938
4939 if (chip->info->g2_irqs > 0)
4940 mv88e6xxx_g2_irq_free(chip);
4941
Andrew Lunn76f38f12018-03-17 20:21:09 +01004942 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01004943 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01004944 else
4945 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004946}
4947
4948static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04004949 {
4950 .compatible = "marvell,mv88e6085",
4951 .data = &mv88e6xxx_table[MV88E6085],
4952 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004953 {
4954 .compatible = "marvell,mv88e6190",
4955 .data = &mv88e6xxx_table[MV88E6190],
4956 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004957 { /* sentinel */ },
4958};
4959
4960MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
4961
4962static struct mdio_driver mv88e6xxx_driver = {
4963 .probe = mv88e6xxx_probe,
4964 .remove = mv88e6xxx_remove,
4965 .mdiodrv.driver = {
4966 .name = "mv88e6085",
4967 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01004968 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004969 },
4970};
4971
Ben Hutchings98e67302011-11-25 14:36:19 +00004972static int __init mv88e6xxx_init(void)
4973{
Florian Fainelliab3d4082017-01-08 14:52:07 -08004974 register_switch_driver(&mv88e6xxx_switch_drv);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004975 return mdio_driver_register(&mv88e6xxx_driver);
Ben Hutchings98e67302011-11-25 14:36:19 +00004976}
4977module_init(mv88e6xxx_init);
4978
4979static void __exit mv88e6xxx_cleanup(void)
4980{
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02004981 mdio_driver_unregister(&mv88e6xxx_driver);
Florian Fainelliab3d4082017-01-08 14:52:07 -08004982 unregister_switch_driver(&mv88e6xxx_switch_drv);
Ben Hutchings98e67302011-11-25 14:36:19 +00004983}
4984module_exit(mv88e6xxx_cleanup);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00004985
4986MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
4987MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
4988MODULE_LICENSE("GPL");