blob: 2c9569e88fac4b32c170148b84c68d554d79a2fa [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00002/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 * Marvell 88e6xxx Ethernet switch single-chip support
4 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00005 * Copyright (c) 2008 Marvell Semiconductor
6 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02007 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
8 *
Vivien Didelot4333d612017-03-28 15:10:36 -04009 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 */
12
Vivien Didelot19fb7f62019-08-09 18:47:55 -040013#include <linux/bitfield.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000014#include <linux/delay.h>
Vladimir Oltean5bded822021-10-07 19:47:11 +030015#include <linux/dsa/mv88e6xxx.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070016#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020017#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070018#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020019#include <linux/interrupt.h>
20#include <linux/irq.h>
21#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000022#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000023#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020024#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000025#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040026#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020027#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020028#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020029#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000030#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010031#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070032#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000033#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040034
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040035#include "chip.h"
Andrew Lunn9dd43aa2020-09-18 21:11:05 +020036#include "devlink.h"
Vivien Didelota935c052016-09-29 12:21:53 -040037#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040038#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010039#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020040#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010041#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010042#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020043#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040044#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000045
Vivien Didelotfad09c72016-06-21 12:28:20 -040046static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040047{
Vivien Didelotfad09c72016-06-21 12:28:20 -040048 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
49 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040050 dump_stack();
51 }
52}
53
Vivien Didelotec561272016-09-02 14:45:33 -040054int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040055{
56 int err;
57
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059
Vivien Didelotfad09c72016-06-21 12:28:20 -040060 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040061 if (err)
62 return err;
63
Vivien Didelotfad09c72016-06-21 12:28:20 -040064 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040065 addr, reg, *val);
66
67 return 0;
68}
69
Vivien Didelotec561272016-09-02 14:45:33 -040070int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040071{
72 int err;
73
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075
Vivien Didelotfad09c72016-06-21 12:28:20 -040076 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040077 if (err)
78 return err;
79
Vivien Didelotfad09c72016-06-21 12:28:20 -040080 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040081 addr, reg, val);
82
83 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000084}
85
Vivien Didelot683f2242019-08-09 18:47:54 -040086int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
87 u16 mask, u16 val)
88{
89 u16 data;
90 int err;
91 int i;
92
93 /* There's no bus specific operation to wait for a mask */
94 for (i = 0; i < 16; i++) {
95 err = mv88e6xxx_read(chip, addr, reg, &data);
96 if (err)
97 return err;
98
99 if ((data & mask) == val)
100 return 0;
101
102 usleep_range(1000, 2000);
103 }
104
105 dev_err(chip->dev, "Timeout while waiting for switch\n");
106 return -ETIMEDOUT;
107}
108
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400109int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
110 int bit, int val)
111{
112 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
113 val ? BIT(bit) : 0x0000);
114}
115
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200116struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100117{
118 struct mv88e6xxx_mdio_bus *mdio_bus;
119
120 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
121 list);
122 if (!mdio_bus)
123 return NULL;
124
125 return mdio_bus->bus;
126}
127
Andrew Lunndc30c352016-10-16 19:56:49 +0200128static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
129{
130 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
131 unsigned int n = d->hwirq;
132
133 chip->g1_irq.masked |= (1 << n);
134}
135
136static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
137{
138 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
139 unsigned int n = d->hwirq;
140
141 chip->g1_irq.masked &= ~(1 << n);
142}
143
Andrew Lunn294d7112018-02-22 22:58:32 +0100144static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200145{
Andrew Lunndc30c352016-10-16 19:56:49 +0200146 unsigned int nhandled = 0;
147 unsigned int sub_irq;
148 unsigned int n;
149 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500150 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200151 int err;
152
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000153 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400154 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000155 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200156
157 if (err)
158 goto out;
159
John David Anglin7c0db242019-02-11 13:40:21 -0500160 do {
161 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
162 if (reg & (1 << n)) {
163 sub_irq = irq_find_mapping(chip->g1_irq.domain,
164 n);
165 handle_nested_irq(sub_irq);
166 ++nhandled;
167 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200168 }
John David Anglin7c0db242019-02-11 13:40:21 -0500169
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000170 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500171 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
172 if (err)
173 goto unlock;
174 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
175unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000176 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500177 if (err)
178 goto out;
179 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
180 } while (reg & ctl1);
181
Andrew Lunndc30c352016-10-16 19:56:49 +0200182out:
183 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
184}
185
Andrew Lunn294d7112018-02-22 22:58:32 +0100186static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
187{
188 struct mv88e6xxx_chip *chip = dev_id;
189
190 return mv88e6xxx_g1_irq_thread_work(chip);
191}
192
Andrew Lunndc30c352016-10-16 19:56:49 +0200193static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
194{
195 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
196
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000197 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200198}
199
200static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
201{
202 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
203 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
204 u16 reg;
205 int err;
206
Vivien Didelotd77f4322017-06-15 12:14:03 -0400207 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200208 if (err)
209 goto out;
210
211 reg &= ~mask;
212 reg |= (~chip->g1_irq.masked & mask);
213
Vivien Didelotd77f4322017-06-15 12:14:03 -0400214 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200215 if (err)
216 goto out;
217
218out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000219 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200220}
221
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530222static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200223 .name = "mv88e6xxx-g1",
224 .irq_mask = mv88e6xxx_g1_irq_mask,
225 .irq_unmask = mv88e6xxx_g1_irq_unmask,
226 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
227 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
228};
229
230static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
231 unsigned int irq,
232 irq_hw_number_t hwirq)
233{
234 struct mv88e6xxx_chip *chip = d->host_data;
235
236 irq_set_chip_data(irq, d->host_data);
237 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
238 irq_set_noprobe(irq);
239
240 return 0;
241}
242
243static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
244 .map = mv88e6xxx_g1_irq_domain_map,
245 .xlate = irq_domain_xlate_twocell,
246};
247
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200248/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100249static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200250{
251 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100252 u16 mask;
253
Vivien Didelotd77f4322017-06-15 12:14:03 -0400254 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100255 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400256 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100257
Andreas Färber5edef2f2016-11-27 23:26:28 +0100258 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100259 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200260 irq_dispose_mapping(virq);
261 }
262
Andrew Lunna3db3d32016-11-20 20:14:14 +0100263 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200264}
265
Andrew Lunn294d7112018-02-22 22:58:32 +0100266static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
267{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200268 /*
269 * free_irq must be called without reg_lock taken because the irq
270 * handler takes this lock, too.
271 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100272 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200273
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000274 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200275 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000276 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100277}
278
279static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200280{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100281 int err, irq, virq;
282 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200283
284 chip->g1_irq.nirqs = chip->info->g1_irqs;
285 chip->g1_irq.domain = irq_domain_add_simple(
286 NULL, chip->g1_irq.nirqs, 0,
287 &mv88e6xxx_g1_irq_domain_ops, chip);
288 if (!chip->g1_irq.domain)
289 return -ENOMEM;
290
291 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
292 irq_create_mapping(chip->g1_irq.domain, irq);
293
294 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
295 chip->g1_irq.masked = ~0;
296
Vivien Didelotd77f4322017-06-15 12:14:03 -0400297 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200298 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100299 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200300
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100301 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200302
Vivien Didelotd77f4322017-06-15 12:14:03 -0400303 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200304 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100305 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200306
307 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400308 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200309 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100310 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200311
Andrew Lunndc30c352016-10-16 19:56:49 +0200312 return 0;
313
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100314out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100315 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400316 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100317
318out_mapping:
319 for (irq = 0; irq < 16; irq++) {
320 virq = irq_find_mapping(chip->g1_irq.domain, irq);
321 irq_dispose_mapping(virq);
322 }
323
324 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200325
326 return err;
327}
328
Andrew Lunn294d7112018-02-22 22:58:32 +0100329static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
330{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100331 static struct lock_class_key lock_key;
332 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100333 int err;
334
335 err = mv88e6xxx_g1_irq_setup_common(chip);
336 if (err)
337 return err;
338
Andrew Lunnf6d97582019-02-23 17:43:56 +0100339 /* These lock classes tells lockdep that global 1 irqs are in
340 * a different category than their parent GPIO, so it won't
341 * report false recursion.
342 */
343 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
344
Andrew Lunn30953832020-01-06 17:13:48 +0100345 snprintf(chip->irq_name, sizeof(chip->irq_name),
346 "mv88e6xxx-%s", dev_name(chip->dev));
347
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000348 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100349 err = request_threaded_irq(chip->irq, NULL,
350 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200351 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100352 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000353 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100354 if (err)
355 mv88e6xxx_g1_irq_free_common(chip);
356
357 return err;
358}
359
360static void mv88e6xxx_irq_poll(struct kthread_work *work)
361{
362 struct mv88e6xxx_chip *chip = container_of(work,
363 struct mv88e6xxx_chip,
364 irq_poll_work.work);
365 mv88e6xxx_g1_irq_thread_work(chip);
366
367 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
368 msecs_to_jiffies(100));
369}
370
371static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
372{
373 int err;
374
375 err = mv88e6xxx_g1_irq_setup_common(chip);
376 if (err)
377 return err;
378
379 kthread_init_delayed_work(&chip->irq_poll_work,
380 mv88e6xxx_irq_poll);
381
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800382 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100383 if (IS_ERR(chip->kworker))
384 return PTR_ERR(chip->kworker);
385
386 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
387 msecs_to_jiffies(100));
388
389 return 0;
390}
391
392static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
393{
394 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
395 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200396
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000397 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200398 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000399 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100400}
401
Russell King64d47d52020-03-14 10:15:38 +0000402static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
403 int port, phy_interface_t interface)
404{
405 int err;
406
407 if (chip->info->ops->port_set_rgmii_delay) {
408 err = chip->info->ops->port_set_rgmii_delay(chip, port,
409 interface);
410 if (err && err != -EOPNOTSUPP)
411 return err;
412 }
413
414 if (chip->info->ops->port_set_cmode) {
415 err = chip->info->ops->port_set_cmode(chip, port,
416 interface);
417 if (err && err != -EOPNOTSUPP)
418 return err;
419 }
420
421 return 0;
422}
423
Russell Kinga5a68582020-03-14 10:15:43 +0000424static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
425 int link, int speed, int duplex, int pause,
426 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100427{
428 int err;
429
430 if (!chip->info->ops->port_set_link)
431 return 0;
432
433 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200434 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100435 if (err)
436 return err;
437
Russell Kingf365c6f2020-03-14 10:15:53 +0000438 if (chip->info->ops->port_set_speed_duplex) {
439 err = chip->info->ops->port_set_speed_duplex(chip, port,
440 speed, duplex);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100441 if (err && err != -EOPNOTSUPP)
442 goto restore_link;
443 }
444
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100445 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
446 mode = chip->info->ops->port_max_speed_mode(port);
447
Andrew Lunn54186b92018-08-09 15:38:37 +0200448 if (chip->info->ops->port_set_pause) {
449 err = chip->info->ops->port_set_pause(chip, port, pause);
450 if (err)
451 goto restore_link;
452 }
453
Russell King64d47d52020-03-14 10:15:38 +0000454 err = mv88e6xxx_port_config_interface(chip, port, mode);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100455restore_link:
456 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400457 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100458
459 return err;
460}
461
Marek Vasutd700ec42018-09-12 00:15:24 +0200462static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
463{
464 struct mv88e6xxx_chip *chip = ds->priv;
465
466 return port < chip->info->num_internal_phys;
467}
468
Russell King5d5b2312020-03-14 10:16:03 +0000469static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)
470{
471 u16 reg;
472 int err;
473
474 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
475 if (err) {
476 dev_err(chip->dev,
477 "p%d: %s: failed to read port status\n",
478 port, __func__);
479 return err;
480 }
481
482 return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
483}
484
Russell Kinga5a68582020-03-14 10:15:43 +0000485static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
486 struct phylink_link_state *state)
487{
488 struct mv88e6xxx_chip *chip = ds->priv;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100489 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000490 int err;
491
492 mv88e6xxx_reg_lock(chip);
493 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100494 if (lane >= 0 && chip->info->ops->serdes_pcs_get_state)
Russell Kinga5a68582020-03-14 10:15:43 +0000495 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
496 state);
497 else
498 err = -EOPNOTSUPP;
499 mv88e6xxx_reg_unlock(chip);
500
501 return err;
502}
503
504static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
505 unsigned int mode,
506 phy_interface_t interface,
507 const unsigned long *advertise)
508{
509 const struct mv88e6xxx_ops *ops = chip->info->ops;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100510 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000511
512 if (ops->serdes_pcs_config) {
513 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100514 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000515 return ops->serdes_pcs_config(chip, port, lane, mode,
516 interface, advertise);
517 }
518
519 return 0;
520}
521
522static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
523{
524 struct mv88e6xxx_chip *chip = ds->priv;
525 const struct mv88e6xxx_ops *ops;
526 int err = 0;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100527 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000528
529 ops = chip->info->ops;
530
531 if (ops->serdes_pcs_an_restart) {
532 mv88e6xxx_reg_lock(chip);
533 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100534 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000535 err = ops->serdes_pcs_an_restart(chip, port, lane);
536 mv88e6xxx_reg_unlock(chip);
537
538 if (err)
539 dev_err(ds->dev, "p%d: failed to restart AN\n", port);
540 }
541}
542
543static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
544 unsigned int mode,
545 int speed, int duplex)
546{
547 const struct mv88e6xxx_ops *ops = chip->info->ops;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100548 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000549
550 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
551 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100552 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000553 return ops->serdes_pcs_link_up(chip, port, lane,
554 speed, duplex);
555 }
556
557 return 0;
558}
559
Russell King6c422e32018-08-09 15:38:39 +0200560static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
561 unsigned long *mask,
562 struct phylink_link_state *state)
563{
564 if (!phy_interface_mode_is_8023z(state->interface)) {
565 /* 10M and 100M are only supported in non-802.3z mode */
566 phylink_set(mask, 10baseT_Half);
567 phylink_set(mask, 10baseT_Full);
568 phylink_set(mask, 100baseT_Half);
569 phylink_set(mask, 100baseT_Full);
570 }
571}
572
573static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
574 unsigned long *mask,
575 struct phylink_link_state *state)
576{
577 /* FIXME: if the port is in 1000Base-X mode, then it only supports
578 * 1000M FD speeds. In this case, CMODE will indicate 5.
579 */
580 phylink_set(mask, 1000baseT_Full);
581 phylink_set(mask, 1000baseX_Full);
582
583 mv88e6065_phylink_validate(chip, port, mask, state);
584}
585
Marek Behúne3af71a2019-02-25 12:39:55 +0100586static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
587 unsigned long *mask,
588 struct phylink_link_state *state)
589{
590 if (port >= 5)
591 phylink_set(mask, 2500baseX_Full);
592
593 /* No ethtool bits for 200Mbps */
594 phylink_set(mask, 1000baseT_Full);
595 phylink_set(mask, 1000baseX_Full);
596
597 mv88e6065_phylink_validate(chip, port, mask, state);
598}
599
Russell King6c422e32018-08-09 15:38:39 +0200600static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
601 unsigned long *mask,
602 struct phylink_link_state *state)
603{
604 /* No ethtool bits for 200Mbps */
605 phylink_set(mask, 1000baseT_Full);
606 phylink_set(mask, 1000baseX_Full);
607
608 mv88e6065_phylink_validate(chip, port, mask, state);
609}
610
611static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
612 unsigned long *mask,
613 struct phylink_link_state *state)
614{
Andrew Lunnec260162019-02-08 22:25:44 +0100615 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200616 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100617 phylink_set(mask, 2500baseT_Full);
618 }
Russell King6c422e32018-08-09 15:38:39 +0200619
620 /* No ethtool bits for 200Mbps */
621 phylink_set(mask, 1000baseT_Full);
622 phylink_set(mask, 1000baseX_Full);
623
624 mv88e6065_phylink_validate(chip, port, mask, state);
625}
626
627static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
628 unsigned long *mask,
629 struct phylink_link_state *state)
630{
631 if (port >= 9) {
632 phylink_set(mask, 10000baseT_Full);
633 phylink_set(mask, 10000baseKR_Full);
634 }
635
636 mv88e6390_phylink_validate(chip, port, mask, state);
637}
638
Pavana Sharmade776d02021-03-17 14:46:42 +0100639static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
640 unsigned long *mask,
641 struct phylink_link_state *state)
642{
Marek Behúndc2fc9f2021-11-04 18:17:47 +0100643 bool is_6191x =
644 chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X;
645
646 if (((port == 0 || port == 9) && !is_6191x) || port == 10) {
Pavana Sharmade776d02021-03-17 14:46:42 +0100647 phylink_set(mask, 10000baseT_Full);
648 phylink_set(mask, 10000baseKR_Full);
649 phylink_set(mask, 10000baseCR_Full);
650 phylink_set(mask, 10000baseSR_Full);
651 phylink_set(mask, 10000baseLR_Full);
652 phylink_set(mask, 10000baseLRM_Full);
653 phylink_set(mask, 10000baseER_Full);
654 phylink_set(mask, 5000baseT_Full);
655 phylink_set(mask, 2500baseX_Full);
656 phylink_set(mask, 2500baseT_Full);
657 }
658
659 phylink_set(mask, 1000baseT_Full);
660 phylink_set(mask, 1000baseX_Full);
661
662 mv88e6065_phylink_validate(chip, port, mask, state);
663}
664
Russell Kingc9a23562018-05-10 13:17:35 -0700665static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
666 unsigned long *supported,
667 struct phylink_link_state *state)
668{
Russell King6c422e32018-08-09 15:38:39 +0200669 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
670 struct mv88e6xxx_chip *chip = ds->priv;
671
672 /* Allow all the expected bits */
673 phylink_set(mask, Autoneg);
674 phylink_set(mask, Pause);
675 phylink_set_port_modes(mask);
676
677 if (chip->info->ops->phylink_validate)
678 chip->info->ops->phylink_validate(chip, port, mask, state);
679
Sean Anderson49730562021-10-22 18:41:04 -0400680 linkmode_and(supported, supported, mask);
681 linkmode_and(state->advertising, state->advertising, mask);
Russell King6c422e32018-08-09 15:38:39 +0200682
683 /* We can only operate at 2500BaseX or 1000BaseX. If requested
684 * to advertise both, only report advertising at 2500BaseX.
685 */
686 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700687}
688
Russell Kingc9a23562018-05-10 13:17:35 -0700689static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
690 unsigned int mode,
691 const struct phylink_link_state *state)
692{
693 struct mv88e6xxx_chip *chip = ds->priv;
Russell Kingfad58192020-07-19 12:00:35 +0100694 struct mv88e6xxx_port *p;
Russell King64d47d52020-03-14 10:15:38 +0000695 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700696
Russell Kingfad58192020-07-19 12:00:35 +0100697 p = &chip->ports[port];
698
Russell King64d47d52020-03-14 10:15:38 +0000699 /* FIXME: is this the correct test? If we're in fixed mode on an
700 * internal port, why should we process this any different from
701 * PHY mode? On the other hand, the port may be automedia between
702 * an internal PHY and the serdes...
703 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200704 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700705 return;
706
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000707 mv88e6xxx_reg_lock(chip);
Russell Kingfad58192020-07-19 12:00:35 +0100708 /* In inband mode, the link may come up at any time while the link
709 * is not forced down. Force the link down while we reconfigure the
710 * interface mode.
Russell King64d47d52020-03-14 10:15:38 +0000711 */
Russell Kingfad58192020-07-19 12:00:35 +0100712 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
713 chip->info->ops->port_set_link)
714 chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
715
Russell King64d47d52020-03-14 10:15:38 +0000716 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000717 if (err && err != -EOPNOTSUPP)
718 goto err_unlock;
719
720 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
721 state->advertising);
722 /* FIXME: we should restart negotiation if something changed - which
723 * is something we get if we convert to using phylinks PCS operations.
724 */
725 if (err > 0)
726 err = 0;
727
Russell Kingfad58192020-07-19 12:00:35 +0100728 /* Undo the forced down state above after completing configuration
729 * irrespective of its state on entry, which allows the link to come up.
730 */
731 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
732 chip->info->ops->port_set_link)
733 chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
734
735 p->interface = state->interface;
736
Russell Kinga5a68582020-03-14 10:15:43 +0000737err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000738 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700739
740 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000741 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700742}
743
Russell Kingc9a23562018-05-10 13:17:35 -0700744static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
745 unsigned int mode,
746 phy_interface_t interface)
747{
Russell King30c4a5b2020-02-26 10:23:51 +0000748 struct mv88e6xxx_chip *chip = ds->priv;
749 const struct mv88e6xxx_ops *ops;
750 int err = 0;
751
752 ops = chip->info->ops;
753
Russell King5d5b2312020-03-14 10:16:03 +0000754 mv88e6xxx_reg_lock(chip);
Maarten Zanders4a3e0ae2021-10-11 16:27:20 +0200755 /* Internal PHYs propagate their configuration directly to the MAC.
756 * External PHYs depend on whether the PPU is enabled for this port.
757 */
758 if (((!mv88e6xxx_phy_is_internal(ds, port) &&
759 !mv88e6xxx_port_ppu_updates(chip, port)) ||
Chris Packham4efe76622020-11-24 17:34:37 +1300760 mode == MLO_AN_FIXED) && ops->port_sync_link)
761 err = ops->port_sync_link(chip, port, mode, false);
Russell King5d5b2312020-03-14 10:16:03 +0000762 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000763
Russell King5d5b2312020-03-14 10:16:03 +0000764 if (err)
765 dev_err(chip->dev,
766 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700767}
768
769static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
770 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000771 struct phy_device *phydev,
772 int speed, int duplex,
773 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700774{
Russell King30c4a5b2020-02-26 10:23:51 +0000775 struct mv88e6xxx_chip *chip = ds->priv;
776 const struct mv88e6xxx_ops *ops;
777 int err = 0;
778
779 ops = chip->info->ops;
780
Russell King5d5b2312020-03-14 10:16:03 +0000781 mv88e6xxx_reg_lock(chip);
Maarten Zanders4a3e0ae2021-10-11 16:27:20 +0200782 /* Internal PHYs propagate their configuration directly to the MAC.
783 * External PHYs depend on whether the PPU is enabled for this port.
784 */
785 if ((!mv88e6xxx_phy_is_internal(ds, port) &&
786 !mv88e6xxx_port_ppu_updates(chip, port)) ||
787 mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000788 /* FIXME: for an automedia port, should we force the link
789 * down here - what if the link comes up due to "other" media
790 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000791 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000792 * shared between internal PHY and Serdes.
793 */
Russell Kinga5a68582020-03-14 10:15:43 +0000794 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
795 duplex);
796 if (err)
797 goto error;
798
Russell Kingf365c6f2020-03-14 10:15:53 +0000799 if (ops->port_set_speed_duplex) {
800 err = ops->port_set_speed_duplex(chip, port,
801 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000802 if (err && err != -EOPNOTSUPP)
803 goto error;
804 }
805
Chris Packham4efe76622020-11-24 17:34:37 +1300806 if (ops->port_sync_link)
807 err = ops->port_sync_link(chip, port, mode, true);
Russell King30c4a5b2020-02-26 10:23:51 +0000808 }
Russell King5d5b2312020-03-14 10:16:03 +0000809error:
810 mv88e6xxx_reg_unlock(chip);
811
812 if (err && err != -EOPNOTSUPP)
813 dev_err(ds->dev,
814 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700815}
816
Andrew Lunna605a0f2016-11-21 23:26:58 +0100817static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000818{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100819 if (!chip->info->ops->stats_snapshot)
820 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000821
Andrew Lunna605a0f2016-11-21 23:26:58 +0100822 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000823}
824
Andrew Lunne413e7e2015-04-02 04:06:38 +0200825static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100826 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
827 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
828 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
829 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
830 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
831 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
832 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
833 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
834 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
835 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
836 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
837 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
838 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
839 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
840 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
841 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
842 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
843 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
844 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
845 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
846 { "single", 4, 0x14, STATS_TYPE_BANK0, },
847 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
848 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
849 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
850 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
851 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
852 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
853 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
854 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
855 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
856 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
857 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
858 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
859 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
860 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
861 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
862 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
863 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
864 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
865 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
866 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
867 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
868 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
869 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
870 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
871 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
872 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
873 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
874 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
875 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
876 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
877 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
878 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
879 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
880 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
881 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
882 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
883 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
884 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200885};
886
Vivien Didelotfad09c72016-06-21 12:28:20 -0400887static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100888 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100889 int port, u16 bank1_select,
890 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200891{
Andrew Lunn80c46272015-06-20 18:42:30 +0200892 u32 low;
893 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100894 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200895 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200896 u64 value;
897
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100898 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100899 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200900 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
901 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800902 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200903
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200904 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100905 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200906 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
907 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800908 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000909 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200910 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100911 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100912 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100913 reg = bank1_select;
Gustavo A. R. Silvadf561f662020-08-23 17:36:59 -0500914 fallthrough;
Andrew Lunndfafe442016-11-21 23:27:02 +0100915 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100916 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100917 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100918 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100919 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500920 break;
921 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800922 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200923 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100924 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200925 return value;
926}
927
Andrew Lunn436fe172018-03-01 02:02:29 +0100928static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
929 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100930{
931 struct mv88e6xxx_hw_stat *stat;
932 int i, j;
933
934 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
935 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100936 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100937 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
938 ETH_GSTRING_LEN);
939 j++;
940 }
941 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100942
943 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100944}
945
Andrew Lunn436fe172018-03-01 02:02:29 +0100946static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
947 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100948{
Andrew Lunn436fe172018-03-01 02:02:29 +0100949 return mv88e6xxx_stats_get_strings(chip, data,
950 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100951}
952
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000953static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
954 uint8_t *data)
955{
956 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
957}
958
Andrew Lunn436fe172018-03-01 02:02:29 +0100959static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
960 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100961{
Andrew Lunn436fe172018-03-01 02:02:29 +0100962 return mv88e6xxx_stats_get_strings(chip, data,
963 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100964}
965
Andrew Lunn65f60e42018-03-28 23:50:28 +0200966static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
967 "atu_member_violation",
968 "atu_miss_violation",
969 "atu_full_violation",
970 "vtu_member_violation",
971 "vtu_miss_violation",
972};
973
974static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
975{
976 unsigned int i;
977
978 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
979 strlcpy(data + i * ETH_GSTRING_LEN,
980 mv88e6xxx_atu_vtu_stats_strings[i],
981 ETH_GSTRING_LEN);
982}
983
Andrew Lunndfafe442016-11-21 23:27:02 +0100984static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700985 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100986{
Vivien Didelot04bed142016-08-31 18:06:13 -0400987 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100988 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100989
Florian Fainelli89f09042018-04-25 12:12:50 -0700990 if (stringset != ETH_SS_STATS)
991 return;
992
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000993 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100994
Andrew Lunndfafe442016-11-21 23:27:02 +0100995 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100996 count = chip->info->ops->stats_get_strings(chip, data);
997
998 if (chip->info->ops->serdes_get_strings) {
999 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001000 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001001 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001002
Andrew Lunn65f60e42018-03-28 23:50:28 +02001003 data += count * ETH_GSTRING_LEN;
1004 mv88e6xxx_atu_vtu_get_strings(data);
1005
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001006 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001007}
1008
1009static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
1010 int types)
1011{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001012 struct mv88e6xxx_hw_stat *stat;
1013 int i, j;
1014
1015 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1016 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +01001017 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001018 j++;
1019 }
1020 return j;
1021}
1022
Andrew Lunndfafe442016-11-21 23:27:02 +01001023static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1024{
1025 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1026 STATS_TYPE_PORT);
1027}
1028
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001029static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1030{
1031 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
1032}
1033
Andrew Lunndfafe442016-11-21 23:27:02 +01001034static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1035{
1036 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1037 STATS_TYPE_BANK1);
1038}
1039
Florian Fainelli89f09042018-04-25 12:12:50 -07001040static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001041{
1042 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001043 int serdes_count = 0;
1044 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001045
Florian Fainelli89f09042018-04-25 12:12:50 -07001046 if (sset != ETH_SS_STATS)
1047 return 0;
1048
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001049 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001050 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001051 count = chip->info->ops->stats_get_sset_count(chip);
1052 if (count < 0)
1053 goto out;
1054
1055 if (chip->info->ops->serdes_get_sset_count)
1056 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1057 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001058 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001059 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001060 goto out;
1061 }
1062 count += serdes_count;
1063 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1064
Andrew Lunn436fe172018-03-01 02:02:29 +01001065out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001066 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001067
Andrew Lunn436fe172018-03-01 02:02:29 +01001068 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001069}
1070
Andrew Lunn436fe172018-03-01 02:02:29 +01001071static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1072 uint64_t *data, int types,
1073 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001074{
1075 struct mv88e6xxx_hw_stat *stat;
1076 int i, j;
1077
1078 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1079 stat = &mv88e6xxx_hw_stats[i];
1080 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001081 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001082 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1083 bank1_select,
1084 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001085 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001086
Andrew Lunn052f9472016-11-21 23:27:03 +01001087 j++;
1088 }
1089 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001090 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001091}
1092
Andrew Lunn436fe172018-03-01 02:02:29 +01001093static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1094 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001095{
1096 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001097 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001098 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001099}
1100
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001101static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1102 uint64_t *data)
1103{
1104 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1105 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1106}
1107
Andrew Lunn436fe172018-03-01 02:02:29 +01001108static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1109 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001110{
1111 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001112 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001113 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1114 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001115}
1116
Andrew Lunn436fe172018-03-01 02:02:29 +01001117static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1118 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001119{
1120 return mv88e6xxx_stats_get_stats(chip, port, data,
1121 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001122 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1123 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001124}
1125
Andrew Lunn65f60e42018-03-28 23:50:28 +02001126static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1127 uint64_t *data)
1128{
1129 *data++ = chip->ports[port].atu_member_violation;
1130 *data++ = chip->ports[port].atu_miss_violation;
1131 *data++ = chip->ports[port].atu_full_violation;
1132 *data++ = chip->ports[port].vtu_member_violation;
1133 *data++ = chip->ports[port].vtu_miss_violation;
1134}
1135
Andrew Lunn052f9472016-11-21 23:27:03 +01001136static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1137 uint64_t *data)
1138{
Andrew Lunn436fe172018-03-01 02:02:29 +01001139 int count = 0;
1140
Andrew Lunn052f9472016-11-21 23:27:03 +01001141 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001142 count = chip->info->ops->stats_get_stats(chip, port, data);
1143
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001144 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001145 if (chip->info->ops->serdes_get_stats) {
1146 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001147 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001148 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001149 data += count;
1150 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001151 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001152}
1153
Vivien Didelotf81ec902016-05-09 13:22:58 -04001154static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1155 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001156{
Vivien Didelot04bed142016-08-31 18:06:13 -04001157 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001158 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001159
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001160 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001161
Andrew Lunna605a0f2016-11-21 23:26:58 +01001162 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001163 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001164
1165 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001166 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001167
1168 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001169
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001170}
Ben Hutchings98e67302011-11-25 14:36:19 +00001171
Vivien Didelotf81ec902016-05-09 13:22:58 -04001172static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001173{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001174 struct mv88e6xxx_chip *chip = ds->priv;
1175 int len;
1176
1177 len = 32 * sizeof(u16);
1178 if (chip->info->ops->serdes_get_regs_len)
1179 len += chip->info->ops->serdes_get_regs_len(chip, port);
1180
1181 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001182}
1183
Vivien Didelotf81ec902016-05-09 13:22:58 -04001184static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1185 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001186{
Vivien Didelot04bed142016-08-31 18:06:13 -04001187 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001188 int err;
1189 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001190 u16 *p = _p;
1191 int i;
1192
Vivien Didelota5f39322018-12-17 16:05:21 -05001193 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001194
1195 memset(p, 0xff, 32 * sizeof(u16));
1196
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001197 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001198
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001199 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001200
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001201 err = mv88e6xxx_port_read(chip, port, i, &reg);
1202 if (!err)
1203 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001204 }
Vivien Didelot23062512016-05-09 13:22:45 -04001205
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001206 if (chip->info->ops->serdes_get_regs)
1207 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1208
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001209 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001210}
1211
Vivien Didelot08f50062017-08-01 16:32:41 -04001212static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1213 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001214{
Vivien Didelot5480db62017-08-01 16:32:40 -04001215 /* Nothing to do on the port's MAC */
1216 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001217}
1218
Vivien Didelot08f50062017-08-01 16:32:41 -04001219static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1220 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001221{
Vivien Didelot5480db62017-08-01 16:32:40 -04001222 /* Nothing to do on the port's MAC */
1223 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001224}
1225
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001226/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001227static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001228{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001229 struct dsa_switch *ds = chip->ds;
1230 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001231 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001232 struct dsa_port *dp;
1233 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001234 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001235
Vladimir Olteance5df682021-07-22 18:55:41 +03001236 /* dev is a physical switch */
1237 if (dev <= dst->last_switch) {
1238 list_for_each_entry(dp, &dst->ports, list) {
1239 if (dp->ds->index == dev && dp->index == port) {
1240 /* dp might be a DSA link or a user port, so it
1241 * might or might not have a bridge_dev
1242 * pointer. Use the "found" variable for both
1243 * cases.
1244 */
1245 br = dp->bridge_dev;
1246 found = true;
1247 break;
1248 }
1249 }
1250 /* dev is a virtual bridge */
1251 } else {
1252 list_for_each_entry(dp, &dst->ports, list) {
Vladimir Oltean3f9bb032021-12-06 18:57:47 +02001253 if (!dp->bridge_num)
Vladimir Olteance5df682021-07-22 18:55:41 +03001254 continue;
1255
Vladimir Oltean3f9bb032021-12-06 18:57:47 +02001256 if (dp->bridge_num + dst->last_switch != dev)
Vladimir Olteance5df682021-07-22 18:55:41 +03001257 continue;
1258
1259 br = dp->bridge_dev;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001260 found = true;
1261 break;
1262 }
1263 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001264
Vladimir Olteance5df682021-07-22 18:55:41 +03001265 /* Prevent frames from unknown switch or virtual bridge */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001266 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001267 return 0;
1268
1269 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001270 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001271 return mv88e6xxx_port_mask(chip);
1272
Vivien Didelote5887a22017-03-30 17:37:11 -04001273 pvlan = 0;
1274
1275 /* Frames from user ports can egress any local DSA links and CPU ports,
1276 * as well as any local member of their bridge group.
1277 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001278 list_for_each_entry(dp, &dst->ports, list)
1279 if (dp->ds == ds &&
1280 (dp->type == DSA_PORT_TYPE_CPU ||
1281 dp->type == DSA_PORT_TYPE_DSA ||
1282 (br && dp->bridge_dev == br)))
1283 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001284
1285 return pvlan;
1286}
1287
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001288static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001289{
1290 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001291
1292 /* prevent frames from going back out of the port they came in on */
1293 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001294
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001295 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001296}
1297
Vivien Didelotf81ec902016-05-09 13:22:58 -04001298static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1299 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001300{
Vivien Didelot04bed142016-08-31 18:06:13 -04001301 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001302 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001303
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001304 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001305 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001306 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001307
1308 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001309 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001310}
1311
Vivien Didelot93e18d62018-05-11 17:16:35 -04001312static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1313{
1314 int err;
1315
1316 if (chip->info->ops->ieee_pri_map) {
1317 err = chip->info->ops->ieee_pri_map(chip);
1318 if (err)
1319 return err;
1320 }
1321
1322 if (chip->info->ops->ip_pri_map) {
1323 err = chip->info->ops->ip_pri_map(chip);
1324 if (err)
1325 return err;
1326 }
1327
1328 return 0;
1329}
1330
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001331static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1332{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001333 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001334 int target, port;
1335 int err;
1336
1337 if (!chip->info->global2_addr)
1338 return 0;
1339
1340 /* Initialize the routing port to the 32 possible target devices */
1341 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001342 port = dsa_routing_port(ds, target);
1343 if (port == ds->num_ports)
1344 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001345
1346 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1347 if (err)
1348 return err;
1349 }
1350
Vivien Didelot02317e62018-05-09 11:38:49 -04001351 if (chip->info->ops->set_cascade_port) {
1352 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1353 err = chip->info->ops->set_cascade_port(chip, port);
1354 if (err)
1355 return err;
1356 }
1357
Vivien Didelot23c98912018-05-09 11:38:50 -04001358 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1359 if (err)
1360 return err;
1361
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001362 return 0;
1363}
1364
Vivien Didelotb28f8722018-04-26 21:56:44 -04001365static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1366{
1367 /* Clear all trunk masks and mapping */
1368 if (chip->info->global2_addr)
1369 return mv88e6xxx_g2_trunk_clear(chip);
1370
1371 return 0;
1372}
1373
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001374static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1375{
1376 if (chip->info->ops->rmu_disable)
1377 return chip->info->ops->rmu_disable(chip);
1378
1379 return 0;
1380}
1381
Vivien Didelot9e907d72017-07-17 13:03:43 -04001382static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1383{
1384 if (chip->info->ops->pot_clear)
1385 return chip->info->ops->pot_clear(chip);
1386
1387 return 0;
1388}
1389
Vivien Didelot51c901a2017-07-17 13:03:41 -04001390static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1391{
1392 if (chip->info->ops->mgmt_rsvd2cpu)
1393 return chip->info->ops->mgmt_rsvd2cpu(chip);
1394
1395 return 0;
1396}
1397
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001398static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1399{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001400 int err;
1401
Vivien Didelotdaefc942017-03-11 16:12:54 -05001402 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1403 if (err)
1404 return err;
1405
Rasmus Villemoes49506a92020-12-10 12:06:44 +01001406 /* The chips that have a "learn2all" bit in Global1, ATU
1407 * Control are precisely those whose port registers have a
1408 * Message Port bit in Port Control 1 and hence implement
1409 * ->port_setup_message_port.
1410 */
1411 if (chip->info->ops->port_setup_message_port) {
1412 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1413 if (err)
1414 return err;
1415 }
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001416
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001417 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1418}
1419
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001420static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1421{
1422 int port;
1423 int err;
1424
1425 if (!chip->info->ops->irl_init_all)
1426 return 0;
1427
1428 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1429 /* Disable ingress rate limiting by resetting all per port
1430 * ingress rate limit resources to their initial state.
1431 */
1432 err = chip->info->ops->irl_init_all(chip, port);
1433 if (err)
1434 return err;
1435 }
1436
1437 return 0;
1438}
1439
Vivien Didelot04a69a12017-10-13 14:18:05 -04001440static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1441{
1442 if (chip->info->ops->set_switch_mac) {
1443 u8 addr[ETH_ALEN];
1444
1445 eth_random_addr(addr);
1446
1447 return chip->info->ops->set_switch_mac(chip, addr);
1448 }
1449
1450 return 0;
1451}
1452
Vivien Didelot17a15942017-03-30 17:37:09 -04001453static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1454{
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001455 struct dsa_switch_tree *dst = chip->ds->dst;
1456 struct dsa_switch *ds;
1457 struct dsa_port *dp;
Vivien Didelot17a15942017-03-30 17:37:09 -04001458 u16 pvlan = 0;
1459
1460 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001461 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001462
1463 /* Skip the local source device, which uses in-chip port VLAN */
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001464 if (dev != chip->ds->index) {
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001465 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001466
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001467 ds = dsa_switch_find(dst->index, dev);
1468 dp = ds ? dsa_to_port(ds, port) : NULL;
1469 if (dp && dp->lag_dev) {
1470 /* As the PVT is used to limit flooding of
1471 * FORWARD frames, which use the LAG ID as the
1472 * source port, we must translate dev/port to
1473 * the special "LAG device" in the PVT, using
1474 * the LAG ID as the port number.
1475 */
Tobias Waldekranz78e70db2021-04-21 14:04:52 +02001476 dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001477 port = dsa_lag_id(dst, dp->lag_dev);
1478 }
1479 }
1480
Vivien Didelot17a15942017-03-30 17:37:09 -04001481 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1482}
1483
Vivien Didelot81228992017-03-30 17:37:08 -04001484static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1485{
Vivien Didelot17a15942017-03-30 17:37:09 -04001486 int dev, port;
1487 int err;
1488
Vivien Didelot81228992017-03-30 17:37:08 -04001489 if (!mv88e6xxx_has_pvt(chip))
1490 return 0;
1491
1492 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1493 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1494 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001495 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1496 if (err)
1497 return err;
1498
1499 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1500 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1501 err = mv88e6xxx_pvt_map(chip, dev, port);
1502 if (err)
1503 return err;
1504 }
1505 }
1506
1507 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001508}
1509
Vivien Didelot749efcb2016-09-22 16:49:24 -04001510static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1511{
1512 struct mv88e6xxx_chip *chip = ds->priv;
1513 int err;
1514
Tobias Waldekranzffcec3f2021-03-18 20:25:34 +01001515 if (dsa_to_port(ds, port)->lag_dev)
1516 /* Hardware is incapable of fast-aging a LAG through a
1517 * regular ATU move operation. Until we have something
1518 * more fancy in place this is a no-op.
1519 */
1520 return;
1521
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001522 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001523 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001524 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001525
1526 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001527 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001528}
1529
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001530static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1531{
Tobias Waldekranze545f862020-11-10 19:57:20 +01001532 if (!mv88e6xxx_max_vid(chip))
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001533 return 0;
1534
1535 return mv88e6xxx_g1_vtu_flush(chip);
1536}
1537
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001538static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1539 struct mv88e6xxx_vtu_entry *entry)
Vivien Didelotf1394b782017-05-01 14:05:22 -04001540{
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001541 int err;
1542
Vivien Didelotf1394b782017-05-01 14:05:22 -04001543 if (!chip->info->ops->vtu_getnext)
1544 return -EOPNOTSUPP;
1545
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001546 entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip);
1547 entry->valid = false;
1548
1549 err = chip->info->ops->vtu_getnext(chip, entry);
1550
1551 if (entry->vid != vid)
1552 entry->valid = false;
1553
1554 return err;
Vivien Didelotf1394b782017-05-01 14:05:22 -04001555}
1556
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001557static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip,
1558 int (*cb)(struct mv88e6xxx_chip *chip,
1559 const struct mv88e6xxx_vtu_entry *entry,
1560 void *priv),
1561 void *priv)
1562{
1563 struct mv88e6xxx_vtu_entry entry = {
1564 .vid = mv88e6xxx_max_vid(chip),
1565 .valid = false,
1566 };
1567 int err;
1568
1569 if (!chip->info->ops->vtu_getnext)
1570 return -EOPNOTSUPP;
1571
1572 do {
1573 err = chip->info->ops->vtu_getnext(chip, &entry);
1574 if (err)
1575 return err;
1576
1577 if (!entry.valid)
1578 break;
1579
1580 err = cb(chip, &entry, priv);
1581 if (err)
1582 return err;
1583 } while (entry.vid < mv88e6xxx_max_vid(chip));
1584
1585 return 0;
1586}
1587
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001588static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1589 struct mv88e6xxx_vtu_entry *entry)
1590{
1591 if (!chip->info->ops->vtu_loadpurge)
1592 return -EOPNOTSUPP;
1593
1594 return chip->info->ops->vtu_loadpurge(chip, entry);
1595}
1596
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001597static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip,
1598 const struct mv88e6xxx_vtu_entry *entry,
1599 void *_fid_bitmap)
1600{
1601 unsigned long *fid_bitmap = _fid_bitmap;
1602
1603 set_bit(entry->fid, fid_bitmap);
1604 return 0;
1605}
1606
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001607int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001608{
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001609 int i, err;
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001610 u16 fid;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001611
1612 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1613
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001614 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001615 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001616 err = mv88e6xxx_port_get_fid(chip, i, &fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001617 if (err)
1618 return err;
1619
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001620 set_bit(fid, fid_bitmap);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001621 }
1622
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001623 /* Set every FID bit used by the VLAN entries */
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001624 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap);
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001625}
1626
1627static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1628{
1629 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1630 int err;
1631
1632 err = mv88e6xxx_fid_map(chip, fid_bitmap);
1633 if (err)
1634 return err;
1635
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001636 /* The reset value 0x000 is used to indicate that multiple address
1637 * databases are not needed. Return the next positive available.
1638 */
1639 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001640 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001641 return -ENOSPC;
1642
1643 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001644 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001645}
1646
Vivien Didelotda9c3592016-02-12 12:09:40 -05001647static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001648 u16 vid)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001649{
Vladimir Oltean0493fa72021-12-06 18:57:50 +02001650 struct dsa_port *dp = dsa_to_port(ds, port), *other_dp;
Vivien Didelot04bed142016-08-31 18:06:13 -04001651 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001652 struct mv88e6xxx_vtu_entry vlan;
Vladimir Oltean0493fa72021-12-06 18:57:50 +02001653 int err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001654
Andrew Lunndb06ae412017-09-25 23:32:20 +02001655 /* DSA and CPU ports have to be members of multiple vlans */
Vladimir Oltean0493fa72021-12-06 18:57:50 +02001656 if (dsa_port_is_dsa(dp) || dsa_port_is_cpu(dp))
Andrew Lunndb06ae412017-09-25 23:32:20 +02001657 return 0;
1658
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001659 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001660 if (err)
1661 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001662
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001663 if (!vlan.valid)
1664 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001665
Vladimir Oltean0493fa72021-12-06 18:57:50 +02001666 dsa_switch_for_each_user_port(other_dp, ds) {
1667 if (vlan.member[other_dp->index] ==
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001668 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
1669 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001670
Vladimir Oltean0493fa72021-12-06 18:57:50 +02001671 if (dp->bridge_dev == other_dp->bridge_dev)
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001672 break; /* same bridge, check next VLAN */
Vivien Didelotda9c3592016-02-12 12:09:40 -05001673
Vladimir Oltean0493fa72021-12-06 18:57:50 +02001674 if (!other_dp->bridge_dev)
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001675 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001676
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001677 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
Vladimir Oltean0493fa72021-12-06 18:57:50 +02001678 port, vlan.vid, other_dp->index,
1679 netdev_name(other_dp->bridge_dev));
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001680 return -EOPNOTSUPP;
1681 }
Vivien Didelotda9c3592016-02-12 12:09:40 -05001682
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001683 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001684}
1685
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001686static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port)
1687{
1688 struct dsa_port *dp = dsa_to_port(chip->ds, port);
1689 struct mv88e6xxx_port *p = &chip->ports[port];
Vladimir Oltean5bded822021-10-07 19:47:11 +03001690 u16 pvid = MV88E6XXX_VID_STANDALONE;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001691 bool drop_untagged = false;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001692 int err;
1693
Vladimir Oltean5bded822021-10-07 19:47:11 +03001694 if (dp->bridge_dev) {
1695 if (br_vlan_enabled(dp->bridge_dev)) {
1696 pvid = p->bridge_pvid.vid;
1697 drop_untagged = !p->bridge_pvid.valid;
1698 } else {
1699 pvid = MV88E6XXX_VID_BRIDGED;
1700 }
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001701 }
1702
1703 err = mv88e6xxx_port_set_pvid(chip, port, pvid);
1704 if (err)
1705 return err;
1706
1707 return mv88e6xxx_port_drop_untagged(chip, port, drop_untagged);
1708}
1709
Vivien Didelotf81ec902016-05-09 13:22:58 -04001710static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
Vladimir Oltean89153ed2021-02-13 22:43:19 +02001711 bool vlan_filtering,
1712 struct netlink_ext_ack *extack)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001713{
Vivien Didelot04bed142016-08-31 18:06:13 -04001714 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001715 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1716 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001717 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001718
Vladimir Olteanbae33f22021-01-09 02:01:50 +02001719 if (!mv88e6xxx_max_vid(chip))
1720 return -EOPNOTSUPP;
Vivien Didelot54d77b52016-05-09 13:22:47 -04001721
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001722 mv88e6xxx_reg_lock(chip);
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001723
Vivien Didelot385a0992016-11-04 03:23:31 +01001724 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001725 if (err)
1726 goto unlock;
1727
1728 err = mv88e6xxx_port_commit_pvid(chip, port);
1729 if (err)
1730 goto unlock;
1731
1732unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001733 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001734
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001735 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001736}
1737
Vivien Didelot57d32312016-06-20 13:13:58 -04001738static int
1739mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001740 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001741{
Vivien Didelot04bed142016-08-31 18:06:13 -04001742 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001743 int err;
1744
Tobias Waldekranze545f862020-11-10 19:57:20 +01001745 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001746 return -EOPNOTSUPP;
1747
Vivien Didelotda9c3592016-02-12 12:09:40 -05001748 /* If the requested port doesn't belong to the same bridge as the VLAN
1749 * members, do not support it (yet) and fallback to software VLAN.
1750 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001751 mv88e6xxx_reg_lock(chip);
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001752 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001753 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001754
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001755 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001756}
1757
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001758static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1759 const unsigned char *addr, u16 vid,
1760 u8 state)
1761{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001762 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001763 struct mv88e6xxx_vtu_entry vlan;
1764 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001765 int err;
1766
Vladimir Oltean5bded822021-10-07 19:47:11 +03001767 /* Ports have two private address databases: one for when the port is
1768 * standalone and one for when the port is under a bridge and the
1769 * 802.1Q mode is disabled. When the port is standalone, DSA wants its
1770 * address database to remain 100% empty, so we never load an ATU entry
1771 * into a standalone port's database. Therefore, translate the null
1772 * VLAN ID into the port's database used for VLAN-unaware bridging.
1773 */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001774 if (vid == 0) {
Vladimir Oltean5bded822021-10-07 19:47:11 +03001775 fid = MV88E6XXX_FID_BRIDGED;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001776 } else {
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001777 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001778 if (err)
1779 return err;
1780
1781 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001782 if (!vlan.valid)
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001783 return -EOPNOTSUPP;
1784
1785 fid = vlan.fid;
1786 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001787
Vivien Didelotd8291a92019-09-07 16:00:47 -04001788 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001789 ether_addr_copy(entry.mac, addr);
1790 eth_addr_dec(entry.mac);
1791
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001792 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001793 if (err)
1794 return err;
1795
1796 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001797 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001798 memset(&entry, 0, sizeof(entry));
1799 ether_addr_copy(entry.mac, addr);
1800 }
1801
1802 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001803 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001804 entry.portvec &= ~BIT(port);
1805 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001806 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001807 } else {
DENG Qingfangf72f2fb2021-01-30 21:43:34 +08001808 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
1809 entry.portvec = BIT(port);
1810 else
1811 entry.portvec |= BIT(port);
1812
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001813 entry.state = state;
1814 }
1815
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001816 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001817}
1818
Vivien Didelotda7dc872019-09-07 16:00:49 -04001819static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1820 const struct mv88e6xxx_policy *policy)
1821{
1822 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1823 enum mv88e6xxx_policy_action action = policy->action;
1824 const u8 *addr = policy->addr;
1825 u16 vid = policy->vid;
1826 u8 state;
1827 int err;
1828 int id;
1829
1830 if (!chip->info->ops->port_set_policy)
1831 return -EOPNOTSUPP;
1832
1833 switch (mapping) {
1834 case MV88E6XXX_POLICY_MAPPING_DA:
1835 case MV88E6XXX_POLICY_MAPPING_SA:
1836 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1837 state = 0; /* Dissociate the port and address */
1838 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1839 is_multicast_ether_addr(addr))
1840 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1841 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1842 is_unicast_ether_addr(addr))
1843 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1844 else
1845 return -EOPNOTSUPP;
1846
1847 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1848 state);
1849 if (err)
1850 return err;
1851 break;
1852 default:
1853 return -EOPNOTSUPP;
1854 }
1855
1856 /* Skip the port's policy clearing if the mapping is still in use */
1857 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1858 idr_for_each_entry(&chip->policies, policy, id)
1859 if (policy->port == port &&
1860 policy->mapping == mapping &&
1861 policy->action != action)
1862 return 0;
1863
1864 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1865}
1866
1867static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1868 struct ethtool_rx_flow_spec *fs)
1869{
1870 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1871 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1872 enum mv88e6xxx_policy_mapping mapping;
1873 enum mv88e6xxx_policy_action action;
1874 struct mv88e6xxx_policy *policy;
1875 u16 vid = 0;
1876 u8 *addr;
1877 int err;
1878 int id;
1879
1880 if (fs->location != RX_CLS_LOC_ANY)
1881 return -EINVAL;
1882
1883 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1884 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1885 else
1886 return -EOPNOTSUPP;
1887
1888 switch (fs->flow_type & ~FLOW_EXT) {
1889 case ETHER_FLOW:
1890 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1891 is_zero_ether_addr(mac_mask->h_source)) {
1892 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1893 addr = mac_entry->h_dest;
1894 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1895 !is_zero_ether_addr(mac_mask->h_source)) {
1896 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1897 addr = mac_entry->h_source;
1898 } else {
1899 /* Cannot support DA and SA mapping in the same rule */
1900 return -EOPNOTSUPP;
1901 }
1902 break;
1903 default:
1904 return -EOPNOTSUPP;
1905 }
1906
1907 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001908 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001909 return -EOPNOTSUPP;
1910 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1911 }
1912
1913 idr_for_each_entry(&chip->policies, policy, id) {
1914 if (policy->port == port && policy->mapping == mapping &&
1915 policy->action == action && policy->vid == vid &&
1916 ether_addr_equal(policy->addr, addr))
1917 return -EEXIST;
1918 }
1919
1920 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1921 if (!policy)
1922 return -ENOMEM;
1923
1924 fs->location = 0;
1925 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1926 GFP_KERNEL);
1927 if (err) {
1928 devm_kfree(chip->dev, policy);
1929 return err;
1930 }
1931
1932 memcpy(&policy->fs, fs, sizeof(*fs));
1933 ether_addr_copy(policy->addr, addr);
1934 policy->mapping = mapping;
1935 policy->action = action;
1936 policy->port = port;
1937 policy->vid = vid;
1938
1939 err = mv88e6xxx_policy_apply(chip, port, policy);
1940 if (err) {
1941 idr_remove(&chip->policies, fs->location);
1942 devm_kfree(chip->dev, policy);
1943 return err;
1944 }
1945
1946 return 0;
1947}
1948
1949static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1950 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1951{
1952 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1953 struct mv88e6xxx_chip *chip = ds->priv;
1954 struct mv88e6xxx_policy *policy;
1955 int err;
1956 int id;
1957
1958 mv88e6xxx_reg_lock(chip);
1959
1960 switch (rxnfc->cmd) {
1961 case ETHTOOL_GRXCLSRLCNT:
1962 rxnfc->data = 0;
1963 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1964 rxnfc->rule_cnt = 0;
1965 idr_for_each_entry(&chip->policies, policy, id)
1966 if (policy->port == port)
1967 rxnfc->rule_cnt++;
1968 err = 0;
1969 break;
1970 case ETHTOOL_GRXCLSRULE:
1971 err = -ENOENT;
1972 policy = idr_find(&chip->policies, fs->location);
1973 if (policy) {
1974 memcpy(fs, &policy->fs, sizeof(*fs));
1975 err = 0;
1976 }
1977 break;
1978 case ETHTOOL_GRXCLSRLALL:
1979 rxnfc->data = 0;
1980 rxnfc->rule_cnt = 0;
1981 idr_for_each_entry(&chip->policies, policy, id)
1982 if (policy->port == port)
1983 rule_locs[rxnfc->rule_cnt++] = id;
1984 err = 0;
1985 break;
1986 default:
1987 err = -EOPNOTSUPP;
1988 break;
1989 }
1990
1991 mv88e6xxx_reg_unlock(chip);
1992
1993 return err;
1994}
1995
1996static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1997 struct ethtool_rxnfc *rxnfc)
1998{
1999 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
2000 struct mv88e6xxx_chip *chip = ds->priv;
2001 struct mv88e6xxx_policy *policy;
2002 int err;
2003
2004 mv88e6xxx_reg_lock(chip);
2005
2006 switch (rxnfc->cmd) {
2007 case ETHTOOL_SRXCLSRLINS:
2008 err = mv88e6xxx_policy_insert(chip, port, fs);
2009 break;
2010 case ETHTOOL_SRXCLSRLDEL:
2011 err = -ENOENT;
2012 policy = idr_remove(&chip->policies, fs->location);
2013 if (policy) {
2014 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
2015 err = mv88e6xxx_policy_apply(chip, port, policy);
2016 devm_kfree(chip->dev, policy);
2017 }
2018 break;
2019 default:
2020 err = -EOPNOTSUPP;
2021 break;
2022 }
2023
2024 mv88e6xxx_reg_unlock(chip);
2025
2026 return err;
2027}
2028
Andrew Lunn87fa8862017-11-09 22:29:56 +01002029static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
2030 u16 vid)
2031{
Andrew Lunn87fa8862017-11-09 22:29:56 +01002032 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
Tobias Waldekranz0806dd462021-03-18 20:25:37 +01002033 u8 broadcast[ETH_ALEN];
2034
2035 eth_broadcast_addr(broadcast);
Andrew Lunn87fa8862017-11-09 22:29:56 +01002036
2037 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
2038}
2039
2040static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
2041{
2042 int port;
2043 int err;
2044
2045 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01002046 struct dsa_port *dp = dsa_to_port(chip->ds, port);
2047 struct net_device *brport;
2048
2049 if (dsa_is_unused_port(chip->ds, port))
2050 continue;
2051
2052 brport = dsa_port_to_bridge_port(dp);
2053 if (brport && !br_port_flag_is_set(brport, BR_BCAST_FLOOD))
2054 /* Skip bridged user ports where broadcast
2055 * flooding is disabled.
2056 */
2057 continue;
2058
Andrew Lunn87fa8862017-11-09 22:29:56 +01002059 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
2060 if (err)
2061 return err;
2062 }
2063
2064 return 0;
2065}
2066
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01002067struct mv88e6xxx_port_broadcast_sync_ctx {
2068 int port;
2069 bool flood;
2070};
2071
2072static int
2073mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip,
2074 const struct mv88e6xxx_vtu_entry *vlan,
2075 void *_ctx)
2076{
2077 struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx;
2078 u8 broadcast[ETH_ALEN];
2079 u8 state;
2080
2081 if (ctx->flood)
2082 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
2083 else
2084 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED;
2085
2086 eth_broadcast_addr(broadcast);
2087
2088 return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast,
2089 vlan->vid, state);
2090}
2091
2092static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port,
2093 bool flood)
2094{
2095 struct mv88e6xxx_port_broadcast_sync_ctx ctx = {
2096 .port = port,
2097 .flood = flood,
2098 };
2099 struct mv88e6xxx_vtu_entry vid0 = {
2100 .vid = 0,
2101 };
2102 int err;
2103
2104 /* Update the port's private database... */
2105 err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx);
2106 if (err)
2107 return err;
2108
2109 /* ...and the database for all VLANs. */
2110 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan,
2111 &ctx);
2112}
2113
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002114static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00002115 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002116{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002117 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002118 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002119 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002120
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002121 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002122 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002123 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002124
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002125 if (!vlan.valid) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002126 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002127
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002128 err = mv88e6xxx_atu_new(chip, &vlan.fid);
2129 if (err)
2130 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01002131
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002132 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
2133 if (i == port)
2134 vlan.member[i] = member;
2135 else
2136 vlan.member[i] = non_member;
2137
2138 vlan.vid = vid;
2139 vlan.valid = true;
2140
2141 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2142 if (err)
2143 return err;
2144
2145 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
2146 if (err)
2147 return err;
2148 } else if (vlan.member[port] != member) {
2149 vlan.member[port] = member;
2150
2151 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2152 if (err)
2153 return err;
Russell King933b4422020-02-26 17:14:26 +00002154 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002155 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
2156 port, vid);
2157 }
2158
2159 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002160}
2161
Vladimir Oltean1958d582021-01-09 02:01:53 +02002162static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vladimir Oltean31046a52021-02-13 22:43:18 +02002163 const struct switchdev_obj_port_vlan *vlan,
2164 struct netlink_ext_ack *extack)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002165{
Vivien Didelot04bed142016-08-31 18:06:13 -04002166 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002167 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
2168 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002169 struct mv88e6xxx_port *p = &chip->ports[port];
Russell King933b4422020-02-26 17:14:26 +00002170 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002171 u8 member;
Vladimir Oltean1958d582021-01-09 02:01:53 +02002172 int err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002173
Eldar Gasanovb8b79c42021-06-21 11:54:38 +03002174 if (!vlan->vid)
2175 return 0;
2176
Vladimir Oltean1958d582021-01-09 02:01:53 +02002177 err = mv88e6xxx_port_vlan_prepare(ds, port, vlan);
2178 if (err)
2179 return err;
Vivien Didelot54d77b52016-05-09 13:22:47 -04002180
Vivien Didelotc91498e2017-06-07 18:12:13 -04002181 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002182 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002183 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002184 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002185 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002186 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002187
Russell King933b4422020-02-26 17:14:26 +00002188 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
2189 * and then the CPU port. Do not warn for duplicates for the CPU port.
2190 */
2191 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
2192
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002193 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002194
Vladimir Oltean1958d582021-01-09 02:01:53 +02002195 err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn);
2196 if (err) {
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002197 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
2198 vlan->vid, untagged ? 'u' : 't');
Vladimir Oltean1958d582021-01-09 02:01:53 +02002199 goto out;
2200 }
Vivien Didelot76e398a2015-11-01 12:33:55 -05002201
Vladimir Oltean1958d582021-01-09 02:01:53 +02002202 if (pvid) {
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002203 p->bridge_pvid.vid = vlan->vid;
2204 p->bridge_pvid.valid = true;
2205
2206 err = mv88e6xxx_port_commit_pvid(chip, port);
2207 if (err)
Vladimir Oltean1958d582021-01-09 02:01:53 +02002208 goto out;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002209 } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) {
2210 /* The old pvid was reinstalled as a non-pvid VLAN */
2211 p->bridge_pvid.valid = false;
2212
2213 err = mv88e6xxx_port_commit_pvid(chip, port);
2214 if (err)
2215 goto out;
Vladimir Oltean1958d582021-01-09 02:01:53 +02002216 }
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002217
Vladimir Oltean1958d582021-01-09 02:01:53 +02002218out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002219 mv88e6xxx_reg_unlock(chip);
Vladimir Oltean1958d582021-01-09 02:01:53 +02002220
2221 return err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002222}
2223
Vivien Didelot521098922019-08-01 14:36:36 -04002224static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2225 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002226{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002227 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002228 int i, err;
2229
Vivien Didelot521098922019-08-01 14:36:36 -04002230 if (!vid)
Vladimir Olteanc92c7412021-07-22 16:05:51 +03002231 return 0;
Vivien Didelot521098922019-08-01 14:36:36 -04002232
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002233 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002234 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002235 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002236
Vivien Didelot521098922019-08-01 14:36:36 -04002237 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2238 * tell switchdev that this VLAN is likely handled in software.
2239 */
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002240 if (!vlan.valid ||
Vivien Didelot521098922019-08-01 14:36:36 -04002241 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002242 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002243
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002244 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002245
2246 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002247 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002248 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002249 if (vlan.member[i] !=
2250 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002251 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002252 break;
2253 }
2254 }
2255
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002256 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002257 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002258 return err;
2259
Vivien Didelote606ca32017-03-11 16:12:55 -05002260 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002261}
2262
Vivien Didelotf81ec902016-05-09 13:22:58 -04002263static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2264 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002265{
Vivien Didelot04bed142016-08-31 18:06:13 -04002266 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002267 struct mv88e6xxx_port *p = &chip->ports[port];
Vivien Didelot76e398a2015-11-01 12:33:55 -05002268 int err = 0;
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002269 u16 pvid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002270
Tobias Waldekranze545f862020-11-10 19:57:20 +01002271 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04002272 return -EOPNOTSUPP;
2273
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002274 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002275
Vivien Didelot77064f32016-11-04 03:23:30 +01002276 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002277 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002278 goto unlock;
2279
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002280 err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid);
2281 if (err)
2282 goto unlock;
2283
2284 if (vlan->vid == pvid) {
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002285 p->bridge_pvid.valid = false;
2286
2287 err = mv88e6xxx_port_commit_pvid(chip, port);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002288 if (err)
2289 goto unlock;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002290 }
2291
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002292unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002293 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002294
2295 return err;
2296}
2297
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002298static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2299 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002300{
Vivien Didelot04bed142016-08-31 18:06:13 -04002301 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002302 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002303
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002304 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002305 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2306 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002307 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002308
2309 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002310}
2311
Vivien Didelotf81ec902016-05-09 13:22:58 -04002312static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002313 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002314{
Vivien Didelot04bed142016-08-31 18:06:13 -04002315 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002316 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002317
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002318 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002319 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002320 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002321
Vivien Didelot83dabd12016-08-31 11:50:04 -04002322 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002323}
2324
Vivien Didelot83dabd12016-08-31 11:50:04 -04002325static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2326 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002327 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002328{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002329 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002330 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002331 int err;
2332
Vivien Didelotd8291a92019-09-07 16:00:47 -04002333 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002334 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002335
2336 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002337 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002338 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002339 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002340
Vivien Didelotd8291a92019-09-07 16:00:47 -04002341 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002342 break;
2343
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002344 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002345 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002346
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002347 if (!is_unicast_ether_addr(addr.mac))
2348 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002349
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002350 is_static = (addr.state ==
2351 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2352 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002353 if (err)
2354 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002355 } while (!is_broadcast_ether_addr(addr.mac));
2356
2357 return err;
2358}
2359
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002360struct mv88e6xxx_port_db_dump_vlan_ctx {
2361 int port;
2362 dsa_fdb_dump_cb_t *cb;
2363 void *data;
2364};
2365
2366static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip,
2367 const struct mv88e6xxx_vtu_entry *entry,
2368 void *_data)
2369{
2370 struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data;
2371
2372 return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid,
2373 ctx->port, ctx->cb, ctx->data);
2374}
2375
Vivien Didelot83dabd12016-08-31 11:50:04 -04002376static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002377 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002378{
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002379 struct mv88e6xxx_port_db_dump_vlan_ctx ctx = {
2380 .port = port,
2381 .cb = cb,
2382 .data = data,
2383 };
Vivien Didelot83dabd12016-08-31 11:50:04 -04002384 u16 fid;
2385 int err;
2386
2387 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002388 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002389 if (err)
2390 return err;
2391
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002392 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002393 if (err)
2394 return err;
2395
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002396 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002397}
2398
Vivien Didelotf81ec902016-05-09 13:22:58 -04002399static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002400 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002401{
Vivien Didelot04bed142016-08-31 18:06:13 -04002402 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002403 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002404
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002405 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002406 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002407 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002408
2409 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002410}
2411
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002412static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2413 struct net_device *br)
2414{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002415 struct dsa_switch *ds = chip->ds;
2416 struct dsa_switch_tree *dst = ds->dst;
2417 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002418 int err;
2419
Vivien Didelotef2025e2019-10-21 16:51:27 -04002420 list_for_each_entry(dp, &dst->ports, list) {
2421 if (dp->bridge_dev == br) {
2422 if (dp->ds == ds) {
2423 /* This is a local bridge group member,
2424 * remap its Port VLAN Map.
2425 */
2426 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2427 if (err)
2428 return err;
2429 } else {
2430 /* This is an external bridge group member,
2431 * remap its cross-chip Port VLAN Table entry.
2432 */
2433 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2434 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002435 if (err)
2436 return err;
2437 }
2438 }
2439 }
2440
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002441 return 0;
2442}
2443
Vivien Didelotf81ec902016-05-09 13:22:58 -04002444static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002445 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002446{
Vivien Didelot04bed142016-08-31 18:06:13 -04002447 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002448 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002449
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002450 mv88e6xxx_reg_lock(chip);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002451
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002452 err = mv88e6xxx_bridge_map(chip, br);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002453 if (err)
2454 goto unlock;
2455
2456 err = mv88e6xxx_port_commit_pvid(chip, port);
2457 if (err)
2458 goto unlock;
2459
2460unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002461 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002462
Vivien Didelot466dfa02016-02-26 13:16:05 -05002463 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002464}
2465
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002466static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2467 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002468{
Vivien Didelot04bed142016-08-31 18:06:13 -04002469 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Oltean5bded822021-10-07 19:47:11 +03002470 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002471
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002472 mv88e6xxx_reg_lock(chip);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002473
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002474 if (mv88e6xxx_bridge_map(chip, br) ||
2475 mv88e6xxx_port_vlan_map(chip, port))
2476 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vladimir Oltean5bded822021-10-07 19:47:11 +03002477
2478 err = mv88e6xxx_port_commit_pvid(chip, port);
2479 if (err)
2480 dev_err(ds->dev,
2481 "port %d failed to restore standalone pvid: %pe\n",
2482 port, ERR_PTR(err));
2483
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002484 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002485}
2486
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002487static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2488 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002489 int port, struct net_device *br)
2490{
2491 struct mv88e6xxx_chip *chip = ds->priv;
2492 int err;
2493
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002494 if (tree_index != ds->dst->index)
2495 return 0;
2496
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002497 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002498 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002499 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002500
2501 return err;
2502}
2503
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002504static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2505 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002506 int port, struct net_device *br)
2507{
2508 struct mv88e6xxx_chip *chip = ds->priv;
2509
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002510 if (tree_index != ds->dst->index)
2511 return;
2512
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002513 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002514 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002515 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002516 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002517}
2518
Vladimir Olteance5df682021-07-22 18:55:41 +03002519/* Treat the software bridge as a virtual single-port switch behind the
2520 * CPU and map in the PVT. First dst->last_switch elements are taken by
2521 * physical switches, so start from beyond that range.
2522 */
2523static int mv88e6xxx_map_virtual_bridge_to_pvt(struct dsa_switch *ds,
Vladimir Oltean3f9bb032021-12-06 18:57:47 +02002524 unsigned int bridge_num)
Vladimir Olteance5df682021-07-22 18:55:41 +03002525{
Vladimir Oltean3f9bb032021-12-06 18:57:47 +02002526 u8 dev = bridge_num + ds->dst->last_switch;
Vladimir Olteance5df682021-07-22 18:55:41 +03002527 struct mv88e6xxx_chip *chip = ds->priv;
2528 int err;
2529
2530 mv88e6xxx_reg_lock(chip);
2531 err = mv88e6xxx_pvt_map(chip, dev, 0);
2532 mv88e6xxx_reg_unlock(chip);
2533
2534 return err;
2535}
2536
2537static int mv88e6xxx_bridge_tx_fwd_offload(struct dsa_switch *ds, int port,
2538 struct net_device *br,
Vladimir Oltean3f9bb032021-12-06 18:57:47 +02002539 unsigned int bridge_num)
Vladimir Olteance5df682021-07-22 18:55:41 +03002540{
2541 return mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num);
2542}
2543
2544static void mv88e6xxx_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port,
2545 struct net_device *br,
Vladimir Oltean3f9bb032021-12-06 18:57:47 +02002546 unsigned int bridge_num)
Vladimir Olteance5df682021-07-22 18:55:41 +03002547{
2548 int err;
2549
2550 err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num);
2551 if (err) {
2552 dev_err(ds->dev, "failed to remap cross-chip Port VLAN: %pe\n",
2553 ERR_PTR(err));
2554 }
2555}
2556
Vivien Didelot17e708b2016-12-05 17:30:27 -05002557static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2558{
2559 if (chip->info->ops->reset)
2560 return chip->info->ops->reset(chip);
2561
2562 return 0;
2563}
2564
Vivien Didelot309eca62016-12-05 17:30:26 -05002565static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2566{
2567 struct gpio_desc *gpiod = chip->reset;
2568
2569 /* If there is a GPIO connected to the reset pin, toggle it */
2570 if (gpiod) {
2571 gpiod_set_value_cansleep(gpiod, 1);
2572 usleep_range(10000, 20000);
2573 gpiod_set_value_cansleep(gpiod, 0);
2574 usleep_range(10000, 20000);
Andrew Lunna3dcb3e2020-11-16 08:43:01 -08002575
2576 mv88e6xxx_g1_wait_eeprom_done(chip);
Vivien Didelot309eca62016-12-05 17:30:26 -05002577 }
2578}
2579
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002580static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2581{
2582 int i, err;
2583
2584 /* Set all ports to the Disabled state */
2585 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002586 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002587 if (err)
2588 return err;
2589 }
2590
2591 /* Wait for transmit queues to drain,
2592 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2593 */
2594 usleep_range(2000, 4000);
2595
2596 return 0;
2597}
2598
Vivien Didelotfad09c72016-06-21 12:28:20 -04002599static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002600{
Vivien Didelota935c052016-09-29 12:21:53 -04002601 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002602
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002603 err = mv88e6xxx_disable_ports(chip);
2604 if (err)
2605 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002606
Vivien Didelot309eca62016-12-05 17:30:26 -05002607 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002608
Vivien Didelot17e708b2016-12-05 17:30:27 -05002609 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002610}
2611
Vivien Didelot43145572017-03-11 16:12:59 -05002612static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002613 enum mv88e6xxx_frame_mode frame,
2614 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002615{
2616 int err;
2617
Vivien Didelot43145572017-03-11 16:12:59 -05002618 if (!chip->info->ops->port_set_frame_mode)
2619 return -EOPNOTSUPP;
2620
2621 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002622 if (err)
2623 return err;
2624
Vivien Didelot43145572017-03-11 16:12:59 -05002625 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2626 if (err)
2627 return err;
2628
2629 if (chip->info->ops->port_set_ether_type)
2630 return chip->info->ops->port_set_ether_type(chip, port, etype);
2631
2632 return 0;
2633}
2634
2635static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2636{
2637 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002638 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002639 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002640}
2641
2642static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2643{
2644 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002645 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002646 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002647}
2648
2649static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2650{
2651 return mv88e6xxx_set_port_mode(chip, port,
2652 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002653 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2654 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002655}
2656
2657static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2658{
2659 if (dsa_is_dsa_port(chip->ds, port))
2660 return mv88e6xxx_set_port_mode_dsa(chip, port);
2661
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002662 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002663 return mv88e6xxx_set_port_mode_normal(chip, port);
2664
2665 /* Setup CPU port mode depending on its supported tag format */
Tobias Waldekranz670bb802021-04-20 20:53:07 +02002666 if (chip->tag_protocol == DSA_TAG_PROTO_DSA)
Vivien Didelot43145572017-03-11 16:12:59 -05002667 return mv88e6xxx_set_port_mode_dsa(chip, port);
2668
Tobias Waldekranz670bb802021-04-20 20:53:07 +02002669 if (chip->tag_protocol == DSA_TAG_PROTO_EDSA)
Vivien Didelot43145572017-03-11 16:12:59 -05002670 return mv88e6xxx_set_port_mode_edsa(chip, port);
2671
2672 return -EINVAL;
2673}
2674
Vivien Didelotea698f42017-03-11 16:12:50 -05002675static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2676{
2677 bool message = dsa_is_dsa_port(chip->ds, port);
2678
2679 return mv88e6xxx_port_set_message_port(chip, port, message);
2680}
2681
Vivien Didelot601aeed2017-03-11 16:13:00 -05002682static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2683{
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002684 int err;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002685
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002686 if (chip->info->ops->port_set_ucast_flood) {
Tobias Waldekranz7b9f16f2021-03-18 20:25:38 +01002687 err = chip->info->ops->port_set_ucast_flood(chip, port, true);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002688 if (err)
2689 return err;
2690 }
2691 if (chip->info->ops->port_set_mcast_flood) {
Tobias Waldekranz7b9f16f2021-03-18 20:25:38 +01002692 err = chip->info->ops->port_set_mcast_flood(chip, port, true);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002693 if (err)
2694 return err;
2695 }
Vivien Didelot601aeed2017-03-11 16:13:00 -05002696
David S. Miller407308f2019-06-15 13:35:29 -07002697 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002698}
2699
Vivien Didelot45de77f2019-08-31 16:18:36 -04002700static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2701{
2702 struct mv88e6xxx_port *mvp = dev_id;
2703 struct mv88e6xxx_chip *chip = mvp->chip;
2704 irqreturn_t ret = IRQ_NONE;
2705 int port = mvp->port;
Pavana Sharma193c5b22021-03-17 14:46:40 +01002706 int lane;
Vivien Didelot45de77f2019-08-31 16:18:36 -04002707
2708 mv88e6xxx_reg_lock(chip);
2709 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +01002710 if (lane >= 0)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002711 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2712 mv88e6xxx_reg_unlock(chip);
2713
2714 return ret;
2715}
2716
2717static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
Pavana Sharma193c5b22021-03-17 14:46:40 +01002718 int lane)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002719{
2720 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2721 unsigned int irq;
2722 int err;
2723
2724 /* Nothing to request if this SERDES port has no IRQ */
2725 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2726 if (!irq)
2727 return 0;
2728
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002729 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2730 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2731
Vivien Didelot45de77f2019-08-31 16:18:36 -04002732 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2733 mv88e6xxx_reg_unlock(chip);
2734 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002735 IRQF_ONESHOT, dev_id->serdes_irq_name,
2736 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002737 mv88e6xxx_reg_lock(chip);
2738 if (err)
2739 return err;
2740
2741 dev_id->serdes_irq = irq;
2742
2743 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2744}
2745
2746static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
Pavana Sharma193c5b22021-03-17 14:46:40 +01002747 int lane)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002748{
2749 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2750 unsigned int irq = dev_id->serdes_irq;
2751 int err;
2752
2753 /* Nothing to free if no IRQ has been requested */
2754 if (!irq)
2755 return 0;
2756
2757 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2758
2759 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2760 mv88e6xxx_reg_unlock(chip);
2761 free_irq(irq, dev_id);
2762 mv88e6xxx_reg_lock(chip);
2763
2764 dev_id->serdes_irq = 0;
2765
2766 return err;
2767}
2768
Andrew Lunn6d917822017-05-26 01:03:21 +02002769static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2770 bool on)
2771{
Pavana Sharma193c5b22021-03-17 14:46:40 +01002772 int lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002773 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002774
Vivien Didelotdc272f62019-08-31 16:18:33 -04002775 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +01002776 if (lane < 0)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002777 return 0;
2778
2779 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002780 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002781 if (err)
2782 return err;
2783
Vivien Didelot45de77f2019-08-31 16:18:36 -04002784 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002785 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002786 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2787 if (err)
2788 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002789
Vivien Didelotdc272f62019-08-31 16:18:33 -04002790 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002791 }
2792
2793 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002794}
2795
Marek Behún2fda45f2021-03-17 14:46:41 +01002796static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip,
2797 enum mv88e6xxx_egress_direction direction,
2798 int port)
2799{
2800 int err;
2801
2802 if (!chip->info->ops->set_egress_port)
2803 return -EOPNOTSUPP;
2804
2805 err = chip->info->ops->set_egress_port(chip, direction, port);
2806 if (err)
2807 return err;
2808
2809 if (direction == MV88E6XXX_EGRESS_DIR_INGRESS)
2810 chip->ingress_dest_port = port;
2811 else
2812 chip->egress_dest_port = port;
2813
2814 return 0;
2815}
2816
Vivien Didelotfa371c82017-12-05 15:34:10 -05002817static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2818{
2819 struct dsa_switch *ds = chip->ds;
2820 int upstream_port;
2821 int err;
2822
Vivien Didelot07073c72017-12-05 15:34:13 -05002823 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002824 if (chip->info->ops->port_set_upstream_port) {
2825 err = chip->info->ops->port_set_upstream_port(chip, port,
2826 upstream_port);
2827 if (err)
2828 return err;
2829 }
2830
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002831 if (port == upstream_port) {
2832 if (chip->info->ops->set_cpu_port) {
2833 err = chip->info->ops->set_cpu_port(chip,
2834 upstream_port);
2835 if (err)
2836 return err;
2837 }
2838
Marek Behún2fda45f2021-03-17 14:46:41 +01002839 err = mv88e6xxx_set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002840 MV88E6XXX_EGRESS_DIR_INGRESS,
2841 upstream_port);
Marek Behún2fda45f2021-03-17 14:46:41 +01002842 if (err && err != -EOPNOTSUPP)
2843 return err;
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002844
Marek Behún2fda45f2021-03-17 14:46:41 +01002845 err = mv88e6xxx_set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002846 MV88E6XXX_EGRESS_DIR_EGRESS,
2847 upstream_port);
Marek Behún2fda45f2021-03-17 14:46:41 +01002848 if (err && err != -EOPNOTSUPP)
2849 return err;
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002850 }
2851
Vivien Didelotfa371c82017-12-05 15:34:10 -05002852 return 0;
2853}
2854
Vivien Didelotfad09c72016-06-21 12:28:20 -04002855static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002856{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002857 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002858 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002859 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002860
Andrew Lunn7b898462018-08-09 15:38:47 +02002861 chip->ports[port].chip = chip;
2862 chip->ports[port].port = port;
2863
Vivien Didelotd78343d2016-11-04 03:23:36 +01002864 /* MAC Forcing register: don't force link, speed, duplex or flow control
2865 * state to any particular values on physical ports, but force the CPU
2866 * port and all DSA ports to their maximum bandwidth and full duplex.
2867 */
2868 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2869 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2870 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002871 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002872 PHY_INTERFACE_MODE_NA);
2873 else
2874 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2875 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002876 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002877 PHY_INTERFACE_MODE_NA);
2878 if (err)
2879 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002880
2881 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2882 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2883 * tunneling, determine priority by looking at 802.1p and IP
2884 * priority fields (IP prio has precedence), and set STP state
2885 * to Forwarding.
2886 *
2887 * If this is the CPU link, use DSA or EDSA tagging depending
2888 * on which tagging mode was configured.
2889 *
2890 * If this is a link to another switch, use DSA tagging mode.
2891 *
2892 * If this is the upstream port for this switch, enable
2893 * forwarding of unknown unicasts and multicasts.
2894 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002895 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2896 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2897 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2898 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002899 if (err)
2900 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002901
Vivien Didelot601aeed2017-03-11 16:13:00 -05002902 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002903 if (err)
2904 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002905
Vivien Didelot601aeed2017-03-11 16:13:00 -05002906 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002907 if (err)
2908 return err;
2909
Andrew Lunnb92ce2f2021-09-26 19:41:25 +02002910 /* Port Control 2: don't force a good FCS, set the MTU size to
2911 * 10222 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002912 * untagged frames on this port, do a destination address lookup on all
2913 * received packets as usual, disable ARP mirroring and don't send a
2914 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002915 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002916 err = mv88e6xxx_port_set_map_da(chip, port);
2917 if (err)
2918 return err;
2919
Vivien Didelotfa371c82017-12-05 15:34:10 -05002920 err = mv88e6xxx_setup_upstream_port(chip, port);
2921 if (err)
2922 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002923
Andrew Lunna23b2962017-02-04 20:15:28 +01002924 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002925 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002926 if (err)
2927 return err;
2928
Vladimir Oltean5bded822021-10-07 19:47:11 +03002929 /* Associate MV88E6XXX_VID_BRIDGED with MV88E6XXX_FID_BRIDGED in the
2930 * ATU by virtue of the fact that mv88e6xxx_atu_new() will pick it as
2931 * the first free FID after MV88E6XXX_FID_STANDALONE. This will be used
2932 * as the private PVID on ports under a VLAN-unaware bridge.
2933 * Shared (DSA and CPU) ports must also be members of it, to translate
2934 * the VID from the DSA tag into MV88E6XXX_FID_BRIDGED, instead of
2935 * relying on their port default FID.
2936 */
2937 err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_BRIDGED,
2938 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED,
2939 false);
2940 if (err)
2941 return err;
2942
Vivien Didelotcd782652017-06-08 18:34:13 -04002943 if (chip->info->ops->port_set_jumbo_size) {
Andrew Lunnb92ce2f2021-09-26 19:41:25 +02002944 err = chip->info->ops->port_set_jumbo_size(chip, port, 10218);
Andrew Lunn5f436662016-12-03 04:45:17 +01002945 if (err)
2946 return err;
2947 }
2948
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002949 /* Port Association Vector: disable automatic address learning
2950 * on all user ports since they start out in standalone
2951 * mode. When joining a bridge, learning will be configured to
2952 * match the bridge port settings. Enable learning on all
2953 * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the
2954 * learning process.
2955 *
2956 * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData,
2957 * and RefreshLocked. I.e. setup standard automatic learning.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002958 */
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002959 if (dsa_is_user_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002960 reg = 0;
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002961 else
2962 reg = 1 << port;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002963
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002964 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2965 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002966 if (err)
2967 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002968
2969 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002970 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2971 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002972 if (err)
2973 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002974
Vivien Didelot08984322017-06-08 18:34:12 -04002975 if (chip->info->ops->port_pause_limit) {
2976 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002977 if (err)
2978 return err;
2979 }
2980
Vivien Didelotc8c94892017-03-11 16:13:01 -05002981 if (chip->info->ops->port_disable_learn_limit) {
2982 err = chip->info->ops->port_disable_learn_limit(chip, port);
2983 if (err)
2984 return err;
2985 }
2986
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002987 if (chip->info->ops->port_disable_pri_override) {
2988 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002989 if (err)
2990 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002991 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002992
Andrew Lunnef0a7312016-12-03 04:35:16 +01002993 if (chip->info->ops->port_tag_remap) {
2994 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002995 if (err)
2996 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002997 }
2998
Andrew Lunnef70b112016-12-03 04:45:18 +01002999 if (chip->info->ops->port_egress_rate_limiting) {
3000 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003001 if (err)
3002 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003003 }
3004
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003005 if (chip->info->ops->port_setup_message_port) {
3006 err = chip->info->ops->port_setup_message_port(chip, port);
3007 if (err)
3008 return err;
3009 }
Guenter Roeckd827e882015-03-26 18:36:29 -07003010
Vivien Didelot207afda2016-04-14 14:42:09 -04003011 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05003012 * database, and allow bidirectional communication between the
3013 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07003014 */
Vladimir Oltean5bded822021-10-07 19:47:11 +03003015 err = mv88e6xxx_port_set_fid(chip, port, MV88E6XXX_FID_STANDALONE);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003016 if (err)
3017 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05003018
Vivien Didelot240ea3e2017-03-30 17:37:12 -04003019 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003020 if (err)
3021 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07003022
3023 /* Default VLAN ID and priority: don't set a default VLAN
3024 * ID, and set the default packet priority to zero.
3025 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04003026 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02003027}
3028
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003029static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
3030{
3031 struct mv88e6xxx_chip *chip = ds->priv;
3032
3033 if (chip->info->ops->port_set_jumbo_size)
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003034 return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
Chris Packham1baf0fa2020-07-24 11:21:22 +12003035 else if (chip->info->ops->set_max_frame_size)
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003036 return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
3037 return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003038}
3039
3040static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
3041{
3042 struct mv88e6xxx_chip *chip = ds->priv;
3043 int ret = 0;
3044
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003045 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
3046 new_mtu += EDSA_HLEN;
3047
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003048 mv88e6xxx_reg_lock(chip);
3049 if (chip->info->ops->port_set_jumbo_size)
3050 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Chris Packham1baf0fa2020-07-24 11:21:22 +12003051 else if (chip->info->ops->set_max_frame_size)
3052 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003053 else
3054 if (new_mtu > 1522)
3055 ret = -EINVAL;
3056 mv88e6xxx_reg_unlock(chip);
3057
3058 return ret;
3059}
3060
Andrew Lunn04aca992017-05-26 01:03:24 +02003061static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
3062 struct phy_device *phydev)
3063{
3064 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04003065 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02003066
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003067 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04003068 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003069 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02003070
3071 return err;
3072}
3073
Andrew Lunn75104db2019-02-24 20:44:43 +01003074static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02003075{
3076 struct mv88e6xxx_chip *chip = ds->priv;
3077
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003078 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04003079 if (mv88e6xxx_serdes_power(chip, port, false))
3080 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003081 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02003082}
3083
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003084static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
3085 unsigned int ageing_time)
3086{
Vivien Didelot04bed142016-08-31 18:06:13 -04003087 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003088 int err;
3089
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003090 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05003091 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003092 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003093
3094 return err;
3095}
3096
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003097static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04003098{
3099 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04003100
Andrew Lunnde2273872016-11-21 23:27:01 +01003101 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003102 if (chip->info->ops->stats_set_histogram) {
3103 err = chip->info->ops->stats_set_histogram(chip);
3104 if (err)
3105 return err;
3106 }
Andrew Lunnde2273872016-11-21 23:27:01 +01003107
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003108 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04003109}
3110
Andrew Lunnea890982019-01-09 00:24:03 +01003111/* Check if the errata has already been applied. */
3112static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
3113{
3114 int port;
3115 int err;
3116 u16 val;
3117
3118 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02003119 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01003120 if (err) {
3121 dev_err(chip->dev,
3122 "Error reading hidden register: %d\n", err);
3123 return false;
3124 }
3125 if (val != 0x01c0)
3126 return false;
3127 }
3128
3129 return true;
3130}
3131
3132/* The 6390 copper ports have an errata which require poking magic
3133 * values into undocumented hidden registers and then performing a
3134 * software reset.
3135 */
3136static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
3137{
3138 int port;
3139 int err;
3140
3141 if (mv88e6390_setup_errata_applied(chip))
3142 return 0;
3143
3144 /* Set the ports into blocking mode */
3145 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
3146 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
3147 if (err)
3148 return err;
3149 }
3150
3151 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02003152 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01003153 if (err)
3154 return err;
3155 }
3156
3157 return mv88e6xxx_software_reset(chip);
3158}
3159
Andrew Lunn23e8b472019-10-25 01:03:52 +02003160static void mv88e6xxx_teardown(struct dsa_switch *ds)
3161{
3162 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003163 dsa_devlink_resources_unregister(ds);
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003164 mv88e6xxx_teardown_devlink_regions_global(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02003165}
3166
Vivien Didelotf81ec902016-05-09 13:22:58 -04003167static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07003168{
Vivien Didelot04bed142016-08-31 18:06:13 -04003169 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003170 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04003171 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04003172 int i;
3173
Vivien Didelotfad09c72016-06-21 12:28:20 -04003174 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003175 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003176
Vladimir Olteance5df682021-07-22 18:55:41 +03003177 /* Since virtual bridges are mapped in the PVT, the number we support
3178 * depends on the physical switch topology. We need to let DSA figure
3179 * that out and therefore we cannot set this at dsa_register_switch()
3180 * time.
3181 */
3182 if (mv88e6xxx_has_pvt(chip))
Vladimir Oltean947c8742021-12-06 18:57:48 +02003183 ds->max_num_bridges = MV88E6XXX_MAX_PVT_SWITCHES -
3184 ds->dst->last_switch - 1;
Vladimir Olteance5df682021-07-22 18:55:41 +03003185
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003186 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003187
Andrew Lunnea890982019-01-09 00:24:03 +01003188 if (chip->info->ops->setup_errata) {
3189 err = chip->info->ops->setup_errata(chip);
3190 if (err)
3191 goto unlock;
3192 }
3193
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003194 /* Cache the cmode of each port. */
3195 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3196 if (chip->info->ops->port_get_cmode) {
3197 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3198 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003199 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003200
3201 chip->ports[i].cmode = cmode;
3202 }
3203 }
3204
Vladimir Oltean5bded822021-10-07 19:47:11 +03003205 err = mv88e6xxx_vtu_setup(chip);
3206 if (err)
3207 goto unlock;
3208
Vivien Didelot97299342016-07-18 20:45:30 -04003209 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003210 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003211 if (dsa_is_unused_port(ds, i))
3212 continue;
3213
Hubert Feursteinc8574862019-07-31 10:23:48 +02003214 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003215 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003216 dev_err(chip->dev, "port %d is invalid\n", i);
3217 err = -EINVAL;
3218 goto unlock;
3219 }
3220
Vivien Didelot97299342016-07-18 20:45:30 -04003221 err = mv88e6xxx_setup_port(chip, i);
3222 if (err)
3223 goto unlock;
3224 }
3225
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003226 err = mv88e6xxx_irl_setup(chip);
3227 if (err)
3228 goto unlock;
3229
Vivien Didelot04a69a12017-10-13 14:18:05 -04003230 err = mv88e6xxx_mac_setup(chip);
3231 if (err)
3232 goto unlock;
3233
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003234 err = mv88e6xxx_phy_setup(chip);
3235 if (err)
3236 goto unlock;
3237
Vivien Didelot81228992017-03-30 17:37:08 -04003238 err = mv88e6xxx_pvt_setup(chip);
3239 if (err)
3240 goto unlock;
3241
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003242 err = mv88e6xxx_atu_setup(chip);
3243 if (err)
3244 goto unlock;
3245
Andrew Lunn87fa8862017-11-09 22:29:56 +01003246 err = mv88e6xxx_broadcast_setup(chip, 0);
3247 if (err)
3248 goto unlock;
3249
Vivien Didelot9e907d72017-07-17 13:03:43 -04003250 err = mv88e6xxx_pot_setup(chip);
3251 if (err)
3252 goto unlock;
3253
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003254 err = mv88e6xxx_rmu_setup(chip);
3255 if (err)
3256 goto unlock;
3257
Vivien Didelot51c901a2017-07-17 13:03:41 -04003258 err = mv88e6xxx_rsvd2cpu_setup(chip);
3259 if (err)
3260 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003261
Vivien Didelotb28f8722018-04-26 21:56:44 -04003262 err = mv88e6xxx_trunk_setup(chip);
3263 if (err)
3264 goto unlock;
3265
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003266 err = mv88e6xxx_devmap_setup(chip);
3267 if (err)
3268 goto unlock;
3269
Vivien Didelot93e18d62018-05-11 17:16:35 -04003270 err = mv88e6xxx_pri_setup(chip);
3271 if (err)
3272 goto unlock;
3273
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003274 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003275 if (chip->info->ptp_support) {
3276 err = mv88e6xxx_ptp_setup(chip);
3277 if (err)
3278 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003279
3280 err = mv88e6xxx_hwtstamp_setup(chip);
3281 if (err)
3282 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003283 }
3284
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003285 err = mv88e6xxx_stats_setup(chip);
3286 if (err)
3287 goto unlock;
3288
Vivien Didelot6b17e862015-08-13 12:52:18 -04003289unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003290 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003291
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003292 if (err)
3293 return err;
3294
3295 /* Have to be called without holding the register lock, since
3296 * they take the devlink lock, and we later take the locks in
3297 * the reverse order when getting/setting parameters or
3298 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003299 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003300 err = mv88e6xxx_setup_devlink_resources(ds);
3301 if (err)
3302 return err;
3303
3304 err = mv88e6xxx_setup_devlink_params(ds);
3305 if (err)
Andrew Lunnbfb25542020-09-18 21:11:07 +02003306 goto out_resources;
3307
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003308 err = mv88e6xxx_setup_devlink_regions_global(ds);
Andrew Lunnbfb25542020-09-18 21:11:07 +02003309 if (err)
3310 goto out_params;
3311
3312 return 0;
3313
3314out_params:
3315 mv88e6xxx_teardown_devlink_params(ds);
3316out_resources:
3317 dsa_devlink_resources_unregister(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003318
3319 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003320}
3321
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003322static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port)
3323{
3324 return mv88e6xxx_setup_devlink_regions_port(ds, port);
3325}
3326
3327static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port)
3328{
3329 mv88e6xxx_teardown_devlink_regions_port(ds, port);
3330}
3331
Pali Rohár1fe976d2021-04-12 18:57:39 +02003332/* prod_id for switch families which do not have a PHY model number */
3333static const u16 family_prod_id_table[] = {
3334 [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
3335 [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Marek Behúnc5d015b2021-04-20 09:54:02 +02003336 [MV88E6XXX_FAMILY_6393] = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
Pali Rohár1fe976d2021-04-12 18:57:39 +02003337};
3338
Vivien Didelote57e5e72016-08-15 17:19:00 -04003339static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003340{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003341 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3342 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Pali Rohár1fe976d2021-04-12 18:57:39 +02003343 u16 prod_id;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003344 u16 val;
3345 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003346
Andrew Lunnee26a222017-01-24 14:53:48 +01003347 if (!chip->info->ops->phy_read)
3348 return -EOPNOTSUPP;
3349
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003350 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003351 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003352 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003353
Pali Rohár1fe976d2021-04-12 18:57:39 +02003354 /* Some internal PHYs don't have a model number. */
3355 if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
3356 chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
3357 prod_id = family_prod_id_table[chip->info->family];
3358 if (prod_id)
3359 val |= prod_id >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003360 }
3361
Vivien Didelote57e5e72016-08-15 17:19:00 -04003362 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003363}
3364
Vivien Didelote57e5e72016-08-15 17:19:00 -04003365static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003366{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003367 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3368 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003369 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003370
Andrew Lunnee26a222017-01-24 14:53:48 +01003371 if (!chip->info->ops->phy_write)
3372 return -EOPNOTSUPP;
3373
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003374 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003375 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003376 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003377
3378 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003379}
3380
Vivien Didelotfad09c72016-06-21 12:28:20 -04003381static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003382 struct device_node *np,
3383 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003384{
3385 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003386 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003387 struct mii_bus *bus;
3388 int err;
3389
Andrew Lunn2510bab2018-02-22 01:51:49 +01003390 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003391 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003392 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003393 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003394
3395 if (err)
3396 return err;
3397 }
3398
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003399 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003400 if (!bus)
3401 return -ENOMEM;
3402
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003403 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003404 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003405 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003406 INIT_LIST_HEAD(&mdio_bus->list);
3407 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003408
Andrew Lunnb516d452016-06-04 21:17:06 +02003409 if (np) {
3410 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003411 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003412 } else {
3413 bus->name = "mv88e6xxx SMI";
3414 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3415 }
3416
3417 bus->read = mv88e6xxx_mdio_read;
3418 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003419 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003420
Andrew Lunn6f882842018-03-17 20:32:05 +01003421 if (!external) {
3422 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3423 if (err)
3424 return err;
3425 }
3426
Florian Fainelli00e798c2018-05-15 16:56:19 -07003427 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003428 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003429 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003430 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003431 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003432 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003433
3434 if (external)
3435 list_add_tail(&mdio_bus->list, &chip->mdios);
3436 else
3437 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003438
3439 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003440}
3441
Andrew Lunn3126aee2017-12-07 01:05:57 +01003442static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3443
3444{
3445 struct mv88e6xxx_mdio_bus *mdio_bus;
3446 struct mii_bus *bus;
3447
3448 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3449 bus = mdio_bus->bus;
3450
Andrew Lunn6f882842018-03-17 20:32:05 +01003451 if (!mdio_bus->external)
3452 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3453
Andrew Lunn3126aee2017-12-07 01:05:57 +01003454 mdiobus_unregister(bus);
3455 }
3456}
3457
Andrew Lunna3c53be52017-01-24 14:53:50 +01003458static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3459 struct device_node *np)
3460{
Andrew Lunna3c53be52017-01-24 14:53:50 +01003461 struct device_node *child;
3462 int err;
3463
3464 /* Always register one mdio bus for the internal/default mdio
3465 * bus. This maybe represented in the device tree, but is
3466 * optional.
3467 */
3468 child = of_get_child_by_name(np, "mdio");
3469 err = mv88e6xxx_mdio_register(chip, child, false);
3470 if (err)
3471 return err;
3472
3473 /* Walk the device tree, and see if there are any other nodes
3474 * which say they are compatible with the external mdio
3475 * bus.
3476 */
3477 for_each_available_child_of_node(np, child) {
Andrew Lunnceb96fa2020-09-01 04:32:57 +02003478 if (of_device_is_compatible(
3479 child, "marvell,mv88e6xxx-mdio-external")) {
Andrew Lunna3c53be52017-01-24 14:53:50 +01003480 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003481 if (err) {
3482 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303483 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003484 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003485 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003486 }
3487 }
3488
3489 return 0;
3490}
3491
Vivien Didelot855b1932016-07-20 18:18:35 -04003492static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3493{
Vivien Didelot04bed142016-08-31 18:06:13 -04003494 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003495
3496 return chip->eeprom_len;
3497}
3498
Vivien Didelot855b1932016-07-20 18:18:35 -04003499static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3500 struct ethtool_eeprom *eeprom, u8 *data)
3501{
Vivien Didelot04bed142016-08-31 18:06:13 -04003502 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003503 int err;
3504
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003505 if (!chip->info->ops->get_eeprom)
3506 return -EOPNOTSUPP;
3507
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003508 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003509 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003510 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003511
3512 if (err)
3513 return err;
3514
3515 eeprom->magic = 0xc3ec4951;
3516
3517 return 0;
3518}
3519
Vivien Didelot855b1932016-07-20 18:18:35 -04003520static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3521 struct ethtool_eeprom *eeprom, u8 *data)
3522{
Vivien Didelot04bed142016-08-31 18:06:13 -04003523 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003524 int err;
3525
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003526 if (!chip->info->ops->set_eeprom)
3527 return -EOPNOTSUPP;
3528
Vivien Didelot855b1932016-07-20 18:18:35 -04003529 if (eeprom->magic != 0xc3ec4951)
3530 return -EINVAL;
3531
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003532 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003533 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003534 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003535
3536 return err;
3537}
3538
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003539static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003540 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003541 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3542 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003543 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003544 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003545 .phy_read = mv88e6185_phy_ppu_read,
3546 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003547 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003548 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003549 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003550 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003551 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003552 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3553 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003554 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003555 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003556 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003557 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003558 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003559 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003560 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003561 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003562 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003563 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3564 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003565 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003566 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3567 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003568 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003569 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003570 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003571 .ppu_enable = mv88e6185_g1_ppu_enable,
3572 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003573 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003574 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003575 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003576 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003577 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003578 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003579};
3580
3581static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003582 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003583 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3584 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003585 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003586 .phy_read = mv88e6185_phy_ppu_read,
3587 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003588 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003589 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003590 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003591 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003592 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3593 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunna23b2962017-02-04 20:15:28 +01003594 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003595 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003596 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003597 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003598 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003599 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3600 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003601 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003602 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003603 .serdes_power = mv88e6185_serdes_power,
3604 .serdes_get_lane = mv88e6185_serdes_get_lane,
3605 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003606 .ppu_enable = mv88e6185_g1_ppu_enable,
3607 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003608 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003609 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003610 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003611 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003612 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003613};
3614
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003615static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003616 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003617 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3618 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003619 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003620 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3621 .phy_read = mv88e6xxx_g2_smi_phy_read,
3622 .phy_write = mv88e6xxx_g2_smi_phy_write,
3623 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003624 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003625 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003626 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003627 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003628 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3629 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003630 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003631 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003632 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003633 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003634 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003635 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003636 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003637 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003638 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003639 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3640 .stats_get_strings = mv88e6095_stats_get_strings,
3641 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003642 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3643 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003644 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003645 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003646 .serdes_power = mv88e6185_serdes_power,
3647 .serdes_get_lane = mv88e6185_serdes_get_lane,
3648 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Chris Packham5c19bc82020-11-24 17:34:39 +13003649 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
3650 .serdes_irq_enable = mv88e6097_serdes_irq_enable,
3651 .serdes_irq_status = mv88e6097_serdes_irq_status,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003652 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003653 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003654 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003655 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003656 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003657 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003658 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003659};
3660
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003661static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003662 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003663 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3664 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003665 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003666 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003667 .phy_read = mv88e6xxx_g2_smi_phy_read,
3668 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003669 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003670 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003671 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003672 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003673 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3674 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003675 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003676 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003677 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003678 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003679 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003680 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003681 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3682 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003683 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003684 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3685 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003686 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003687 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003688 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003689 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003690 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3691 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003692 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003693 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003694 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003695 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003696};
3697
3698static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003699 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003700 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3701 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003702 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003703 .phy_read = mv88e6185_phy_ppu_read,
3704 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003705 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003706 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003707 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003708 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003709 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003710 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3711 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003712 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003713 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003714 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003715 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003716 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003717 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003718 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003719 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003720 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003721 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003722 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3723 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003724 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003725 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3726 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003727 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003728 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003729 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003730 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003731 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003732 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003733 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003734 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003735 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003736};
3737
Vivien Didelot990e27b2017-03-28 13:50:32 -04003738static const struct mv88e6xxx_ops mv88e6141_ops = {
3739 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003740 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3741 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003742 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003743 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3744 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3745 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3746 .phy_read = mv88e6xxx_g2_smi_phy_read,
3747 .phy_write = mv88e6xxx_g2_smi_phy_write,
3748 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003749 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003750 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003751 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003752 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003753 .port_tag_remap = mv88e6095_port_tag_remap,
Marek Behún7da467d2021-07-01 00:22:26 +02003754 .port_set_policy = mv88e6352_port_set_policy,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003755 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003756 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3757 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003758 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003759 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003760 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003761 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003762 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3763 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003764 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003765 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003766 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003767 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Marek Behún11527f32021-07-01 00:22:27 +02003768 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003769 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3770 .stats_get_strings = mv88e6320_stats_get_strings,
3771 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003772 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3773 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003774 .watchdog_ops = &mv88e6390_watchdog_ops,
3775 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003776 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003777 .reset = mv88e6352_g1_reset,
Marek Behún37094882021-07-01 00:22:28 +02003778 .rmu_disable = mv88e6390_g1_rmu_disable,
Marek Behúnc07fff32021-07-01 00:22:29 +02003779 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3780 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003781 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003782 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003783 .serdes_power = mv88e6390_serdes_power,
3784 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003785 /* Check status register pause & lpa register */
3786 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3787 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3788 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3789 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003790 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003791 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003792 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003793 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúna03b98d2021-07-01 00:22:30 +02003794 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
3795 .serdes_get_strings = mv88e6390_serdes_get_strings,
3796 .serdes_get_stats = mv88e6390_serdes_get_stats,
Marek Behún953b0dc2021-07-01 00:22:31 +02003797 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3798 .serdes_get_regs = mv88e6390_serdes_get_regs,
Marek Behúne3af71a2019-02-25 12:39:55 +01003799 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003800};
3801
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003802static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003803 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003804 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3805 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003806 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003807 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003808 .phy_read = mv88e6xxx_g2_smi_phy_read,
3809 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003810 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003811 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003812 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003813 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003814 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003815 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3816 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003817 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003818 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003819 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003820 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003821 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003822 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003823 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003824 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003825 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003826 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3827 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003828 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003829 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3830 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003831 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003832 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003833 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003834 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003835 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3836 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003837 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003838 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003839 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003840 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003841 .phylink_validate = mv88e6185_phylink_validate,
Andrew Lunnfe230362021-09-26 19:41:24 +02003842 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003843};
3844
3845static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003846 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003847 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3848 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003849 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003850 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003851 .phy_read = mv88e6165_phy_read,
3852 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003853 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003854 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003855 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003856 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003857 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003858 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003859 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003860 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003861 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003862 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3863 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003864 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003865 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3866 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003867 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003868 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003869 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003870 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003871 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3872 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003873 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003874 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003875 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003876 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003877 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003878};
3879
3880static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003881 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003882 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3883 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003884 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003885 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003886 .phy_read = mv88e6xxx_g2_smi_phy_read,
3887 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003888 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003889 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003890 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003891 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003892 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003893 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003894 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3895 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003896 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003897 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003898 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003899 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003900 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003901 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003902 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003903 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003904 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003905 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003906 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3907 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003908 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003909 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3910 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003911 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003912 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003913 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003914 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003915 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3916 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003917 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003918 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003919 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003920};
3921
3922static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003923 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003924 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3925 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003926 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003927 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3928 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003929 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003930 .phy_read = mv88e6xxx_g2_smi_phy_read,
3931 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003932 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003933 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003934 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003935 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003936 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003937 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003938 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003939 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3940 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003941 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003942 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003943 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003944 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003945 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003946 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003947 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003948 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003949 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003950 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003951 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3952 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003953 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003954 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3955 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003956 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003957 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003958 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003959 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003960 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003961 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3962 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003963 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003964 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003965 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003966 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3967 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3968 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3969 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003970 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003971 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3972 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003973 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003974 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003975};
3976
3977static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003978 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003979 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3980 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003981 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003982 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003983 .phy_read = mv88e6xxx_g2_smi_phy_read,
3984 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003985 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003986 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003987 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003988 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003989 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003990 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003991 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3992 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003993 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003994 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003995 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003996 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003997 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003998 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003999 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004000 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004001 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004002 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004003 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4004 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004005 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004006 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4007 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004008 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004009 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004010 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004011 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004012 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4013 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004014 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004015 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004016 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004017};
4018
4019static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004020 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004021 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4022 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004023 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004024 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4025 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004026 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004027 .phy_read = mv88e6xxx_g2_smi_phy_read,
4028 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004029 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004030 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004031 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004032 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004033 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004034 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004035 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004036 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4037 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004038 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004039 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004040 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004041 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004042 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004043 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004044 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004045 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004046 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004047 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004048 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4049 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004050 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004051 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4052 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004053 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004054 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004055 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004056 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004057 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004058 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4059 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004060 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004061 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004062 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004063 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4064 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4065 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4066 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004067 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004068 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004069 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004070 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004071 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4072 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004073 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004074 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004075};
4076
4077static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004078 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004079 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4080 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004081 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04004082 .phy_read = mv88e6185_phy_ppu_read,
4083 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004084 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004085 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004086 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004087 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004088 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
4089 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunnef70b112016-12-03 04:45:18 +01004090 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01004091 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02004092 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004093 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004094 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004095 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004096 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004097 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4098 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004099 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004100 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4101 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004102 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004103 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13004104 .serdes_power = mv88e6185_serdes_power,
4105 .serdes_get_lane = mv88e6185_serdes_get_lane,
4106 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelot02317e62018-05-09 11:38:49 -04004107 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05004108 .ppu_enable = mv88e6185_g1_ppu_enable,
4109 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004110 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004111 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004112 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004113 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12004114 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004115};
4116
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004117static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004118 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004119 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004120 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004121 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4122 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004123 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4124 .phy_read = mv88e6xxx_g2_smi_phy_read,
4125 .phy_write = mv88e6xxx_g2_smi_phy_write,
4126 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004127 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004128 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004129 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004130 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004131 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004132 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004133 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004134 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4135 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004136 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12004137 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04004138 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004139 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004140 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004141 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004142 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004143 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004144 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004145 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004146 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4147 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004148 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004149 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4150 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004151 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004152 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004153 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004154 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004155 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004156 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4157 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004158 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4159 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004160 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004161 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004162 /* Check status register pause & lpa register */
4163 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4164 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4165 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4166 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004167 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004168 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004169 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004170 .serdes_get_strings = mv88e6390_serdes_get_strings,
4171 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004172 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4173 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004174 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004175 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004176};
4177
4178static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004179 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004180 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004181 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004182 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4183 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004184 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4185 .phy_read = mv88e6xxx_g2_smi_phy_read,
4186 .phy_write = mv88e6xxx_g2_smi_phy_write,
4187 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004188 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004189 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004190 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004191 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004192 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004193 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004194 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004195 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4196 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004197 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12004198 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04004199 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004200 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004201 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004202 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004203 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004204 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004205 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004206 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004207 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4208 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004209 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004210 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4211 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004212 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004213 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004214 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004215 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004216 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004217 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4218 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004219 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4220 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004221 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004222 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004223 /* Check status register pause & lpa register */
4224 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4225 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4226 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4227 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004228 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004229 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004230 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004231 .serdes_get_strings = mv88e6390_serdes_get_strings,
4232 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004233 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4234 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004235 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004236 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004237};
4238
4239static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004240 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004241 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004242 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004243 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4244 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004245 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4246 .phy_read = mv88e6xxx_g2_smi_phy_read,
4247 .phy_write = mv88e6xxx_g2_smi_phy_write,
4248 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004249 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004250 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004251 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004252 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004253 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004254 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004255 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4256 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004257 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004258 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004259 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004260 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004261 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004262 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004263 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004264 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004265 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004266 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4267 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004268 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004269 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4270 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004271 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004272 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004273 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004274 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004275 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004276 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4277 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004278 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4279 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004280 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004281 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004282 /* Check status register pause & lpa register */
4283 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4284 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4285 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4286 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004287 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004288 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004289 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004290 .serdes_get_strings = mv88e6390_serdes_get_strings,
4291 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004292 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4293 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004294 .avb_ops = &mv88e6390_avb_ops,
4295 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004296 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004297};
4298
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004299static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004300 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004301 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4302 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004303 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004304 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4305 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004306 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004307 .phy_read = mv88e6xxx_g2_smi_phy_read,
4308 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004309 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004310 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004311 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004312 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004313 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004314 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004315 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004316 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4317 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004318 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004319 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004320 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004321 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004322 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004323 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004324 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004325 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004326 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004327 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004328 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4329 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004330 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004331 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4332 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004333 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004334 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004335 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004336 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004337 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004338 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4339 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004340 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004341 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004342 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004343 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4344 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4345 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4346 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004347 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004348 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004349 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004350 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004351 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4352 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004353 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004354 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004355 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004356 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004357};
4358
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004359static const struct mv88e6xxx_ops mv88e6250_ops = {
4360 /* MV88E6XXX_FAMILY_6250 */
4361 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4362 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4363 .irl_init_all = mv88e6352_g2_irl_init_all,
4364 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4365 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4366 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4367 .phy_read = mv88e6xxx_g2_smi_phy_read,
4368 .phy_write = mv88e6xxx_g2_smi_phy_write,
4369 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004370 .port_sync_link = mv88e6xxx_port_sync_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004371 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004372 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004373 .port_tag_remap = mv88e6095_port_tag_remap,
4374 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004375 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4376 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004377 .port_set_ether_type = mv88e6351_port_set_ether_type,
4378 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4379 .port_pause_limit = mv88e6097_port_pause_limit,
4380 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004381 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4382 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4383 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4384 .stats_get_strings = mv88e6250_stats_get_strings,
4385 .stats_get_stats = mv88e6250_stats_get_stats,
4386 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4387 .set_egress_port = mv88e6095_g1_set_egress_port,
4388 .watchdog_ops = &mv88e6250_watchdog_ops,
4389 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4390 .pot_clear = mv88e6xxx_g2_pot_clear,
4391 .reset = mv88e6250_g1_reset,
Rasmus Villemoes67c9ed12021-01-25 16:04:48 +01004392 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Rasmus Villemoesb28f3f32021-01-25 16:04:49 +01004393 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004394 .avb_ops = &mv88e6352_avb_ops,
4395 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004396 .phylink_validate = mv88e6065_phylink_validate,
4397};
4398
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004399static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004400 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004401 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004402 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004403 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4404 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004405 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4406 .phy_read = mv88e6xxx_g2_smi_phy_read,
4407 .phy_write = mv88e6xxx_g2_smi_phy_write,
4408 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004409 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004410 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004411 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004412 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004413 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004414 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004415 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004416 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4417 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004418 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004419 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004420 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004421 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004422 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004423 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004424 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004425 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004426 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004427 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4428 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004429 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004430 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4431 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004432 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004433 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004434 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004435 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004436 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004437 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4438 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004439 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4440 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004441 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004442 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004443 /* Check status register pause & lpa register */
4444 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4445 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4446 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4447 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004448 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004449 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004450 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004451 .serdes_get_strings = mv88e6390_serdes_get_strings,
4452 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004453 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4454 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004455 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004456 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004457 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004458 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004459};
4460
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004461static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004462 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004463 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4464 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004465 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004466 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4467 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004468 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004469 .phy_read = mv88e6xxx_g2_smi_phy_read,
4470 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004471 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004472 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004473 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004474 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004475 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004476 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4477 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004478 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004479 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004480 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004481 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004482 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004483 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004484 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004485 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004486 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004487 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004488 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4489 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004490 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004491 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4492 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004493 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004494 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004495 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004496 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004497 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004498 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004499 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004500 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004501 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004502 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004503};
4504
4505static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004506 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004507 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4508 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004509 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004510 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4511 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004512 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004513 .phy_read = mv88e6xxx_g2_smi_phy_read,
4514 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004515 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004516 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004517 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004518 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004519 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004520 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4521 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004522 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004523 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004524 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004525 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004526 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004527 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004528 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004529 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004530 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004531 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004532 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4533 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004534 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004535 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4536 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004537 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004538 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004539 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004540 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004541 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004542 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004543 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004544 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004545};
4546
Vivien Didelot16e329a2017-03-28 13:50:33 -04004547static const struct mv88e6xxx_ops mv88e6341_ops = {
4548 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004549 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4550 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004551 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004552 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4553 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4554 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4555 .phy_read = mv88e6xxx_g2_smi_phy_read,
4556 .phy_write = mv88e6xxx_g2_smi_phy_write,
4557 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004558 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004559 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004560 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004561 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004562 .port_tag_remap = mv88e6095_port_tag_remap,
Marek Behún7da467d2021-07-01 00:22:26 +02004563 .port_set_policy = mv88e6352_port_set_policy,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004564 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004565 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4566 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004567 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004568 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004569 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004570 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004571 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4572 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004573 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004574 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004575 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004576 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Marek Behún11527f32021-07-01 00:22:27 +02004577 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004578 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4579 .stats_get_strings = mv88e6320_stats_get_strings,
4580 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004581 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4582 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004583 .watchdog_ops = &mv88e6390_watchdog_ops,
4584 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004585 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004586 .reset = mv88e6352_g1_reset,
Marek Behún37094882021-07-01 00:22:28 +02004587 .rmu_disable = mv88e6390_g1_rmu_disable,
Marek Behúnc07fff32021-07-01 00:22:29 +02004588 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4589 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004590 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004591 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004592 .serdes_power = mv88e6390_serdes_power,
4593 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004594 /* Check status register pause & lpa register */
4595 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4596 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4597 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4598 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004599 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004600 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004601 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004602 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004603 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004604 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúna03b98d2021-07-01 00:22:30 +02004605 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4606 .serdes_get_strings = mv88e6390_serdes_get_strings,
4607 .serdes_get_stats = mv88e6390_serdes_get_stats,
Marek Behún953b0dc2021-07-01 00:22:31 +02004608 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4609 .serdes_get_regs = mv88e6390_serdes_get_regs,
Marek Behúne3af71a2019-02-25 12:39:55 +01004610 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004611};
4612
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004613static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004614 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004615 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4616 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004617 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004618 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004619 .phy_read = mv88e6xxx_g2_smi_phy_read,
4620 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004621 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004622 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004623 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004624 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004625 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004626 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004627 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4628 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004629 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004630 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004631 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004632 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004633 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004634 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004635 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004636 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004637 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004638 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004639 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4640 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004641 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004642 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4643 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004644 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004645 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004646 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004647 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004648 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4649 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004650 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004651 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004652 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004653};
4654
4655static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004656 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004657 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4658 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004659 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004660 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004661 .phy_read = mv88e6xxx_g2_smi_phy_read,
4662 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004663 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004664 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004665 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004666 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004667 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004668 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004669 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4670 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004671 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004672 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004673 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004674 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004675 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004676 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004677 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004678 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004679 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004680 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004681 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4682 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004683 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004684 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4685 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004686 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004687 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004688 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004689 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004690 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4691 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004692 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004693 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004694 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004695 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004696 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004697};
4698
4699static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004700 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004701 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4702 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004703 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004704 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4705 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004706 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004707 .phy_read = mv88e6xxx_g2_smi_phy_read,
4708 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004709 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004710 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004711 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004712 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004713 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004714 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004715 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004716 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4717 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004718 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004719 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004720 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004721 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004722 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004723 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004724 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004725 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004726 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004727 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004728 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4729 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004730 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004731 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4732 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004733 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004734 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004735 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004736 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004737 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004738 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4739 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004740 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004741 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004742 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004743 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4744 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4745 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4746 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004747 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004748 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004749 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004750 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004751 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004752 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004753 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004754 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4755 .serdes_get_strings = mv88e6352_serdes_get_strings,
4756 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004757 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4758 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004759 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004760};
4761
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004762static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004763 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004764 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004765 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004766 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4767 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004768 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4769 .phy_read = mv88e6xxx_g2_smi_phy_read,
4770 .phy_write = mv88e6xxx_g2_smi_phy_write,
4771 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004772 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004773 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004774 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004775 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004776 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004777 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004778 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004779 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4780 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004781 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004782 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004783 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004784 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004785 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004786 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004787 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004788 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004789 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004790 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004791 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004792 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4793 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004794 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004795 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4796 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004797 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004798 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004799 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004800 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004801 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004802 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4803 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004804 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4805 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004806 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004807 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004808 /* Check status register pause & lpa register */
4809 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4810 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4811 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4812 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004813 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004814 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004815 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004816 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004817 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004818 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004819 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4820 .serdes_get_strings = mv88e6390_serdes_get_strings,
4821 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004822 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4823 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004824 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004825};
4826
4827static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004828 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004829 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004830 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004831 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4832 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004833 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4834 .phy_read = mv88e6xxx_g2_smi_phy_read,
4835 .phy_write = mv88e6xxx_g2_smi_phy_write,
4836 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004837 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004838 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004839 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004840 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004841 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004842 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004843 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004844 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4845 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004846 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004847 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004848 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004849 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004850 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004851 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004852 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004853 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004854 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004855 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004856 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004857 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4858 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004859 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004860 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4861 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004862 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004863 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004864 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004865 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004866 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004867 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4868 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004869 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4870 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004871 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004872 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004873 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4874 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4875 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4876 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004877 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004878 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004879 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004880 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4881 .serdes_get_strings = mv88e6390_serdes_get_strings,
4882 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004883 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4884 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004885 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004886 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004887 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004888 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004889};
4890
Pavana Sharmade776d02021-03-17 14:46:42 +01004891static const struct mv88e6xxx_ops mv88e6393x_ops = {
4892 /* MV88E6XXX_FAMILY_6393 */
4893 .setup_errata = mv88e6393x_serdes_setup_errata,
4894 .irl_init_all = mv88e6390_g2_irl_init_all,
4895 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4896 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4897 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4898 .phy_read = mv88e6xxx_g2_smi_phy_read,
4899 .phy_write = mv88e6xxx_g2_smi_phy_write,
4900 .port_set_link = mv88e6xxx_port_set_link,
4901 .port_sync_link = mv88e6xxx_port_sync_link,
4902 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4903 .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex,
4904 .port_max_speed_mode = mv88e6393x_port_max_speed_mode,
4905 .port_tag_remap = mv88e6390_port_tag_remap,
Marek Behún6584b262021-03-17 14:46:43 +01004906 .port_set_policy = mv88e6393x_port_set_policy,
Pavana Sharmade776d02021-03-17 14:46:42 +01004907 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4908 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4909 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4910 .port_set_ether_type = mv88e6393x_port_set_ether_type,
4911 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4912 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4913 .port_pause_limit = mv88e6390_port_pause_limit,
4914 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4915 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4916 .port_get_cmode = mv88e6352_port_get_cmode,
4917 .port_set_cmode = mv88e6393x_port_set_cmode,
4918 .port_setup_message_port = mv88e6xxx_setup_message_port,
4919 .port_set_upstream_port = mv88e6393x_port_set_upstream_port,
4920 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4921 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4922 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4923 .stats_get_strings = mv88e6320_stats_get_strings,
4924 .stats_get_stats = mv88e6390_stats_get_stats,
4925 /* .set_cpu_port is missing because this family does not support a global
4926 * CPU port, only per port CPU port which is set via
4927 * .port_set_upstream_port method.
4928 */
4929 .set_egress_port = mv88e6393x_set_egress_port,
4930 .watchdog_ops = &mv88e6390_watchdog_ops,
4931 .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu,
4932 .pot_clear = mv88e6xxx_g2_pot_clear,
4933 .reset = mv88e6352_g1_reset,
4934 .rmu_disable = mv88e6390_g1_rmu_disable,
4935 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4936 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4937 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4938 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
4939 .serdes_power = mv88e6393x_serdes_power,
4940 .serdes_get_lane = mv88e6393x_serdes_get_lane,
4941 .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state,
4942 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4943 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4944 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
4945 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4946 .serdes_irq_enable = mv88e6393x_serdes_irq_enable,
4947 .serdes_irq_status = mv88e6393x_serdes_irq_status,
4948 /* TODO: serdes stats */
4949 .gpio_ops = &mv88e6352_gpio_ops,
4950 .avb_ops = &mv88e6390_avb_ops,
4951 .ptp_ops = &mv88e6352_ptp_ops,
4952 .phylink_validate = mv88e6393x_phylink_validate,
4953};
4954
Vivien Didelotf81ec902016-05-09 13:22:58 -04004955static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4956 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004957 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004958 .family = MV88E6XXX_FAMILY_6097,
4959 .name = "Marvell 88E6085",
4960 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004961 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004962 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004963 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004964 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004965 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004966 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004967 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004968 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004969 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004970 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004971 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004972 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004973 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004974 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004975 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004976 },
4977
4978 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004979 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004980 .family = MV88E6XXX_FAMILY_6095,
4981 .name = "Marvell 88E6095/88E6095F",
4982 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004983 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004984 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004985 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004986 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004987 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004988 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004989 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004990 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004991 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004992 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004993 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004994 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004995 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004996 },
4997
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004998 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004999 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005000 .family = MV88E6XXX_FAMILY_6097,
5001 .name = "Marvell 88E6097/88E6097F",
5002 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005003 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005004 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01005005 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005006 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005007 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005008 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005009 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005010 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005011 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01005012 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005013 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005014 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005015 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005016 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005017 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005018 .ops = &mv88e6097_ops,
5019 },
5020
Vivien Didelotf81ec902016-05-09 13:22:58 -04005021 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005022 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005023 .family = MV88E6XXX_FAMILY_6165,
5024 .name = "Marvell 88E6123",
5025 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005026 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005027 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01005028 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005029 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005030 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005031 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005032 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005033 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005034 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005035 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005036 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005037 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005038 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005039 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005040 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005041 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005042 },
5043
5044 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005045 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005046 .family = MV88E6XXX_FAMILY_6185,
5047 .name = "Marvell 88E6131",
5048 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005049 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005050 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005051 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005052 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005053 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005054 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005055 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005056 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005057 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005058 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05005059 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005060 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005061 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005062 },
5063
Vivien Didelot990e27b2017-03-28 13:50:32 -04005064 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005065 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005066 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01005067 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04005068 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005069 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005070 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005071 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005072 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005073 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005074 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005075 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005076 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005077 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005078 .age_time_coeff = 3750,
5079 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005080 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005081 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005082 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005083 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005084 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005085 .ops = &mv88e6141_ops,
5086 },
5087
Vivien Didelotf81ec902016-05-09 13:22:58 -04005088 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005089 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005090 .family = MV88E6XXX_FAMILY_6165,
5091 .name = "Marvell 88E6161",
5092 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005093 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005094 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005095 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005096 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005097 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005098 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005099 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005100 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005101 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005102 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005103 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005104 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005105 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005106 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005107 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Andrew Lunndfa54342018-07-18 22:38:22 +02005108 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005109 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005110 },
5111
5112 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005113 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005114 .family = MV88E6XXX_FAMILY_6165,
5115 .name = "Marvell 88E6165",
5116 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005117 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005118 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005119 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005120 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005121 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005122 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005123 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005124 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005125 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005126 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005127 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005128 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005129 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005130 .multi_chip = true,
Andrew Lunndfa54342018-07-18 22:38:22 +02005131 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005132 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005133 },
5134
5135 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005136 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005137 .family = MV88E6XXX_FAMILY_6351,
5138 .name = "Marvell 88E6171",
5139 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005140 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005141 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005142 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005143 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005144 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005145 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005146 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005147 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005148 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005149 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005150 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005151 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005152 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005153 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005154 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005155 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005156 },
5157
5158 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005159 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005160 .family = MV88E6XXX_FAMILY_6352,
5161 .name = "Marvell 88E6172",
5162 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005163 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005164 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005165 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005166 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005167 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005168 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005169 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005170 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005171 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005172 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005173 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005174 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005175 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005176 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005177 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005178 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005179 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005180 },
5181
5182 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005183 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005184 .family = MV88E6XXX_FAMILY_6351,
5185 .name = "Marvell 88E6175",
5186 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005187 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005188 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005189 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005190 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005191 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005192 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005193 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005194 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005195 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005196 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005197 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005198 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005199 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005200 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005201 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005202 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005203 },
5204
5205 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005206 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005207 .family = MV88E6XXX_FAMILY_6352,
5208 .name = "Marvell 88E6176",
5209 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005210 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005211 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005212 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005213 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005214 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005215 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005216 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005217 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005218 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005219 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005220 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005221 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005222 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005223 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005224 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005225 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005226 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005227 },
5228
5229 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005230 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005231 .family = MV88E6XXX_FAMILY_6185,
5232 .name = "Marvell 88E6185",
5233 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005234 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005235 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01005236 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005237 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005238 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005239 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005240 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005241 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005242 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005243 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05005244 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005245 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005246 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005247 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005248 },
5249
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005250 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005251 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005252 .family = MV88E6XXX_FAMILY_6390,
5253 .name = "Marvell 88E6190",
5254 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005255 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005256 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005257 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005258 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005259 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005260 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005261 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005262 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005263 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005264 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005265 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005266 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04005267 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005268 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05005269 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005270 .ops = &mv88e6190_ops,
5271 },
5272
5273 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005274 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005275 .family = MV88E6XXX_FAMILY_6390,
5276 .name = "Marvell 88E6190X",
5277 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005278 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005279 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005280 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005281 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005282 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005283 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005284 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005285 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005286 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005287 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005288 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005289 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005290 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005291 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005292 .multi_chip = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005293 .ops = &mv88e6190x_ops,
5294 },
5295
5296 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005297 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005298 .family = MV88E6XXX_FAMILY_6390,
5299 .name = "Marvell 88E6191",
5300 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005301 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005302 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005303 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005304 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005305 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005306 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005307 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005308 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005309 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005310 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005311 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005312 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005313 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005314 .multi_chip = true,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005315 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005316 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005317 },
5318
Pavana Sharmade776d02021-03-17 14:46:42 +01005319 [MV88E6191X] = {
5320 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X,
5321 .family = MV88E6XXX_FAMILY_6393,
5322 .name = "Marvell 88E6191X",
5323 .num_databases = 4096,
5324 .num_ports = 11, /* 10 + Z80 */
5325 .num_internal_phys = 9,
5326 .max_vid = 8191,
5327 .port_base_addr = 0x0,
5328 .phy_base_addr = 0x0,
5329 .global1_addr = 0x1b,
5330 .global2_addr = 0x1c,
5331 .age_time_coeff = 3750,
5332 .g1_irqs = 10,
5333 .g2_irqs = 14,
5334 .atu_move_port_mask = 0x1f,
5335 .pvt = true,
5336 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005337 .ptp_support = true,
5338 .ops = &mv88e6393x_ops,
5339 },
5340
5341 [MV88E6193X] = {
5342 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X,
5343 .family = MV88E6XXX_FAMILY_6393,
5344 .name = "Marvell 88E6193X",
5345 .num_databases = 4096,
5346 .num_ports = 11, /* 10 + Z80 */
5347 .num_internal_phys = 9,
5348 .max_vid = 8191,
5349 .port_base_addr = 0x0,
5350 .phy_base_addr = 0x0,
5351 .global1_addr = 0x1b,
5352 .global2_addr = 0x1c,
5353 .age_time_coeff = 3750,
5354 .g1_irqs = 10,
5355 .g2_irqs = 14,
5356 .atu_move_port_mask = 0x1f,
5357 .pvt = true,
5358 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005359 .ptp_support = true,
5360 .ops = &mv88e6393x_ops,
5361 },
5362
Hubert Feurstein49022642019-07-31 10:23:46 +02005363 [MV88E6220] = {
5364 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5365 .family = MV88E6XXX_FAMILY_6250,
5366 .name = "Marvell 88E6220",
5367 .num_databases = 64,
5368
5369 /* Ports 2-4 are not routed to pins
5370 * => usable ports 0, 1, 5, 6
5371 */
5372 .num_ports = 7,
5373 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005374 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005375 .max_vid = 4095,
5376 .port_base_addr = 0x08,
5377 .phy_base_addr = 0x00,
5378 .global1_addr = 0x0f,
5379 .global2_addr = 0x07,
5380 .age_time_coeff = 15000,
5381 .g1_irqs = 9,
5382 .g2_irqs = 10,
5383 .atu_move_port_mask = 0xf,
5384 .dual_chip = true,
Hubert Feurstein71509612019-07-31 10:23:51 +02005385 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005386 .ops = &mv88e6250_ops,
5387 },
5388
Vivien Didelotf81ec902016-05-09 13:22:58 -04005389 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005390 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005391 .family = MV88E6XXX_FAMILY_6352,
5392 .name = "Marvell 88E6240",
5393 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005394 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005395 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005396 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005397 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005398 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005399 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005400 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005401 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005402 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005403 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005404 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005405 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005406 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005407 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005408 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005409 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005410 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005411 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005412 },
5413
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005414 [MV88E6250] = {
5415 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5416 .family = MV88E6XXX_FAMILY_6250,
5417 .name = "Marvell 88E6250",
5418 .num_databases = 64,
5419 .num_ports = 7,
5420 .num_internal_phys = 5,
5421 .max_vid = 4095,
5422 .port_base_addr = 0x08,
5423 .phy_base_addr = 0x00,
5424 .global1_addr = 0x0f,
5425 .global2_addr = 0x07,
5426 .age_time_coeff = 15000,
5427 .g1_irqs = 9,
5428 .g2_irqs = 10,
5429 .atu_move_port_mask = 0xf,
5430 .dual_chip = true,
Hubert Feurstein71509612019-07-31 10:23:51 +02005431 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005432 .ops = &mv88e6250_ops,
5433 },
5434
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005435 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005436 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005437 .family = MV88E6XXX_FAMILY_6390,
5438 .name = "Marvell 88E6290",
5439 .num_databases = 4096,
5440 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005441 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005442 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005443 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005444 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005445 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005446 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005447 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005448 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005449 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005450 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005451 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005452 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005453 .multi_chip = true,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005454 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005455 .ops = &mv88e6290_ops,
5456 },
5457
Vivien Didelotf81ec902016-05-09 13:22:58 -04005458 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005459 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005460 .family = MV88E6XXX_FAMILY_6320,
5461 .name = "Marvell 88E6320",
5462 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005463 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005464 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005465 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005466 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005467 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005468 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005469 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005470 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005471 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005472 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005473 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005474 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005475 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005476 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005477 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005478 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005479 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005480 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005481 },
5482
5483 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005484 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005485 .family = MV88E6XXX_FAMILY_6320,
5486 .name = "Marvell 88E6321",
5487 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005488 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005489 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005490 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005491 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005492 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005493 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005494 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005495 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005496 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005497 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005498 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005499 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005500 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005501 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005502 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005503 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005504 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005505 },
5506
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005507 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005508 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005509 .family = MV88E6XXX_FAMILY_6341,
5510 .name = "Marvell 88E6341",
5511 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005512 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005513 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005514 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005515 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005516 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005517 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005518 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005519 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005520 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005521 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005522 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005523 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005524 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005525 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005526 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005527 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005528 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005529 .ops = &mv88e6341_ops,
5530 },
5531
Vivien Didelotf81ec902016-05-09 13:22:58 -04005532 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005533 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005534 .family = MV88E6XXX_FAMILY_6351,
5535 .name = "Marvell 88E6350",
5536 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005537 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005538 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005539 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005540 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005541 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005542 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005543 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005544 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005545 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005546 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005547 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005548 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005549 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005550 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005551 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005552 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005553 },
5554
5555 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005556 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005557 .family = MV88E6XXX_FAMILY_6351,
5558 .name = "Marvell 88E6351",
5559 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005560 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005561 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005562 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005563 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005564 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005565 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005566 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005567 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005568 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005569 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005570 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005571 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005572 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005573 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005574 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005575 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005576 },
5577
5578 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005579 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005580 .family = MV88E6XXX_FAMILY_6352,
5581 .name = "Marvell 88E6352",
5582 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005583 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005584 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005585 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005586 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005587 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005588 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005589 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005590 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005591 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005592 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005593 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005594 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005595 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005596 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005597 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005598 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005599 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005600 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005601 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005602 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005603 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005604 .family = MV88E6XXX_FAMILY_6390,
5605 .name = "Marvell 88E6390",
5606 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005607 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005608 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005609 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005610 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005611 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005612 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005613 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005614 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005615 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005616 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005617 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005618 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005619 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005620 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005621 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005622 .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005623 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005624 .ops = &mv88e6390_ops,
5625 },
5626 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005627 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005628 .family = MV88E6XXX_FAMILY_6390,
5629 .name = "Marvell 88E6390X",
5630 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005631 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005632 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005633 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005634 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005635 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005636 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005637 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005638 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005639 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005640 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005641 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005642 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005643 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005644 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005645 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005646 .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005647 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005648 .ops = &mv88e6390x_ops,
5649 },
Pavana Sharmade776d02021-03-17 14:46:42 +01005650
5651 [MV88E6393X] = {
5652 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
5653 .family = MV88E6XXX_FAMILY_6393,
5654 .name = "Marvell 88E6393X",
5655 .num_databases = 4096,
5656 .num_ports = 11, /* 10 + Z80 */
5657 .num_internal_phys = 9,
5658 .max_vid = 8191,
5659 .port_base_addr = 0x0,
5660 .phy_base_addr = 0x0,
5661 .global1_addr = 0x1b,
5662 .global2_addr = 0x1c,
5663 .age_time_coeff = 3750,
5664 .g1_irqs = 10,
5665 .g2_irqs = 14,
5666 .atu_move_port_mask = 0x1f,
5667 .pvt = true,
5668 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005669 .ptp_support = true,
5670 .ops = &mv88e6393x_ops,
5671 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005672};
5673
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005674static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005675{
Vivien Didelota439c062016-04-17 13:23:58 -04005676 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005677
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005678 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5679 if (mv88e6xxx_table[i].prod_num == prod_num)
5680 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005681
Vivien Didelotb9b37712015-10-30 19:39:48 -04005682 return NULL;
5683}
5684
Vivien Didelotfad09c72016-06-21 12:28:20 -04005685static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005686{
5687 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005688 unsigned int prod_num, rev;
5689 u16 id;
5690 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005691
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005692 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005693 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005694 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005695 if (err)
5696 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005697
Vivien Didelot107fcc12017-06-12 12:37:36 -04005698 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5699 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005700
5701 info = mv88e6xxx_lookup_info(prod_num);
5702 if (!info)
5703 return -ENODEV;
5704
Vivien Didelotcaac8542016-06-20 13:14:09 -04005705 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005706 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005707
Vivien Didelotfad09c72016-06-21 12:28:20 -04005708 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5709 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005710
5711 return 0;
5712}
5713
Vivien Didelotfad09c72016-06-21 12:28:20 -04005714static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005715{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005716 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005717
Vivien Didelotfad09c72016-06-21 12:28:20 -04005718 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5719 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005720 return NULL;
5721
Vivien Didelotfad09c72016-06-21 12:28:20 -04005722 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005723
Vivien Didelotfad09c72016-06-21 12:28:20 -04005724 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005725 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005726 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005727
Vivien Didelotfad09c72016-06-21 12:28:20 -04005728 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005729}
5730
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005731static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005732 int port,
5733 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005734{
Vivien Didelot04bed142016-08-31 18:06:13 -04005735 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005736
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005737 return chip->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005738}
5739
Tobias Waldekranz9a99bef2021-04-20 20:53:08 +02005740static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds, int port,
5741 enum dsa_tag_protocol proto)
5742{
5743 struct mv88e6xxx_chip *chip = ds->priv;
5744 enum dsa_tag_protocol old_protocol;
5745 int err;
5746
5747 switch (proto) {
5748 case DSA_TAG_PROTO_EDSA:
5749 switch (chip->info->edsa_support) {
5750 case MV88E6XXX_EDSA_UNSUPPORTED:
5751 return -EPROTONOSUPPORT;
5752 case MV88E6XXX_EDSA_UNDOCUMENTED:
5753 dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n");
5754 fallthrough;
5755 case MV88E6XXX_EDSA_SUPPORTED:
5756 break;
5757 }
5758 break;
5759 case DSA_TAG_PROTO_DSA:
5760 break;
5761 default:
5762 return -EPROTONOSUPPORT;
5763 }
5764
5765 old_protocol = chip->tag_protocol;
5766 chip->tag_protocol = proto;
5767
5768 mv88e6xxx_reg_lock(chip);
5769 err = mv88e6xxx_setup_port_mode(chip, port);
5770 mv88e6xxx_reg_unlock(chip);
5771
5772 if (err)
5773 chip->tag_protocol = old_protocol;
5774
5775 return err;
5776}
5777
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005778static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
5779 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005780{
Vivien Didelot04bed142016-08-31 18:06:13 -04005781 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005782 int err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005783
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005784 mv88e6xxx_reg_lock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005785 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
5786 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005787 mv88e6xxx_reg_unlock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005788
5789 return err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005790}
5791
5792static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5793 const struct switchdev_obj_port_mdb *mdb)
5794{
Vivien Didelot04bed142016-08-31 18:06:13 -04005795 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005796 int err;
5797
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005798 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005799 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005800 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005801
5802 return err;
5803}
5804
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005805static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5806 struct dsa_mall_mirror_tc_entry *mirror,
5807 bool ingress)
5808{
5809 enum mv88e6xxx_egress_direction direction = ingress ?
5810 MV88E6XXX_EGRESS_DIR_INGRESS :
5811 MV88E6XXX_EGRESS_DIR_EGRESS;
5812 struct mv88e6xxx_chip *chip = ds->priv;
5813 bool other_mirrors = false;
5814 int i;
5815 int err;
5816
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005817 mutex_lock(&chip->reg_lock);
5818 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5819 mirror->to_local_port) {
5820 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5821 other_mirrors |= ingress ?
5822 chip->ports[i].mirror_ingress :
5823 chip->ports[i].mirror_egress;
5824
5825 /* Can't change egress port when other mirror is active */
5826 if (other_mirrors) {
5827 err = -EBUSY;
5828 goto out;
5829 }
5830
Marek Behún2fda45f2021-03-17 14:46:41 +01005831 err = mv88e6xxx_set_egress_port(chip, direction,
5832 mirror->to_local_port);
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005833 if (err)
5834 goto out;
5835 }
5836
5837 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5838out:
5839 mutex_unlock(&chip->reg_lock);
5840
5841 return err;
5842}
5843
5844static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5845 struct dsa_mall_mirror_tc_entry *mirror)
5846{
5847 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5848 MV88E6XXX_EGRESS_DIR_INGRESS :
5849 MV88E6XXX_EGRESS_DIR_EGRESS;
5850 struct mv88e6xxx_chip *chip = ds->priv;
5851 bool other_mirrors = false;
5852 int i;
5853
5854 mutex_lock(&chip->reg_lock);
5855 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5856 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5857
5858 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5859 other_mirrors |= mirror->ingress ?
5860 chip->ports[i].mirror_ingress :
5861 chip->ports[i].mirror_egress;
5862
5863 /* Reset egress port when no other mirror is active */
5864 if (!other_mirrors) {
Marek Behún2fda45f2021-03-17 14:46:41 +01005865 if (mv88e6xxx_set_egress_port(chip, direction,
5866 dsa_upstream_port(ds, port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005867 dev_err(ds->dev, "failed to set egress port\n");
5868 }
5869
5870 mutex_unlock(&chip->reg_lock);
5871}
5872
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005873static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port,
5874 struct switchdev_brport_flags flags,
5875 struct netlink_ext_ack *extack)
5876{
5877 struct mv88e6xxx_chip *chip = ds->priv;
5878 const struct mv88e6xxx_ops *ops;
5879
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01005880 if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD |
5881 BR_BCAST_FLOOD))
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005882 return -EINVAL;
5883
5884 ops = chip->info->ops;
5885
5886 if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood)
5887 return -EINVAL;
5888
5889 if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood)
5890 return -EINVAL;
5891
5892 return 0;
5893}
5894
5895static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port,
5896 struct switchdev_brport_flags flags,
5897 struct netlink_ext_ack *extack)
Russell King4f859012019-02-20 15:35:05 -08005898{
5899 struct mv88e6xxx_chip *chip = ds->priv;
5900 int err = -EOPNOTSUPP;
5901
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005902 mv88e6xxx_reg_lock(chip);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005903
Tobias Waldekranz041bd542021-03-18 20:25:39 +01005904 if (flags.mask & BR_LEARNING) {
5905 bool learning = !!(flags.val & BR_LEARNING);
5906 u16 pav = learning ? (1 << port) : 0;
5907
5908 err = mv88e6xxx_port_set_assoc_vector(chip, port, pav);
5909 if (err)
5910 goto out;
Tobias Waldekranz041bd542021-03-18 20:25:39 +01005911 }
5912
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005913 if (flags.mask & BR_FLOOD) {
5914 bool unicast = !!(flags.val & BR_FLOOD);
5915
5916 err = chip->info->ops->port_set_ucast_flood(chip, port,
5917 unicast);
5918 if (err)
5919 goto out;
5920 }
5921
5922 if (flags.mask & BR_MCAST_FLOOD) {
5923 bool multicast = !!(flags.val & BR_MCAST_FLOOD);
5924
5925 err = chip->info->ops->port_set_mcast_flood(chip, port,
5926 multicast);
5927 if (err)
5928 goto out;
5929 }
5930
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01005931 if (flags.mask & BR_BCAST_FLOOD) {
5932 bool broadcast = !!(flags.val & BR_BCAST_FLOOD);
5933
5934 err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast);
5935 if (err)
5936 goto out;
5937 }
5938
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005939out:
5940 mv88e6xxx_reg_unlock(chip);
5941
5942 return err;
5943}
5944
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005945static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds,
5946 struct net_device *lag,
5947 struct netdev_lag_upper_info *info)
5948{
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01005949 struct mv88e6xxx_chip *chip = ds->priv;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005950 struct dsa_port *dp;
5951 int id, members = 0;
5952
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01005953 if (!mv88e6xxx_has_lag(chip))
5954 return false;
5955
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005956 id = dsa_lag_id(ds->dst, lag);
5957 if (id < 0 || id >= ds->num_lag_ids)
5958 return false;
5959
5960 dsa_lag_foreach_port(dp, ds->dst, lag)
5961 /* Includes the port joining the LAG */
5962 members++;
5963
5964 if (members > 8)
5965 return false;
5966
5967 /* We could potentially relax this to include active
5968 * backup in the future.
5969 */
5970 if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH)
5971 return false;
5972
5973 /* Ideally we would also validate that the hash type matches
5974 * the hardware. Alas, this is always set to unknown on team
5975 * interfaces.
5976 */
5977 return true;
5978}
5979
5980static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct net_device *lag)
5981{
5982 struct mv88e6xxx_chip *chip = ds->priv;
5983 struct dsa_port *dp;
5984 u16 map = 0;
5985 int id;
5986
5987 id = dsa_lag_id(ds->dst, lag);
5988
5989 /* Build the map of all ports to distribute flows destined for
5990 * this LAG. This can be either a local user port, or a DSA
5991 * port if the LAG port is on a remote chip.
5992 */
5993 dsa_lag_foreach_port(dp, ds->dst, lag)
5994 map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index));
5995
5996 return mv88e6xxx_g2_trunk_mapping_write(chip, id, map);
5997}
5998
5999static const u8 mv88e6xxx_lag_mask_table[8][8] = {
6000 /* Row number corresponds to the number of active members in a
6001 * LAG. Each column states which of the eight hash buckets are
6002 * mapped to the column:th port in the LAG.
6003 *
6004 * Example: In a LAG with three active ports, the second port
6005 * ([2][1]) would be selected for traffic mapped to buckets
6006 * 3,4,5 (0x38).
6007 */
6008 { 0xff, 0, 0, 0, 0, 0, 0, 0 },
6009 { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 },
6010 { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 },
6011 { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 },
6012 { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 },
6013 { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 },
6014 { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 },
6015 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 },
6016};
6017
6018static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port,
6019 int num_tx, int nth)
6020{
6021 u8 active = 0;
6022 int i;
6023
6024 num_tx = num_tx <= 8 ? num_tx : 8;
6025 if (nth < num_tx)
6026 active = mv88e6xxx_lag_mask_table[num_tx - 1][nth];
6027
6028 for (i = 0; i < 8; i++) {
6029 if (BIT(i) & active)
6030 mask[i] |= BIT(port);
6031 }
6032}
6033
6034static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds)
6035{
6036 struct mv88e6xxx_chip *chip = ds->priv;
6037 unsigned int id, num_tx;
6038 struct net_device *lag;
6039 struct dsa_port *dp;
6040 int i, err, nth;
6041 u16 mask[8];
6042 u16 ivec;
6043
6044 /* Assume no port is a member of any LAG. */
6045 ivec = BIT(mv88e6xxx_num_ports(chip)) - 1;
6046
6047 /* Disable all masks for ports that _are_ members of a LAG. */
6048 list_for_each_entry(dp, &ds->dst->ports, list) {
6049 if (!dp->lag_dev || dp->ds != ds)
6050 continue;
6051
6052 ivec &= ~BIT(dp->index);
6053 }
6054
6055 for (i = 0; i < 8; i++)
6056 mask[i] = ivec;
6057
6058 /* Enable the correct subset of masks for all LAG ports that
6059 * are in the Tx set.
6060 */
6061 dsa_lags_foreach_id(id, ds->dst) {
6062 lag = dsa_lag_dev(ds->dst, id);
6063 if (!lag)
6064 continue;
6065
6066 num_tx = 0;
6067 dsa_lag_foreach_port(dp, ds->dst, lag) {
6068 if (dp->lag_tx_enabled)
6069 num_tx++;
6070 }
6071
6072 if (!num_tx)
6073 continue;
6074
6075 nth = 0;
6076 dsa_lag_foreach_port(dp, ds->dst, lag) {
6077 if (!dp->lag_tx_enabled)
6078 continue;
6079
6080 if (dp->ds == ds)
6081 mv88e6xxx_lag_set_port_mask(mask, dp->index,
6082 num_tx, nth);
6083
6084 nth++;
6085 }
6086 }
6087
6088 for (i = 0; i < 8; i++) {
6089 err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]);
6090 if (err)
6091 return err;
6092 }
6093
6094 return 0;
6095}
6096
6097static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds,
6098 struct net_device *lag)
6099{
6100 int err;
6101
6102 err = mv88e6xxx_lag_sync_masks(ds);
6103
6104 if (!err)
6105 err = mv88e6xxx_lag_sync_map(ds, lag);
6106
6107 return err;
6108}
6109
6110static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port)
6111{
6112 struct mv88e6xxx_chip *chip = ds->priv;
6113 int err;
6114
6115 mv88e6xxx_reg_lock(chip);
6116 err = mv88e6xxx_lag_sync_masks(ds);
6117 mv88e6xxx_reg_unlock(chip);
6118 return err;
6119}
6120
6121static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port,
6122 struct net_device *lag,
6123 struct netdev_lag_upper_info *info)
6124{
6125 struct mv88e6xxx_chip *chip = ds->priv;
6126 int err, id;
6127
6128 if (!mv88e6xxx_lag_can_offload(ds, lag, info))
6129 return -EOPNOTSUPP;
6130
6131 id = dsa_lag_id(ds->dst, lag);
6132
6133 mv88e6xxx_reg_lock(chip);
6134
6135 err = mv88e6xxx_port_set_trunk(chip, port, true, id);
6136 if (err)
6137 goto err_unlock;
6138
6139 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
6140 if (err)
6141 goto err_clear_trunk;
6142
6143 mv88e6xxx_reg_unlock(chip);
6144 return 0;
6145
6146err_clear_trunk:
6147 mv88e6xxx_port_set_trunk(chip, port, false, 0);
6148err_unlock:
6149 mv88e6xxx_reg_unlock(chip);
6150 return err;
6151}
6152
6153static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port,
6154 struct net_device *lag)
6155{
6156 struct mv88e6xxx_chip *chip = ds->priv;
6157 int err_sync, err_trunk;
6158
6159 mv88e6xxx_reg_lock(chip);
6160 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
6161 err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0);
6162 mv88e6xxx_reg_unlock(chip);
6163 return err_sync ? : err_trunk;
6164}
6165
6166static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index,
6167 int port)
6168{
6169 struct mv88e6xxx_chip *chip = ds->priv;
6170 int err;
6171
6172 mv88e6xxx_reg_lock(chip);
6173 err = mv88e6xxx_lag_sync_masks(ds);
6174 mv88e6xxx_reg_unlock(chip);
6175 return err;
6176}
6177
6178static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index,
6179 int port, struct net_device *lag,
6180 struct netdev_lag_upper_info *info)
6181{
6182 struct mv88e6xxx_chip *chip = ds->priv;
6183 int err;
6184
6185 if (!mv88e6xxx_lag_can_offload(ds, lag, info))
6186 return -EOPNOTSUPP;
6187
6188 mv88e6xxx_reg_lock(chip);
6189
6190 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
6191 if (err)
6192 goto unlock;
6193
6194 err = mv88e6xxx_pvt_map(chip, sw_index, port);
6195
6196unlock:
6197 mv88e6xxx_reg_unlock(chip);
6198 return err;
6199}
6200
6201static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index,
6202 int port, struct net_device *lag)
6203{
6204 struct mv88e6xxx_chip *chip = ds->priv;
6205 int err_sync, err_pvt;
6206
6207 mv88e6xxx_reg_lock(chip);
6208 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
6209 err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port);
6210 mv88e6xxx_reg_unlock(chip);
6211 return err_sync ? : err_pvt;
6212}
6213
Florian Fainellia82f67a2017-01-08 14:52:08 -08006214static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02006215 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Tobias Waldekranz9a99bef2021-04-20 20:53:08 +02006216 .change_tag_protocol = mv88e6xxx_change_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006217 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02006218 .teardown = mv88e6xxx_teardown,
Vladimir Olteanfd292c12021-09-17 17:29:16 +03006219 .port_setup = mv88e6xxx_port_setup,
6220 .port_teardown = mv88e6xxx_port_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07006221 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00006222 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07006223 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00006224 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07006225 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
6226 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006227 .get_strings = mv88e6xxx_get_strings,
6228 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
6229 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02006230 .port_enable = mv88e6xxx_port_enable,
6231 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02006232 .port_max_mtu = mv88e6xxx_get_max_mtu,
6233 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04006234 .get_mac_eee = mv88e6xxx_get_mac_eee,
6235 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006236 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006237 .get_eeprom = mv88e6xxx_get_eeprom,
6238 .set_eeprom = mv88e6xxx_set_eeprom,
6239 .get_regs_len = mv88e6xxx_get_regs_len,
6240 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04006241 .get_rxnfc = mv88e6xxx_get_rxnfc,
6242 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04006243 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006244 .port_bridge_join = mv88e6xxx_port_bridge_join,
6245 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02006246 .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags,
6247 .port_bridge_flags = mv88e6xxx_port_bridge_flags,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006248 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04006249 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006250 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006251 .port_vlan_add = mv88e6xxx_port_vlan_add,
6252 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006253 .port_fdb_add = mv88e6xxx_port_fdb_add,
6254 .port_fdb_del = mv88e6xxx_port_fdb_del,
6255 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04006256 .port_mdb_add = mv88e6xxx_port_mdb_add,
6257 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01006258 .port_mirror_add = mv88e6xxx_port_mirror_add,
6259 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04006260 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
6261 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006262 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
6263 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
6264 .port_txtstamp = mv88e6xxx_port_txtstamp,
6265 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
6266 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02006267 .devlink_param_get = mv88e6xxx_devlink_param_get,
6268 .devlink_param_set = mv88e6xxx_devlink_param_set,
Andrew Lunn93157302020-09-18 21:11:09 +02006269 .devlink_info_get = mv88e6xxx_devlink_info_get,
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006270 .port_lag_change = mv88e6xxx_port_lag_change,
6271 .port_lag_join = mv88e6xxx_port_lag_join,
6272 .port_lag_leave = mv88e6xxx_port_lag_leave,
6273 .crosschip_lag_change = mv88e6xxx_crosschip_lag_change,
6274 .crosschip_lag_join = mv88e6xxx_crosschip_lag_join,
6275 .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave,
Vladimir Olteance5df682021-07-22 18:55:41 +03006276 .port_bridge_tx_fwd_offload = mv88e6xxx_bridge_tx_fwd_offload,
6277 .port_bridge_tx_fwd_unoffload = mv88e6xxx_bridge_tx_fwd_unoffload,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006278};
6279
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08006280static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006281{
Vivien Didelotfad09c72016-06-21 12:28:20 -04006282 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006283 struct dsa_switch *ds;
6284
Vivien Didelot7e99e342019-10-21 16:51:30 -04006285 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006286 if (!ds)
6287 return -ENOMEM;
6288
Vivien Didelot7e99e342019-10-21 16:51:30 -04006289 ds->dev = dev;
6290 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04006291 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006292 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04006293 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04006294 ds->ageing_time_min = chip->info->age_time_coeff;
6295 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006296
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006297 /* Some chips support up to 32, but that requires enabling the
6298 * 5-bit port mode, which we do not support. 640k^W16 ought to
6299 * be enough for anyone.
6300 */
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01006301 ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006302
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006303 dev_set_drvdata(dev, ds);
6304
Vivien Didelot23c9ee42017-05-26 18:12:51 -04006305 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006306}
6307
Vivien Didelotfad09c72016-06-21 12:28:20 -04006308static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006309{
Vivien Didelotfad09c72016-06-21 12:28:20 -04006310 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006311}
6312
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006313static const void *pdata_device_get_match_data(struct device *dev)
6314{
6315 const struct of_device_id *matches = dev->driver->of_match_table;
6316 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
6317
6318 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
6319 matches++) {
6320 if (!strcmp(pdata->compatible, matches->compatible))
6321 return matches->data;
6322 }
6323 return NULL;
6324}
6325
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01006326/* There is no suspend to RAM support at DSA level yet, the switch configuration
6327 * would be lost after a power cycle so prevent it to be suspended.
6328 */
6329static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
6330{
6331 return -EOPNOTSUPP;
6332}
6333
6334static int __maybe_unused mv88e6xxx_resume(struct device *dev)
6335{
6336 return 0;
6337}
6338
6339static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
6340
Vivien Didelot57d32312016-06-20 13:13:58 -04006341static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006342{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006343 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04006344 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006345 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006346 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04006347 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006348 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02006349 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006350
Andrew Lunn7bb8c992018-05-31 00:15:42 +02006351 if (!np && !pdata)
6352 return -EINVAL;
6353
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006354 if (np)
6355 compat_info = of_device_get_match_data(dev);
6356
6357 if (pdata) {
6358 compat_info = pdata_device_get_match_data(dev);
6359
6360 if (!pdata->netdev)
6361 return -EINVAL;
6362
6363 for (port = 0; port < DSA_MAX_PORTS; port++) {
6364 if (!(pdata->enabled_ports & (1 << port)))
6365 continue;
6366 if (strcmp(pdata->cd.port_names[port], "cpu"))
6367 continue;
6368 pdata->cd.netdev[port] = &pdata->netdev->dev;
6369 break;
6370 }
6371 }
6372
Vivien Didelotcaac8542016-06-20 13:14:09 -04006373 if (!compat_info)
6374 return -EINVAL;
6375
Vivien Didelotfad09c72016-06-21 12:28:20 -04006376 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006377 if (!chip) {
6378 err = -ENOMEM;
6379 goto out;
6380 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006381
Vivien Didelotfad09c72016-06-21 12:28:20 -04006382 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04006383
Vivien Didelotfad09c72016-06-21 12:28:20 -04006384 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04006385 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006386 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006387
Andrew Lunnb4308f02016-11-21 23:26:55 +01006388 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006389 if (IS_ERR(chip->reset)) {
6390 err = PTR_ERR(chip->reset);
6391 goto out;
6392 }
Baruch Siach7b75e492019-06-27 21:17:39 +03006393 if (chip->reset)
6394 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01006395
Vivien Didelotfad09c72016-06-21 12:28:20 -04006396 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04006397 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006398 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006399
Tobias Waldekranz670bb802021-04-20 20:53:07 +02006400 if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED)
6401 chip->tag_protocol = DSA_TAG_PROTO_EDSA;
6402 else
6403 chip->tag_protocol = DSA_TAG_PROTO_DSA;
6404
Vivien Didelote57e5e72016-08-15 17:19:00 -04006405 mv88e6xxx_phy_init(chip);
6406
Andrew Lunn00baabe2018-05-19 22:31:35 +02006407 if (chip->info->ops->get_eeprom) {
6408 if (np)
6409 of_property_read_u32(np, "eeprom-length",
6410 &chip->eeprom_len);
6411 else
6412 chip->eeprom_len = pdata->eeprom_len;
6413 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006414
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006415 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006416 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006417 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02006418 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02006419 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02006420
Andrew Lunna27415d2019-05-01 00:10:50 +02006421 if (np) {
6422 chip->irq = of_irq_get(np, 0);
6423 if (chip->irq == -EPROBE_DEFER) {
6424 err = chip->irq;
6425 goto out;
6426 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02006427 }
6428
Andrew Lunna27415d2019-05-01 00:10:50 +02006429 if (pdata)
6430 chip->irq = pdata->irq;
6431
Andrew Lunn294d7112018-02-22 22:58:32 +01006432 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01006433 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01006434 * controllers
6435 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006436 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006437 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02006438 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006439 else
6440 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006441 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006442
Andrew Lunn294d7112018-02-22 22:58:32 +01006443 if (err)
6444 goto out;
6445
6446 if (chip->info->g2_irqs > 0) {
6447 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006448 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01006449 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02006450 }
6451
Andrew Lunn294d7112018-02-22 22:58:32 +01006452 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
6453 if (err)
6454 goto out_g2_irq;
6455
6456 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
6457 if (err)
6458 goto out_g1_atu_prob_irq;
6459
Andrew Lunna3c53be52017-01-24 14:53:50 +01006460 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02006461 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01006462 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02006463
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08006464 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006465 if (err)
6466 goto out_mdio;
6467
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006468 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02006469
6470out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01006471 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01006472out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006473 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01006474out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006475 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006476out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006477 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02006478 mv88e6xxx_g2_irq_free(chip);
6479out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006480 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01006481 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006482 else
6483 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006484out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006485 if (pdata)
6486 dev_put(pdata->netdev);
6487
Andrew Lunndc30c352016-10-16 19:56:49 +02006488 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006489}
6490
6491static void mv88e6xxx_remove(struct mdio_device *mdiodev)
6492{
6493 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006494 struct mv88e6xxx_chip *chip;
6495
6496 if (!ds)
6497 return;
6498
6499 chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006500
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006501 if (chip->info->ptp_support) {
6502 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01006503 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006504 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01006505
Andrew Lunn930188c2016-08-22 16:01:03 +02006506 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04006507 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01006508 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006509
Andrew Lunn76f38f12018-03-17 20:21:09 +01006510 mv88e6xxx_g1_vtu_prob_irq_free(chip);
6511 mv88e6xxx_g1_atu_prob_irq_free(chip);
6512
6513 if (chip->info->g2_irqs > 0)
6514 mv88e6xxx_g2_irq_free(chip);
6515
Andrew Lunn76f38f12018-03-17 20:21:09 +01006516 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01006517 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01006518 else
6519 mv88e6xxx_irq_poll_free(chip);
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006520
6521 dev_set_drvdata(&mdiodev->dev, NULL);
6522}
6523
6524static void mv88e6xxx_shutdown(struct mdio_device *mdiodev)
6525{
6526 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
6527
6528 if (!ds)
6529 return;
6530
6531 dsa_switch_shutdown(ds);
6532
6533 dev_set_drvdata(&mdiodev->dev, NULL);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006534}
6535
6536static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04006537 {
6538 .compatible = "marvell,mv88e6085",
6539 .data = &mv88e6xxx_table[MV88E6085],
6540 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01006541 {
6542 .compatible = "marvell,mv88e6190",
6543 .data = &mv88e6xxx_table[MV88E6190],
6544 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00006545 {
6546 .compatible = "marvell,mv88e6250",
6547 .data = &mv88e6xxx_table[MV88E6250],
6548 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006549 { /* sentinel */ },
6550};
6551
6552MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
6553
6554static struct mdio_driver mv88e6xxx_driver = {
6555 .probe = mv88e6xxx_probe,
6556 .remove = mv88e6xxx_remove,
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006557 .shutdown = mv88e6xxx_shutdown,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006558 .mdiodrv.driver = {
6559 .name = "mv88e6085",
6560 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01006561 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006562 },
6563};
6564
Andrew Lunn7324d502019-04-27 19:19:10 +02006565mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00006566
6567MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
6568MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
6569MODULE_LICENSE("GPL");