blob: cd8462d1e27c04f09dae7702d8ff2a391cd35373 [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
Russell King (Oracle)2b29cb92021-12-07 10:32:43 +0000474 /* The 88e6250 family does not have the PHY detect bit. Instead,
475 * report whether the port is internal.
476 */
477 if (chip->info->family == MV88E6XXX_FAMILY_6250)
478 return port < chip->info->num_internal_phys;
479
Russell King5d5b2312020-03-14 10:16:03 +0000480 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
481 if (err) {
482 dev_err(chip->dev,
483 "p%d: %s: failed to read port status\n",
484 port, __func__);
485 return err;
486 }
487
488 return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
489}
490
Russell Kinga5a68582020-03-14 10:15:43 +0000491static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
492 struct phylink_link_state *state)
493{
494 struct mv88e6xxx_chip *chip = ds->priv;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100495 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000496 int err;
497
498 mv88e6xxx_reg_lock(chip);
499 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100500 if (lane >= 0 && chip->info->ops->serdes_pcs_get_state)
Russell Kinga5a68582020-03-14 10:15:43 +0000501 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
502 state);
503 else
504 err = -EOPNOTSUPP;
505 mv88e6xxx_reg_unlock(chip);
506
507 return err;
508}
509
510static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
511 unsigned int mode,
512 phy_interface_t interface,
513 const unsigned long *advertise)
514{
515 const struct mv88e6xxx_ops *ops = chip->info->ops;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100516 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000517
518 if (ops->serdes_pcs_config) {
519 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100520 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000521 return ops->serdes_pcs_config(chip, port, lane, mode,
522 interface, advertise);
523 }
524
525 return 0;
526}
527
528static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
529{
530 struct mv88e6xxx_chip *chip = ds->priv;
531 const struct mv88e6xxx_ops *ops;
532 int err = 0;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100533 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000534
535 ops = chip->info->ops;
536
537 if (ops->serdes_pcs_an_restart) {
538 mv88e6xxx_reg_lock(chip);
539 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100540 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000541 err = ops->serdes_pcs_an_restart(chip, port, lane);
542 mv88e6xxx_reg_unlock(chip);
543
544 if (err)
545 dev_err(ds->dev, "p%d: failed to restart AN\n", port);
546 }
547}
548
549static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
550 unsigned int mode,
551 int speed, int duplex)
552{
553 const struct mv88e6xxx_ops *ops = chip->info->ops;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100554 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000555
556 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
557 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100558 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000559 return ops->serdes_pcs_link_up(chip, port, lane,
560 speed, duplex);
561 }
562
563 return 0;
564}
565
Russell King6c422e32018-08-09 15:38:39 +0200566static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
567 unsigned long *mask,
568 struct phylink_link_state *state)
569{
570 if (!phy_interface_mode_is_8023z(state->interface)) {
571 /* 10M and 100M are only supported in non-802.3z mode */
572 phylink_set(mask, 10baseT_Half);
573 phylink_set(mask, 10baseT_Full);
574 phylink_set(mask, 100baseT_Half);
575 phylink_set(mask, 100baseT_Full);
576 }
577}
578
579static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
580 unsigned long *mask,
581 struct phylink_link_state *state)
582{
583 /* FIXME: if the port is in 1000Base-X mode, then it only supports
584 * 1000M FD speeds. In this case, CMODE will indicate 5.
585 */
586 phylink_set(mask, 1000baseT_Full);
587 phylink_set(mask, 1000baseX_Full);
588
589 mv88e6065_phylink_validate(chip, port, mask, state);
590}
591
Marek Behúne3af71a2019-02-25 12:39:55 +0100592static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
593 unsigned long *mask,
594 struct phylink_link_state *state)
595{
596 if (port >= 5)
597 phylink_set(mask, 2500baseX_Full);
598
599 /* No ethtool bits for 200Mbps */
600 phylink_set(mask, 1000baseT_Full);
601 phylink_set(mask, 1000baseX_Full);
602
603 mv88e6065_phylink_validate(chip, port, mask, state);
604}
605
Russell King6c422e32018-08-09 15:38:39 +0200606static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
607 unsigned long *mask,
608 struct phylink_link_state *state)
609{
610 /* No ethtool bits for 200Mbps */
611 phylink_set(mask, 1000baseT_Full);
612 phylink_set(mask, 1000baseX_Full);
613
614 mv88e6065_phylink_validate(chip, port, mask, state);
615}
616
617static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
618 unsigned long *mask,
619 struct phylink_link_state *state)
620{
Andrew Lunnec260162019-02-08 22:25:44 +0100621 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200622 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100623 phylink_set(mask, 2500baseT_Full);
624 }
Russell King6c422e32018-08-09 15:38:39 +0200625
626 /* No ethtool bits for 200Mbps */
627 phylink_set(mask, 1000baseT_Full);
628 phylink_set(mask, 1000baseX_Full);
629
630 mv88e6065_phylink_validate(chip, port, mask, state);
631}
632
633static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
634 unsigned long *mask,
635 struct phylink_link_state *state)
636{
637 if (port >= 9) {
638 phylink_set(mask, 10000baseT_Full);
639 phylink_set(mask, 10000baseKR_Full);
640 }
641
642 mv88e6390_phylink_validate(chip, port, mask, state);
643}
644
Pavana Sharmade776d02021-03-17 14:46:42 +0100645static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
646 unsigned long *mask,
647 struct phylink_link_state *state)
648{
Marek Behúndc2fc9f2021-11-04 18:17:47 +0100649 bool is_6191x =
650 chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6191X;
651
652 if (((port == 0 || port == 9) && !is_6191x) || port == 10) {
Pavana Sharmade776d02021-03-17 14:46:42 +0100653 phylink_set(mask, 10000baseT_Full);
654 phylink_set(mask, 10000baseKR_Full);
655 phylink_set(mask, 10000baseCR_Full);
656 phylink_set(mask, 10000baseSR_Full);
657 phylink_set(mask, 10000baseLR_Full);
658 phylink_set(mask, 10000baseLRM_Full);
659 phylink_set(mask, 10000baseER_Full);
660 phylink_set(mask, 5000baseT_Full);
661 phylink_set(mask, 2500baseX_Full);
662 phylink_set(mask, 2500baseT_Full);
663 }
664
665 phylink_set(mask, 1000baseT_Full);
666 phylink_set(mask, 1000baseX_Full);
667
668 mv88e6065_phylink_validate(chip, port, mask, state);
669}
670
Russell Kingc9a23562018-05-10 13:17:35 -0700671static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
672 unsigned long *supported,
673 struct phylink_link_state *state)
674{
Russell King6c422e32018-08-09 15:38:39 +0200675 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
676 struct mv88e6xxx_chip *chip = ds->priv;
677
678 /* Allow all the expected bits */
679 phylink_set(mask, Autoneg);
680 phylink_set(mask, Pause);
681 phylink_set_port_modes(mask);
682
683 if (chip->info->ops->phylink_validate)
684 chip->info->ops->phylink_validate(chip, port, mask, state);
685
Sean Anderson49730562021-10-22 18:41:04 -0400686 linkmode_and(supported, supported, mask);
687 linkmode_and(state->advertising, state->advertising, mask);
Russell King6c422e32018-08-09 15:38:39 +0200688
689 /* We can only operate at 2500BaseX or 1000BaseX. If requested
690 * to advertise both, only report advertising at 2500BaseX.
691 */
692 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700693}
694
Russell Kingc9a23562018-05-10 13:17:35 -0700695static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
696 unsigned int mode,
697 const struct phylink_link_state *state)
698{
699 struct mv88e6xxx_chip *chip = ds->priv;
Russell Kingfad58192020-07-19 12:00:35 +0100700 struct mv88e6xxx_port *p;
Russell King (Oracle)04ec4e62021-12-09 09:26:47 +0000701 int err = 0;
Russell Kingc9a23562018-05-10 13:17:35 -0700702
Russell Kingfad58192020-07-19 12:00:35 +0100703 p = &chip->ports[port];
704
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000705 mv88e6xxx_reg_lock(chip);
Russell Kingfad58192020-07-19 12:00:35 +0100706
Russell King (Oracle)04ec4e62021-12-09 09:26:47 +0000707 if (mode != MLO_AN_PHY || !mv88e6xxx_phy_is_internal(ds, port)) {
708 /* In inband mode, the link may come up at any time while the
709 * link is not forced down. Force the link down while we
710 * reconfigure the interface mode.
711 */
712 if (mode == MLO_AN_INBAND &&
713 p->interface != state->interface &&
714 chip->info->ops->port_set_link)
715 chip->info->ops->port_set_link(chip, port,
716 LINK_FORCED_DOWN);
Russell Kinga5a68582020-03-14 10:15:43 +0000717
Russell King (Oracle)04ec4e62021-12-09 09:26:47 +0000718 err = mv88e6xxx_port_config_interface(chip, port,
719 state->interface);
720 if (err && err != -EOPNOTSUPP)
721 goto err_unlock;
722
723 err = mv88e6xxx_serdes_pcs_config(chip, port, mode,
724 state->interface,
725 state->advertising);
726 /* FIXME: we should restart negotiation if something changed -
727 * which is something we get if we convert to using phylinks
728 * PCS operations.
729 */
730 if (err > 0)
731 err = 0;
732 }
Russell Kinga5a68582020-03-14 10:15:43 +0000733
Russell Kingfad58192020-07-19 12:00:35 +0100734 /* Undo the forced down state above after completing configuration
Russell King (Oracle)04ec4e62021-12-09 09:26:47 +0000735 * irrespective of its state on entry, which allows the link to come
736 * up in the in-band case where there is no separate SERDES. Also
737 * ensure that the link can come up if the PPU is in use and we are
738 * in PHY mode (we treat the PPU as an effective in-band mechanism.)
Russell Kingfad58192020-07-19 12:00:35 +0100739 */
Russell King (Oracle)04ec4e62021-12-09 09:26:47 +0000740 if (chip->info->ops->port_set_link &&
741 ((mode == MLO_AN_INBAND && p->interface != state->interface) ||
742 (mode == MLO_AN_PHY && mv88e6xxx_port_ppu_updates(chip, port))))
Russell Kingfad58192020-07-19 12:00:35 +0100743 chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
744
745 p->interface = state->interface;
746
Russell Kinga5a68582020-03-14 10:15:43 +0000747err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000748 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700749
750 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000751 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700752}
753
Russell Kingc9a23562018-05-10 13:17:35 -0700754static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
755 unsigned int mode,
756 phy_interface_t interface)
757{
Russell King30c4a5b2020-02-26 10:23:51 +0000758 struct mv88e6xxx_chip *chip = ds->priv;
759 const struct mv88e6xxx_ops *ops;
760 int err = 0;
761
762 ops = chip->info->ops;
763
Russell King5d5b2312020-03-14 10:16:03 +0000764 mv88e6xxx_reg_lock(chip);
Russell King (Oracle)2b29cb92021-12-07 10:32:43 +0000765 /* Force the link down if we know the port may not be automatically
766 * updated by the switch or if we are using fixed-link mode.
Maarten Zanders4a3e0ae2021-10-11 16:27:20 +0200767 */
Russell King (Oracle)2b29cb92021-12-07 10:32:43 +0000768 if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
Chris Packham4efe76622020-11-24 17:34:37 +1300769 mode == MLO_AN_FIXED) && ops->port_sync_link)
770 err = ops->port_sync_link(chip, port, mode, false);
Marek Behún9d591fc2021-12-11 23:51:41 +0100771
772 if (!err && ops->port_set_speed_duplex)
773 err = ops->port_set_speed_duplex(chip, port, SPEED_UNFORCED,
774 DUPLEX_UNFORCED);
Russell King5d5b2312020-03-14 10:16:03 +0000775 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000776
Russell King5d5b2312020-03-14 10:16:03 +0000777 if (err)
778 dev_err(chip->dev,
779 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700780}
781
782static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
783 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000784 struct phy_device *phydev,
785 int speed, int duplex,
786 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700787{
Russell King30c4a5b2020-02-26 10:23:51 +0000788 struct mv88e6xxx_chip *chip = ds->priv;
789 const struct mv88e6xxx_ops *ops;
790 int err = 0;
791
792 ops = chip->info->ops;
793
Russell King5d5b2312020-03-14 10:16:03 +0000794 mv88e6xxx_reg_lock(chip);
Russell King (Oracle)2b29cb92021-12-07 10:32:43 +0000795 /* Configure and force the link up if we know that the port may not
796 * automatically updated by the switch or if we are using fixed-link
797 * mode.
Maarten Zanders4a3e0ae2021-10-11 16:27:20 +0200798 */
Russell King (Oracle)2b29cb92021-12-07 10:32:43 +0000799 if (!mv88e6xxx_port_ppu_updates(chip, port) ||
Maarten Zanders4a3e0ae2021-10-11 16:27:20 +0200800 mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000801 /* FIXME: for an automedia port, should we force the link
802 * down here - what if the link comes up due to "other" media
803 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000804 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000805 * shared between internal PHY and Serdes.
806 */
Russell Kinga5a68582020-03-14 10:15:43 +0000807 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
808 duplex);
809 if (err)
810 goto error;
811
Russell Kingf365c6f2020-03-14 10:15:53 +0000812 if (ops->port_set_speed_duplex) {
813 err = ops->port_set_speed_duplex(chip, port,
814 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000815 if (err && err != -EOPNOTSUPP)
816 goto error;
817 }
818
Chris Packham4efe76622020-11-24 17:34:37 +1300819 if (ops->port_sync_link)
820 err = ops->port_sync_link(chip, port, mode, true);
Russell King30c4a5b2020-02-26 10:23:51 +0000821 }
Russell King5d5b2312020-03-14 10:16:03 +0000822error:
823 mv88e6xxx_reg_unlock(chip);
824
825 if (err && err != -EOPNOTSUPP)
826 dev_err(ds->dev,
827 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700828}
829
Andrew Lunna605a0f2016-11-21 23:26:58 +0100830static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000831{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100832 if (!chip->info->ops->stats_snapshot)
833 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000834
Andrew Lunna605a0f2016-11-21 23:26:58 +0100835 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000836}
837
Andrew Lunne413e7e2015-04-02 04:06:38 +0200838static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100839 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
840 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
841 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
842 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
843 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
844 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
845 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
846 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
847 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
848 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
849 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
850 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
851 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
852 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
853 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
854 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
855 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
856 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
857 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
858 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
859 { "single", 4, 0x14, STATS_TYPE_BANK0, },
860 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
861 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
862 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
863 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
864 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
865 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
866 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
867 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
868 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
869 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
870 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
871 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
872 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
873 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
874 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
875 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
876 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
877 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
878 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
879 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
880 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
881 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
882 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
883 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
884 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
885 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
886 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
887 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
888 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
889 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
890 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
891 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
892 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
893 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
894 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
895 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
896 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
897 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200898};
899
Vivien Didelotfad09c72016-06-21 12:28:20 -0400900static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100901 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100902 int port, u16 bank1_select,
903 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200904{
Andrew Lunn80c46272015-06-20 18:42:30 +0200905 u32 low;
906 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100907 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200908 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200909 u64 value;
910
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100911 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100912 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200913 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
914 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800915 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200916
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200917 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100918 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200919 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
920 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800921 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000922 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200923 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100924 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100925 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100926 reg = bank1_select;
Gustavo A. R. Silvadf561f662020-08-23 17:36:59 -0500927 fallthrough;
Andrew Lunndfafe442016-11-21 23:27:02 +0100928 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100929 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100930 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100931 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100932 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500933 break;
934 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800935 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200936 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100937 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200938 return value;
939}
940
Andrew Lunn436fe172018-03-01 02:02:29 +0100941static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
942 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100943{
944 struct mv88e6xxx_hw_stat *stat;
945 int i, j;
946
947 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
948 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100949 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100950 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
951 ETH_GSTRING_LEN);
952 j++;
953 }
954 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100955
956 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100957}
958
Andrew Lunn436fe172018-03-01 02:02:29 +0100959static int mv88e6095_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_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100964}
965
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000966static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
967 uint8_t *data)
968{
969 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
970}
971
Andrew Lunn436fe172018-03-01 02:02:29 +0100972static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
973 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100974{
Andrew Lunn436fe172018-03-01 02:02:29 +0100975 return mv88e6xxx_stats_get_strings(chip, data,
976 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100977}
978
Andrew Lunn65f60e42018-03-28 23:50:28 +0200979static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
980 "atu_member_violation",
981 "atu_miss_violation",
982 "atu_full_violation",
983 "vtu_member_violation",
984 "vtu_miss_violation",
985};
986
987static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
988{
989 unsigned int i;
990
991 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
992 strlcpy(data + i * ETH_GSTRING_LEN,
993 mv88e6xxx_atu_vtu_stats_strings[i],
994 ETH_GSTRING_LEN);
995}
996
Andrew Lunndfafe442016-11-21 23:27:02 +0100997static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700998 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100999{
Vivien Didelot04bed142016-08-31 18:06:13 -04001000 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001001 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001002
Florian Fainelli89f09042018-04-25 12:12:50 -07001003 if (stringset != ETH_SS_STATS)
1004 return;
1005
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001006 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001007
Andrew Lunndfafe442016-11-21 23:27:02 +01001008 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +01001009 count = chip->info->ops->stats_get_strings(chip, data);
1010
1011 if (chip->info->ops->serdes_get_strings) {
1012 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001013 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001014 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001015
Andrew Lunn65f60e42018-03-28 23:50:28 +02001016 data += count * ETH_GSTRING_LEN;
1017 mv88e6xxx_atu_vtu_get_strings(data);
1018
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001019 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001020}
1021
1022static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
1023 int types)
1024{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001025 struct mv88e6xxx_hw_stat *stat;
1026 int i, j;
1027
1028 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1029 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +01001030 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001031 j++;
1032 }
1033 return j;
1034}
1035
Andrew Lunndfafe442016-11-21 23:27:02 +01001036static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1037{
1038 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1039 STATS_TYPE_PORT);
1040}
1041
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001042static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1043{
1044 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
1045}
1046
Andrew Lunndfafe442016-11-21 23:27:02 +01001047static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1048{
1049 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1050 STATS_TYPE_BANK1);
1051}
1052
Florian Fainelli89f09042018-04-25 12:12:50 -07001053static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001054{
1055 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001056 int serdes_count = 0;
1057 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001058
Florian Fainelli89f09042018-04-25 12:12:50 -07001059 if (sset != ETH_SS_STATS)
1060 return 0;
1061
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001062 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001063 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001064 count = chip->info->ops->stats_get_sset_count(chip);
1065 if (count < 0)
1066 goto out;
1067
1068 if (chip->info->ops->serdes_get_sset_count)
1069 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1070 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001071 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001072 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001073 goto out;
1074 }
1075 count += serdes_count;
1076 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1077
Andrew Lunn436fe172018-03-01 02:02:29 +01001078out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001079 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001080
Andrew Lunn436fe172018-03-01 02:02:29 +01001081 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001082}
1083
Andrew Lunn436fe172018-03-01 02:02:29 +01001084static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1085 uint64_t *data, int types,
1086 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001087{
1088 struct mv88e6xxx_hw_stat *stat;
1089 int i, j;
1090
1091 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1092 stat = &mv88e6xxx_hw_stats[i];
1093 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001094 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001095 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1096 bank1_select,
1097 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001098 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001099
Andrew Lunn052f9472016-11-21 23:27:03 +01001100 j++;
1101 }
1102 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001103 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001104}
1105
Andrew Lunn436fe172018-03-01 02:02:29 +01001106static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1107 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001108{
1109 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001110 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001111 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001112}
1113
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001114static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1115 uint64_t *data)
1116{
1117 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1118 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1119}
1120
Andrew Lunn436fe172018-03-01 02:02:29 +01001121static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1122 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001123{
1124 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001125 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001126 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1127 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001128}
1129
Andrew Lunn436fe172018-03-01 02:02:29 +01001130static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1131 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001132{
1133 return mv88e6xxx_stats_get_stats(chip, port, data,
1134 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001135 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1136 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001137}
1138
Andrew Lunn65f60e42018-03-28 23:50:28 +02001139static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1140 uint64_t *data)
1141{
1142 *data++ = chip->ports[port].atu_member_violation;
1143 *data++ = chip->ports[port].atu_miss_violation;
1144 *data++ = chip->ports[port].atu_full_violation;
1145 *data++ = chip->ports[port].vtu_member_violation;
1146 *data++ = chip->ports[port].vtu_miss_violation;
1147}
1148
Andrew Lunn052f9472016-11-21 23:27:03 +01001149static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1150 uint64_t *data)
1151{
Andrew Lunn436fe172018-03-01 02:02:29 +01001152 int count = 0;
1153
Andrew Lunn052f9472016-11-21 23:27:03 +01001154 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001155 count = chip->info->ops->stats_get_stats(chip, port, data);
1156
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001157 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001158 if (chip->info->ops->serdes_get_stats) {
1159 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001160 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001161 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001162 data += count;
1163 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001164 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001165}
1166
Vivien Didelotf81ec902016-05-09 13:22:58 -04001167static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1168 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001169{
Vivien Didelot04bed142016-08-31 18:06:13 -04001170 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001171 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001172
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001173 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001174
Andrew Lunna605a0f2016-11-21 23:26:58 +01001175 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001176 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001177
1178 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001179 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001180
1181 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001182
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001183}
Ben Hutchings98e67302011-11-25 14:36:19 +00001184
Vivien Didelotf81ec902016-05-09 13:22:58 -04001185static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001186{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001187 struct mv88e6xxx_chip *chip = ds->priv;
1188 int len;
1189
1190 len = 32 * sizeof(u16);
1191 if (chip->info->ops->serdes_get_regs_len)
1192 len += chip->info->ops->serdes_get_regs_len(chip, port);
1193
1194 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001195}
1196
Vivien Didelotf81ec902016-05-09 13:22:58 -04001197static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1198 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001199{
Vivien Didelot04bed142016-08-31 18:06:13 -04001200 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001201 int err;
1202 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001203 u16 *p = _p;
1204 int i;
1205
Vivien Didelota5f39322018-12-17 16:05:21 -05001206 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001207
1208 memset(p, 0xff, 32 * sizeof(u16));
1209
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001210 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001211
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001212 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001213
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001214 err = mv88e6xxx_port_read(chip, port, i, &reg);
1215 if (!err)
1216 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001217 }
Vivien Didelot23062512016-05-09 13:22:45 -04001218
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001219 if (chip->info->ops->serdes_get_regs)
1220 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1221
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001222 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001223}
1224
Vivien Didelot08f50062017-08-01 16:32:41 -04001225static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1226 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001227{
Vivien Didelot5480db62017-08-01 16:32:40 -04001228 /* Nothing to do on the port's MAC */
1229 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001230}
1231
Vivien Didelot08f50062017-08-01 16:32:41 -04001232static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1233 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001234{
Vivien Didelot5480db62017-08-01 16:32:40 -04001235 /* Nothing to do on the port's MAC */
1236 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001237}
1238
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001239/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001240static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001241{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001242 struct dsa_switch *ds = chip->ds;
1243 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001244 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001245 struct dsa_port *dp;
1246 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001247 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001248
Vladimir Olteance5df682021-07-22 18:55:41 +03001249 /* dev is a physical switch */
1250 if (dev <= dst->last_switch) {
1251 list_for_each_entry(dp, &dst->ports, list) {
1252 if (dp->ds->index == dev && dp->index == port) {
1253 /* dp might be a DSA link or a user port, so it
1254 * might or might not have a bridge_dev
1255 * pointer. Use the "found" variable for both
1256 * cases.
1257 */
1258 br = dp->bridge_dev;
1259 found = true;
1260 break;
1261 }
1262 }
1263 /* dev is a virtual bridge */
1264 } else {
1265 list_for_each_entry(dp, &dst->ports, list) {
1266 if (dp->bridge_num < 0)
1267 continue;
1268
1269 if (dp->bridge_num + 1 + dst->last_switch != dev)
1270 continue;
1271
1272 br = dp->bridge_dev;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001273 found = true;
1274 break;
1275 }
1276 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001277
Vladimir Olteance5df682021-07-22 18:55:41 +03001278 /* Prevent frames from unknown switch or virtual bridge */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001279 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001280 return 0;
1281
1282 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001283 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001284 return mv88e6xxx_port_mask(chip);
1285
Vivien Didelote5887a22017-03-30 17:37:11 -04001286 pvlan = 0;
1287
1288 /* Frames from user ports can egress any local DSA links and CPU ports,
1289 * as well as any local member of their bridge group.
1290 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001291 list_for_each_entry(dp, &dst->ports, list)
1292 if (dp->ds == ds &&
1293 (dp->type == DSA_PORT_TYPE_CPU ||
1294 dp->type == DSA_PORT_TYPE_DSA ||
1295 (br && dp->bridge_dev == br)))
1296 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001297
1298 return pvlan;
1299}
1300
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001301static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001302{
1303 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001304
1305 /* prevent frames from going back out of the port they came in on */
1306 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001307
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001308 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001309}
1310
Vivien Didelotf81ec902016-05-09 13:22:58 -04001311static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1312 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001313{
Vivien Didelot04bed142016-08-31 18:06:13 -04001314 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001315 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001316
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001317 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001318 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001319 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001320
1321 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001322 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001323}
1324
Vivien Didelot93e18d62018-05-11 17:16:35 -04001325static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1326{
1327 int err;
1328
1329 if (chip->info->ops->ieee_pri_map) {
1330 err = chip->info->ops->ieee_pri_map(chip);
1331 if (err)
1332 return err;
1333 }
1334
1335 if (chip->info->ops->ip_pri_map) {
1336 err = chip->info->ops->ip_pri_map(chip);
1337 if (err)
1338 return err;
1339 }
1340
1341 return 0;
1342}
1343
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001344static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1345{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001346 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001347 int target, port;
1348 int err;
1349
1350 if (!chip->info->global2_addr)
1351 return 0;
1352
1353 /* Initialize the routing port to the 32 possible target devices */
1354 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001355 port = dsa_routing_port(ds, target);
1356 if (port == ds->num_ports)
1357 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001358
1359 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1360 if (err)
1361 return err;
1362 }
1363
Vivien Didelot02317e62018-05-09 11:38:49 -04001364 if (chip->info->ops->set_cascade_port) {
1365 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1366 err = chip->info->ops->set_cascade_port(chip, port);
1367 if (err)
1368 return err;
1369 }
1370
Vivien Didelot23c98912018-05-09 11:38:50 -04001371 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1372 if (err)
1373 return err;
1374
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001375 return 0;
1376}
1377
Vivien Didelotb28f8722018-04-26 21:56:44 -04001378static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1379{
1380 /* Clear all trunk masks and mapping */
1381 if (chip->info->global2_addr)
1382 return mv88e6xxx_g2_trunk_clear(chip);
1383
1384 return 0;
1385}
1386
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001387static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1388{
1389 if (chip->info->ops->rmu_disable)
1390 return chip->info->ops->rmu_disable(chip);
1391
1392 return 0;
1393}
1394
Vivien Didelot9e907d72017-07-17 13:03:43 -04001395static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1396{
1397 if (chip->info->ops->pot_clear)
1398 return chip->info->ops->pot_clear(chip);
1399
1400 return 0;
1401}
1402
Vivien Didelot51c901a2017-07-17 13:03:41 -04001403static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1404{
1405 if (chip->info->ops->mgmt_rsvd2cpu)
1406 return chip->info->ops->mgmt_rsvd2cpu(chip);
1407
1408 return 0;
1409}
1410
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001411static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1412{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001413 int err;
1414
Vivien Didelotdaefc942017-03-11 16:12:54 -05001415 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1416 if (err)
1417 return err;
1418
Rasmus Villemoes49506a92020-12-10 12:06:44 +01001419 /* The chips that have a "learn2all" bit in Global1, ATU
1420 * Control are precisely those whose port registers have a
1421 * Message Port bit in Port Control 1 and hence implement
1422 * ->port_setup_message_port.
1423 */
1424 if (chip->info->ops->port_setup_message_port) {
1425 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1426 if (err)
1427 return err;
1428 }
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001429
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001430 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1431}
1432
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001433static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1434{
1435 int port;
1436 int err;
1437
1438 if (!chip->info->ops->irl_init_all)
1439 return 0;
1440
1441 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1442 /* Disable ingress rate limiting by resetting all per port
1443 * ingress rate limit resources to their initial state.
1444 */
1445 err = chip->info->ops->irl_init_all(chip, port);
1446 if (err)
1447 return err;
1448 }
1449
1450 return 0;
1451}
1452
Vivien Didelot04a69a12017-10-13 14:18:05 -04001453static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1454{
1455 if (chip->info->ops->set_switch_mac) {
1456 u8 addr[ETH_ALEN];
1457
1458 eth_random_addr(addr);
1459
1460 return chip->info->ops->set_switch_mac(chip, addr);
1461 }
1462
1463 return 0;
1464}
1465
Vivien Didelot17a15942017-03-30 17:37:09 -04001466static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1467{
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001468 struct dsa_switch_tree *dst = chip->ds->dst;
1469 struct dsa_switch *ds;
1470 struct dsa_port *dp;
Vivien Didelot17a15942017-03-30 17:37:09 -04001471 u16 pvlan = 0;
1472
1473 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001474 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001475
1476 /* Skip the local source device, which uses in-chip port VLAN */
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001477 if (dev != chip->ds->index) {
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001478 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001479
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001480 ds = dsa_switch_find(dst->index, dev);
1481 dp = ds ? dsa_to_port(ds, port) : NULL;
1482 if (dp && dp->lag_dev) {
1483 /* As the PVT is used to limit flooding of
1484 * FORWARD frames, which use the LAG ID as the
1485 * source port, we must translate dev/port to
1486 * the special "LAG device" in the PVT, using
1487 * the LAG ID as the port number.
1488 */
Tobias Waldekranz78e70db2021-04-21 14:04:52 +02001489 dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001490 port = dsa_lag_id(dst, dp->lag_dev);
1491 }
1492 }
1493
Vivien Didelot17a15942017-03-30 17:37:09 -04001494 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1495}
1496
Vivien Didelot81228992017-03-30 17:37:08 -04001497static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1498{
Vivien Didelot17a15942017-03-30 17:37:09 -04001499 int dev, port;
1500 int err;
1501
Vivien Didelot81228992017-03-30 17:37:08 -04001502 if (!mv88e6xxx_has_pvt(chip))
1503 return 0;
1504
1505 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1506 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1507 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001508 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1509 if (err)
1510 return err;
1511
1512 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1513 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1514 err = mv88e6xxx_pvt_map(chip, dev, port);
1515 if (err)
1516 return err;
1517 }
1518 }
1519
1520 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001521}
1522
Vivien Didelot749efcb2016-09-22 16:49:24 -04001523static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1524{
1525 struct mv88e6xxx_chip *chip = ds->priv;
1526 int err;
1527
Tobias Waldekranzffcec3f2021-03-18 20:25:34 +01001528 if (dsa_to_port(ds, port)->lag_dev)
1529 /* Hardware is incapable of fast-aging a LAG through a
1530 * regular ATU move operation. Until we have something
1531 * more fancy in place this is a no-op.
1532 */
1533 return;
1534
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001535 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001536 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001537 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001538
1539 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001540 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001541}
1542
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001543static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1544{
Tobias Waldekranze545f862020-11-10 19:57:20 +01001545 if (!mv88e6xxx_max_vid(chip))
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001546 return 0;
1547
1548 return mv88e6xxx_g1_vtu_flush(chip);
1549}
1550
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001551static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1552 struct mv88e6xxx_vtu_entry *entry)
Vivien Didelotf1394b782017-05-01 14:05:22 -04001553{
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001554 int err;
1555
Vivien Didelotf1394b782017-05-01 14:05:22 -04001556 if (!chip->info->ops->vtu_getnext)
1557 return -EOPNOTSUPP;
1558
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001559 entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip);
1560 entry->valid = false;
1561
1562 err = chip->info->ops->vtu_getnext(chip, entry);
1563
1564 if (entry->vid != vid)
1565 entry->valid = false;
1566
1567 return err;
Vivien Didelotf1394b782017-05-01 14:05:22 -04001568}
1569
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001570static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip,
1571 int (*cb)(struct mv88e6xxx_chip *chip,
1572 const struct mv88e6xxx_vtu_entry *entry,
1573 void *priv),
1574 void *priv)
1575{
1576 struct mv88e6xxx_vtu_entry entry = {
1577 .vid = mv88e6xxx_max_vid(chip),
1578 .valid = false,
1579 };
1580 int err;
1581
1582 if (!chip->info->ops->vtu_getnext)
1583 return -EOPNOTSUPP;
1584
1585 do {
1586 err = chip->info->ops->vtu_getnext(chip, &entry);
1587 if (err)
1588 return err;
1589
1590 if (!entry.valid)
1591 break;
1592
1593 err = cb(chip, &entry, priv);
1594 if (err)
1595 return err;
1596 } while (entry.vid < mv88e6xxx_max_vid(chip));
1597
1598 return 0;
1599}
1600
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001601static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1602 struct mv88e6xxx_vtu_entry *entry)
1603{
1604 if (!chip->info->ops->vtu_loadpurge)
1605 return -EOPNOTSUPP;
1606
1607 return chip->info->ops->vtu_loadpurge(chip, entry);
1608}
1609
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001610static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip,
1611 const struct mv88e6xxx_vtu_entry *entry,
1612 void *_fid_bitmap)
1613{
1614 unsigned long *fid_bitmap = _fid_bitmap;
1615
1616 set_bit(entry->fid, fid_bitmap);
1617 return 0;
1618}
1619
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001620int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001621{
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001622 int i, err;
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001623 u16 fid;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001624
1625 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1626
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001627 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001628 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001629 err = mv88e6xxx_port_get_fid(chip, i, &fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001630 if (err)
1631 return err;
1632
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001633 set_bit(fid, fid_bitmap);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001634 }
1635
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001636 /* Set every FID bit used by the VLAN entries */
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001637 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap);
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001638}
1639
1640static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1641{
1642 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1643 int err;
1644
1645 err = mv88e6xxx_fid_map(chip, fid_bitmap);
1646 if (err)
1647 return err;
1648
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001649 /* The reset value 0x000 is used to indicate that multiple address
1650 * databases are not needed. Return the next positive available.
1651 */
1652 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001653 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001654 return -ENOSPC;
1655
1656 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001657 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001658}
1659
Vivien Didelotda9c3592016-02-12 12:09:40 -05001660static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001661 u16 vid)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001662{
Vivien Didelot04bed142016-08-31 18:06:13 -04001663 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001664 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001665 int i, err;
1666
Andrew Lunndb06ae412017-09-25 23:32:20 +02001667 /* DSA and CPU ports have to be members of multiple vlans */
1668 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1669 return 0;
1670
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001671 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001672 if (err)
1673 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001674
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001675 if (!vlan.valid)
1676 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001677
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001678 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
1679 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1680 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001681
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001682 if (!dsa_to_port(ds, i)->slave)
1683 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001684
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001685 if (vlan.member[i] ==
1686 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
1687 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001688
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001689 if (dsa_to_port(ds, i)->bridge_dev ==
1690 dsa_to_port(ds, port)->bridge_dev)
1691 break; /* same bridge, check next VLAN */
Vivien Didelotda9c3592016-02-12 12:09:40 -05001692
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001693 if (!dsa_to_port(ds, i)->bridge_dev)
1694 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001695
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001696 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1697 port, vlan.vid, i,
1698 netdev_name(dsa_to_port(ds, i)->bridge_dev));
1699 return -EOPNOTSUPP;
1700 }
Vivien Didelotda9c3592016-02-12 12:09:40 -05001701
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001702 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001703}
1704
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001705static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port)
1706{
1707 struct dsa_port *dp = dsa_to_port(chip->ds, port);
1708 struct mv88e6xxx_port *p = &chip->ports[port];
Vladimir Oltean5bded822021-10-07 19:47:11 +03001709 u16 pvid = MV88E6XXX_VID_STANDALONE;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001710 bool drop_untagged = false;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001711 int err;
1712
Vladimir Oltean5bded822021-10-07 19:47:11 +03001713 if (dp->bridge_dev) {
1714 if (br_vlan_enabled(dp->bridge_dev)) {
1715 pvid = p->bridge_pvid.vid;
1716 drop_untagged = !p->bridge_pvid.valid;
1717 } else {
1718 pvid = MV88E6XXX_VID_BRIDGED;
1719 }
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001720 }
1721
1722 err = mv88e6xxx_port_set_pvid(chip, port, pvid);
1723 if (err)
1724 return err;
1725
1726 return mv88e6xxx_port_drop_untagged(chip, port, drop_untagged);
1727}
1728
Vivien Didelotf81ec902016-05-09 13:22:58 -04001729static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
Vladimir Oltean89153ed2021-02-13 22:43:19 +02001730 bool vlan_filtering,
1731 struct netlink_ext_ack *extack)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001732{
Vivien Didelot04bed142016-08-31 18:06:13 -04001733 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001734 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1735 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001736 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001737
Vladimir Olteanbae33f22021-01-09 02:01:50 +02001738 if (!mv88e6xxx_max_vid(chip))
1739 return -EOPNOTSUPP;
Vivien Didelot54d77b52016-05-09 13:22:47 -04001740
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001741 mv88e6xxx_reg_lock(chip);
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001742
Vivien Didelot385a0992016-11-04 03:23:31 +01001743 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001744 if (err)
1745 goto unlock;
1746
1747 err = mv88e6xxx_port_commit_pvid(chip, port);
1748 if (err)
1749 goto unlock;
1750
1751unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001752 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001753
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001754 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001755}
1756
Vivien Didelot57d32312016-06-20 13:13:58 -04001757static int
1758mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001759 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001760{
Vivien Didelot04bed142016-08-31 18:06:13 -04001761 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001762 int err;
1763
Tobias Waldekranze545f862020-11-10 19:57:20 +01001764 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001765 return -EOPNOTSUPP;
1766
Vivien Didelotda9c3592016-02-12 12:09:40 -05001767 /* If the requested port doesn't belong to the same bridge as the VLAN
1768 * members, do not support it (yet) and fallback to software VLAN.
1769 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001770 mv88e6xxx_reg_lock(chip);
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001771 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001772 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001773
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001774 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001775}
1776
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001777static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1778 const unsigned char *addr, u16 vid,
1779 u8 state)
1780{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001781 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001782 struct mv88e6xxx_vtu_entry vlan;
1783 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001784 int err;
1785
Vladimir Oltean5bded822021-10-07 19:47:11 +03001786 /* Ports have two private address databases: one for when the port is
1787 * standalone and one for when the port is under a bridge and the
1788 * 802.1Q mode is disabled. When the port is standalone, DSA wants its
1789 * address database to remain 100% empty, so we never load an ATU entry
1790 * into a standalone port's database. Therefore, translate the null
1791 * VLAN ID into the port's database used for VLAN-unaware bridging.
1792 */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001793 if (vid == 0) {
Vladimir Oltean5bded822021-10-07 19:47:11 +03001794 fid = MV88E6XXX_FID_BRIDGED;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001795 } else {
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001796 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001797 if (err)
1798 return err;
1799
1800 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001801 if (!vlan.valid)
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001802 return -EOPNOTSUPP;
1803
1804 fid = vlan.fid;
1805 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001806
Vivien Didelotd8291a92019-09-07 16:00:47 -04001807 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001808 ether_addr_copy(entry.mac, addr);
1809 eth_addr_dec(entry.mac);
1810
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001811 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001812 if (err)
1813 return err;
1814
1815 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001816 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001817 memset(&entry, 0, sizeof(entry));
1818 ether_addr_copy(entry.mac, addr);
1819 }
1820
1821 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001822 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001823 entry.portvec &= ~BIT(port);
1824 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001825 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001826 } else {
DENG Qingfangf72f2fb2021-01-30 21:43:34 +08001827 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
1828 entry.portvec = BIT(port);
1829 else
1830 entry.portvec |= BIT(port);
1831
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001832 entry.state = state;
1833 }
1834
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001835 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001836}
1837
Vivien Didelotda7dc872019-09-07 16:00:49 -04001838static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1839 const struct mv88e6xxx_policy *policy)
1840{
1841 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1842 enum mv88e6xxx_policy_action action = policy->action;
1843 const u8 *addr = policy->addr;
1844 u16 vid = policy->vid;
1845 u8 state;
1846 int err;
1847 int id;
1848
1849 if (!chip->info->ops->port_set_policy)
1850 return -EOPNOTSUPP;
1851
1852 switch (mapping) {
1853 case MV88E6XXX_POLICY_MAPPING_DA:
1854 case MV88E6XXX_POLICY_MAPPING_SA:
1855 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1856 state = 0; /* Dissociate the port and address */
1857 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1858 is_multicast_ether_addr(addr))
1859 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1860 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1861 is_unicast_ether_addr(addr))
1862 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1863 else
1864 return -EOPNOTSUPP;
1865
1866 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1867 state);
1868 if (err)
1869 return err;
1870 break;
1871 default:
1872 return -EOPNOTSUPP;
1873 }
1874
1875 /* Skip the port's policy clearing if the mapping is still in use */
1876 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1877 idr_for_each_entry(&chip->policies, policy, id)
1878 if (policy->port == port &&
1879 policy->mapping == mapping &&
1880 policy->action != action)
1881 return 0;
1882
1883 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1884}
1885
1886static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1887 struct ethtool_rx_flow_spec *fs)
1888{
1889 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1890 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1891 enum mv88e6xxx_policy_mapping mapping;
1892 enum mv88e6xxx_policy_action action;
1893 struct mv88e6xxx_policy *policy;
1894 u16 vid = 0;
1895 u8 *addr;
1896 int err;
1897 int id;
1898
1899 if (fs->location != RX_CLS_LOC_ANY)
1900 return -EINVAL;
1901
1902 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1903 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1904 else
1905 return -EOPNOTSUPP;
1906
1907 switch (fs->flow_type & ~FLOW_EXT) {
1908 case ETHER_FLOW:
1909 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1910 is_zero_ether_addr(mac_mask->h_source)) {
1911 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1912 addr = mac_entry->h_dest;
1913 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1914 !is_zero_ether_addr(mac_mask->h_source)) {
1915 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1916 addr = mac_entry->h_source;
1917 } else {
1918 /* Cannot support DA and SA mapping in the same rule */
1919 return -EOPNOTSUPP;
1920 }
1921 break;
1922 default:
1923 return -EOPNOTSUPP;
1924 }
1925
1926 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001927 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001928 return -EOPNOTSUPP;
1929 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1930 }
1931
1932 idr_for_each_entry(&chip->policies, policy, id) {
1933 if (policy->port == port && policy->mapping == mapping &&
1934 policy->action == action && policy->vid == vid &&
1935 ether_addr_equal(policy->addr, addr))
1936 return -EEXIST;
1937 }
1938
1939 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1940 if (!policy)
1941 return -ENOMEM;
1942
1943 fs->location = 0;
1944 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1945 GFP_KERNEL);
1946 if (err) {
1947 devm_kfree(chip->dev, policy);
1948 return err;
1949 }
1950
1951 memcpy(&policy->fs, fs, sizeof(*fs));
1952 ether_addr_copy(policy->addr, addr);
1953 policy->mapping = mapping;
1954 policy->action = action;
1955 policy->port = port;
1956 policy->vid = vid;
1957
1958 err = mv88e6xxx_policy_apply(chip, port, policy);
1959 if (err) {
1960 idr_remove(&chip->policies, fs->location);
1961 devm_kfree(chip->dev, policy);
1962 return err;
1963 }
1964
1965 return 0;
1966}
1967
1968static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1969 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1970{
1971 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1972 struct mv88e6xxx_chip *chip = ds->priv;
1973 struct mv88e6xxx_policy *policy;
1974 int err;
1975 int id;
1976
1977 mv88e6xxx_reg_lock(chip);
1978
1979 switch (rxnfc->cmd) {
1980 case ETHTOOL_GRXCLSRLCNT:
1981 rxnfc->data = 0;
1982 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1983 rxnfc->rule_cnt = 0;
1984 idr_for_each_entry(&chip->policies, policy, id)
1985 if (policy->port == port)
1986 rxnfc->rule_cnt++;
1987 err = 0;
1988 break;
1989 case ETHTOOL_GRXCLSRULE:
1990 err = -ENOENT;
1991 policy = idr_find(&chip->policies, fs->location);
1992 if (policy) {
1993 memcpy(fs, &policy->fs, sizeof(*fs));
1994 err = 0;
1995 }
1996 break;
1997 case ETHTOOL_GRXCLSRLALL:
1998 rxnfc->data = 0;
1999 rxnfc->rule_cnt = 0;
2000 idr_for_each_entry(&chip->policies, policy, id)
2001 if (policy->port == port)
2002 rule_locs[rxnfc->rule_cnt++] = id;
2003 err = 0;
2004 break;
2005 default:
2006 err = -EOPNOTSUPP;
2007 break;
2008 }
2009
2010 mv88e6xxx_reg_unlock(chip);
2011
2012 return err;
2013}
2014
2015static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
2016 struct ethtool_rxnfc *rxnfc)
2017{
2018 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
2019 struct mv88e6xxx_chip *chip = ds->priv;
2020 struct mv88e6xxx_policy *policy;
2021 int err;
2022
2023 mv88e6xxx_reg_lock(chip);
2024
2025 switch (rxnfc->cmd) {
2026 case ETHTOOL_SRXCLSRLINS:
2027 err = mv88e6xxx_policy_insert(chip, port, fs);
2028 break;
2029 case ETHTOOL_SRXCLSRLDEL:
2030 err = -ENOENT;
2031 policy = idr_remove(&chip->policies, fs->location);
2032 if (policy) {
2033 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
2034 err = mv88e6xxx_policy_apply(chip, port, policy);
2035 devm_kfree(chip->dev, policy);
2036 }
2037 break;
2038 default:
2039 err = -EOPNOTSUPP;
2040 break;
2041 }
2042
2043 mv88e6xxx_reg_unlock(chip);
2044
2045 return err;
2046}
2047
Andrew Lunn87fa8862017-11-09 22:29:56 +01002048static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
2049 u16 vid)
2050{
Andrew Lunn87fa8862017-11-09 22:29:56 +01002051 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
Tobias Waldekranz0806dd462021-03-18 20:25:37 +01002052 u8 broadcast[ETH_ALEN];
2053
2054 eth_broadcast_addr(broadcast);
Andrew Lunn87fa8862017-11-09 22:29:56 +01002055
2056 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
2057}
2058
2059static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
2060{
2061 int port;
2062 int err;
2063
2064 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01002065 struct dsa_port *dp = dsa_to_port(chip->ds, port);
2066 struct net_device *brport;
2067
2068 if (dsa_is_unused_port(chip->ds, port))
2069 continue;
2070
2071 brport = dsa_port_to_bridge_port(dp);
2072 if (brport && !br_port_flag_is_set(brport, BR_BCAST_FLOOD))
2073 /* Skip bridged user ports where broadcast
2074 * flooding is disabled.
2075 */
2076 continue;
2077
Andrew Lunn87fa8862017-11-09 22:29:56 +01002078 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
2079 if (err)
2080 return err;
2081 }
2082
2083 return 0;
2084}
2085
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01002086struct mv88e6xxx_port_broadcast_sync_ctx {
2087 int port;
2088 bool flood;
2089};
2090
2091static int
2092mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip,
2093 const struct mv88e6xxx_vtu_entry *vlan,
2094 void *_ctx)
2095{
2096 struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx;
2097 u8 broadcast[ETH_ALEN];
2098 u8 state;
2099
2100 if (ctx->flood)
2101 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
2102 else
2103 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED;
2104
2105 eth_broadcast_addr(broadcast);
2106
2107 return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast,
2108 vlan->vid, state);
2109}
2110
2111static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port,
2112 bool flood)
2113{
2114 struct mv88e6xxx_port_broadcast_sync_ctx ctx = {
2115 .port = port,
2116 .flood = flood,
2117 };
2118 struct mv88e6xxx_vtu_entry vid0 = {
2119 .vid = 0,
2120 };
2121 int err;
2122
2123 /* Update the port's private database... */
2124 err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx);
2125 if (err)
2126 return err;
2127
2128 /* ...and the database for all VLANs. */
2129 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan,
2130 &ctx);
2131}
2132
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002133static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00002134 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002135{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002136 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002137 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002138 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002139
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002140 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002141 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002142 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002143
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002144 if (!vlan.valid) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002145 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002146
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002147 err = mv88e6xxx_atu_new(chip, &vlan.fid);
2148 if (err)
2149 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01002150
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002151 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
2152 if (i == port)
2153 vlan.member[i] = member;
2154 else
2155 vlan.member[i] = non_member;
2156
2157 vlan.vid = vid;
2158 vlan.valid = true;
2159
2160 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2161 if (err)
2162 return err;
2163
2164 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
2165 if (err)
2166 return err;
2167 } else if (vlan.member[port] != member) {
2168 vlan.member[port] = member;
2169
2170 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2171 if (err)
2172 return err;
Russell King933b4422020-02-26 17:14:26 +00002173 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002174 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
2175 port, vid);
2176 }
2177
2178 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002179}
2180
Vladimir Oltean1958d582021-01-09 02:01:53 +02002181static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vladimir Oltean31046a52021-02-13 22:43:18 +02002182 const struct switchdev_obj_port_vlan *vlan,
2183 struct netlink_ext_ack *extack)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002184{
Vivien Didelot04bed142016-08-31 18:06:13 -04002185 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002186 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
2187 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002188 struct mv88e6xxx_port *p = &chip->ports[port];
Russell King933b4422020-02-26 17:14:26 +00002189 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002190 u8 member;
Vladimir Oltean1958d582021-01-09 02:01:53 +02002191 int err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002192
Eldar Gasanovb8b79c42021-06-21 11:54:38 +03002193 if (!vlan->vid)
2194 return 0;
2195
Vladimir Oltean1958d582021-01-09 02:01:53 +02002196 err = mv88e6xxx_port_vlan_prepare(ds, port, vlan);
2197 if (err)
2198 return err;
Vivien Didelot54d77b52016-05-09 13:22:47 -04002199
Vivien Didelotc91498e2017-06-07 18:12:13 -04002200 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002201 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002202 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002203 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002204 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002205 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002206
Russell King933b4422020-02-26 17:14:26 +00002207 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
2208 * and then the CPU port. Do not warn for duplicates for the CPU port.
2209 */
2210 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
2211
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002212 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002213
Vladimir Oltean1958d582021-01-09 02:01:53 +02002214 err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn);
2215 if (err) {
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002216 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
2217 vlan->vid, untagged ? 'u' : 't');
Vladimir Oltean1958d582021-01-09 02:01:53 +02002218 goto out;
2219 }
Vivien Didelot76e398a2015-11-01 12:33:55 -05002220
Vladimir Oltean1958d582021-01-09 02:01:53 +02002221 if (pvid) {
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002222 p->bridge_pvid.vid = vlan->vid;
2223 p->bridge_pvid.valid = true;
2224
2225 err = mv88e6xxx_port_commit_pvid(chip, port);
2226 if (err)
Vladimir Oltean1958d582021-01-09 02:01:53 +02002227 goto out;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002228 } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) {
2229 /* The old pvid was reinstalled as a non-pvid VLAN */
2230 p->bridge_pvid.valid = false;
2231
2232 err = mv88e6xxx_port_commit_pvid(chip, port);
2233 if (err)
2234 goto out;
Vladimir Oltean1958d582021-01-09 02:01:53 +02002235 }
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002236
Vladimir Oltean1958d582021-01-09 02:01:53 +02002237out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002238 mv88e6xxx_reg_unlock(chip);
Vladimir Oltean1958d582021-01-09 02:01:53 +02002239
2240 return err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002241}
2242
Vivien Didelot521098922019-08-01 14:36:36 -04002243static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2244 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002245{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002246 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002247 int i, err;
2248
Vivien Didelot521098922019-08-01 14:36:36 -04002249 if (!vid)
Vladimir Olteanc92c7412021-07-22 16:05:51 +03002250 return 0;
Vivien Didelot521098922019-08-01 14:36:36 -04002251
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002252 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002253 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002254 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002255
Vivien Didelot521098922019-08-01 14:36:36 -04002256 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2257 * tell switchdev that this VLAN is likely handled in software.
2258 */
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002259 if (!vlan.valid ||
Vivien Didelot521098922019-08-01 14:36:36 -04002260 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002261 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002262
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002263 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002264
2265 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002266 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002267 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002268 if (vlan.member[i] !=
2269 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002270 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002271 break;
2272 }
2273 }
2274
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002275 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002276 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002277 return err;
2278
Vivien Didelote606ca32017-03-11 16:12:55 -05002279 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002280}
2281
Vivien Didelotf81ec902016-05-09 13:22:58 -04002282static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2283 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002284{
Vivien Didelot04bed142016-08-31 18:06:13 -04002285 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002286 struct mv88e6xxx_port *p = &chip->ports[port];
Vivien Didelot76e398a2015-11-01 12:33:55 -05002287 int err = 0;
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002288 u16 pvid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002289
Tobias Waldekranze545f862020-11-10 19:57:20 +01002290 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04002291 return -EOPNOTSUPP;
2292
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002293 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002294
Vivien Didelot77064f32016-11-04 03:23:30 +01002295 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002296 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002297 goto unlock;
2298
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002299 err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid);
2300 if (err)
2301 goto unlock;
2302
2303 if (vlan->vid == pvid) {
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002304 p->bridge_pvid.valid = false;
2305
2306 err = mv88e6xxx_port_commit_pvid(chip, port);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002307 if (err)
2308 goto unlock;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002309 }
2310
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002311unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002312 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002313
2314 return err;
2315}
2316
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002317static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2318 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002319{
Vivien Didelot04bed142016-08-31 18:06:13 -04002320 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002321 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002322
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002323 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002324 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2325 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002326 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002327
2328 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002329}
2330
Vivien Didelotf81ec902016-05-09 13:22:58 -04002331static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002332 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002333{
Vivien Didelot04bed142016-08-31 18:06:13 -04002334 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002335 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002336
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002337 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002338 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002339 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002340
Vivien Didelot83dabd12016-08-31 11:50:04 -04002341 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002342}
2343
Vivien Didelot83dabd12016-08-31 11:50:04 -04002344static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2345 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002346 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002347{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002348 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002349 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002350 int err;
2351
Vivien Didelotd8291a92019-09-07 16:00:47 -04002352 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002353 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002354
2355 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002356 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002357 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002358 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002359
Vivien Didelotd8291a92019-09-07 16:00:47 -04002360 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002361 break;
2362
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002363 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002364 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002365
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002366 if (!is_unicast_ether_addr(addr.mac))
2367 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002368
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002369 is_static = (addr.state ==
2370 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2371 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002372 if (err)
2373 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002374 } while (!is_broadcast_ether_addr(addr.mac));
2375
2376 return err;
2377}
2378
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002379struct mv88e6xxx_port_db_dump_vlan_ctx {
2380 int port;
2381 dsa_fdb_dump_cb_t *cb;
2382 void *data;
2383};
2384
2385static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip,
2386 const struct mv88e6xxx_vtu_entry *entry,
2387 void *_data)
2388{
2389 struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data;
2390
2391 return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid,
2392 ctx->port, ctx->cb, ctx->data);
2393}
2394
Vivien Didelot83dabd12016-08-31 11:50:04 -04002395static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002396 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002397{
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002398 struct mv88e6xxx_port_db_dump_vlan_ctx ctx = {
2399 .port = port,
2400 .cb = cb,
2401 .data = data,
2402 };
Vivien Didelot83dabd12016-08-31 11:50:04 -04002403 u16 fid;
2404 int err;
2405
2406 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002407 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002408 if (err)
2409 return err;
2410
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002411 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002412 if (err)
2413 return err;
2414
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002415 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002416}
2417
Vivien Didelotf81ec902016-05-09 13:22:58 -04002418static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002419 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002420{
Vivien Didelot04bed142016-08-31 18:06:13 -04002421 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002422 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002423
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002424 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002425 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002426 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002427
2428 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002429}
2430
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002431static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2432 struct net_device *br)
2433{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002434 struct dsa_switch *ds = chip->ds;
2435 struct dsa_switch_tree *dst = ds->dst;
2436 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002437 int err;
2438
Vivien Didelotef2025e2019-10-21 16:51:27 -04002439 list_for_each_entry(dp, &dst->ports, list) {
2440 if (dp->bridge_dev == br) {
2441 if (dp->ds == ds) {
2442 /* This is a local bridge group member,
2443 * remap its Port VLAN Map.
2444 */
2445 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2446 if (err)
2447 return err;
2448 } else {
2449 /* This is an external bridge group member,
2450 * remap its cross-chip Port VLAN Table entry.
2451 */
2452 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2453 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002454 if (err)
2455 return err;
2456 }
2457 }
2458 }
2459
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002460 return 0;
2461}
2462
Vivien Didelotf81ec902016-05-09 13:22:58 -04002463static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002464 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002465{
Vivien Didelot04bed142016-08-31 18:06:13 -04002466 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002467 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002468
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002469 mv88e6xxx_reg_lock(chip);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002470
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002471 err = mv88e6xxx_bridge_map(chip, br);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002472 if (err)
2473 goto unlock;
2474
2475 err = mv88e6xxx_port_commit_pvid(chip, port);
2476 if (err)
2477 goto unlock;
2478
2479unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002480 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002481
Vivien Didelot466dfa02016-02-26 13:16:05 -05002482 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002483}
2484
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002485static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2486 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002487{
Vivien Didelot04bed142016-08-31 18:06:13 -04002488 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Oltean5bded822021-10-07 19:47:11 +03002489 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002490
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002491 mv88e6xxx_reg_lock(chip);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002492
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002493 if (mv88e6xxx_bridge_map(chip, br) ||
2494 mv88e6xxx_port_vlan_map(chip, port))
2495 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vladimir Oltean5bded822021-10-07 19:47:11 +03002496
2497 err = mv88e6xxx_port_commit_pvid(chip, port);
2498 if (err)
2499 dev_err(ds->dev,
2500 "port %d failed to restore standalone pvid: %pe\n",
2501 port, ERR_PTR(err));
2502
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002503 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002504}
2505
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002506static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2507 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002508 int port, struct net_device *br)
2509{
2510 struct mv88e6xxx_chip *chip = ds->priv;
2511 int err;
2512
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002513 if (tree_index != ds->dst->index)
2514 return 0;
2515
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002516 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002517 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002518 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002519
2520 return err;
2521}
2522
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002523static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2524 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002525 int port, struct net_device *br)
2526{
2527 struct mv88e6xxx_chip *chip = ds->priv;
2528
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002529 if (tree_index != ds->dst->index)
2530 return;
2531
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002532 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002533 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002534 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002535 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002536}
2537
Vladimir Olteance5df682021-07-22 18:55:41 +03002538/* Treat the software bridge as a virtual single-port switch behind the
2539 * CPU and map in the PVT. First dst->last_switch elements are taken by
2540 * physical switches, so start from beyond that range.
2541 */
2542static int mv88e6xxx_map_virtual_bridge_to_pvt(struct dsa_switch *ds,
2543 int bridge_num)
2544{
2545 u8 dev = bridge_num + ds->dst->last_switch + 1;
2546 struct mv88e6xxx_chip *chip = ds->priv;
2547 int err;
2548
2549 mv88e6xxx_reg_lock(chip);
2550 err = mv88e6xxx_pvt_map(chip, dev, 0);
2551 mv88e6xxx_reg_unlock(chip);
2552
2553 return err;
2554}
2555
2556static int mv88e6xxx_bridge_tx_fwd_offload(struct dsa_switch *ds, int port,
2557 struct net_device *br,
2558 int bridge_num)
2559{
2560 return mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num);
2561}
2562
2563static void mv88e6xxx_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port,
2564 struct net_device *br,
2565 int bridge_num)
2566{
2567 int err;
2568
2569 err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num);
2570 if (err) {
2571 dev_err(ds->dev, "failed to remap cross-chip Port VLAN: %pe\n",
2572 ERR_PTR(err));
2573 }
2574}
2575
Vivien Didelot17e708b2016-12-05 17:30:27 -05002576static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2577{
2578 if (chip->info->ops->reset)
2579 return chip->info->ops->reset(chip);
2580
2581 return 0;
2582}
2583
Vivien Didelot309eca62016-12-05 17:30:26 -05002584static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2585{
2586 struct gpio_desc *gpiod = chip->reset;
2587
2588 /* If there is a GPIO connected to the reset pin, toggle it */
2589 if (gpiod) {
2590 gpiod_set_value_cansleep(gpiod, 1);
2591 usleep_range(10000, 20000);
2592 gpiod_set_value_cansleep(gpiod, 0);
2593 usleep_range(10000, 20000);
Andrew Lunna3dcb3e2020-11-16 08:43:01 -08002594
2595 mv88e6xxx_g1_wait_eeprom_done(chip);
Vivien Didelot309eca62016-12-05 17:30:26 -05002596 }
2597}
2598
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002599static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2600{
2601 int i, err;
2602
2603 /* Set all ports to the Disabled state */
2604 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002605 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002606 if (err)
2607 return err;
2608 }
2609
2610 /* Wait for transmit queues to drain,
2611 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2612 */
2613 usleep_range(2000, 4000);
2614
2615 return 0;
2616}
2617
Vivien Didelotfad09c72016-06-21 12:28:20 -04002618static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002619{
Vivien Didelota935c052016-09-29 12:21:53 -04002620 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002621
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002622 err = mv88e6xxx_disable_ports(chip);
2623 if (err)
2624 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002625
Vivien Didelot309eca62016-12-05 17:30:26 -05002626 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002627
Vivien Didelot17e708b2016-12-05 17:30:27 -05002628 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002629}
2630
Vivien Didelot43145572017-03-11 16:12:59 -05002631static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002632 enum mv88e6xxx_frame_mode frame,
2633 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002634{
2635 int err;
2636
Vivien Didelot43145572017-03-11 16:12:59 -05002637 if (!chip->info->ops->port_set_frame_mode)
2638 return -EOPNOTSUPP;
2639
2640 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002641 if (err)
2642 return err;
2643
Vivien Didelot43145572017-03-11 16:12:59 -05002644 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2645 if (err)
2646 return err;
2647
2648 if (chip->info->ops->port_set_ether_type)
2649 return chip->info->ops->port_set_ether_type(chip, port, etype);
2650
2651 return 0;
2652}
2653
2654static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2655{
2656 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002657 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002658 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002659}
2660
2661static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2662{
2663 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002664 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002665 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002666}
2667
2668static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2669{
2670 return mv88e6xxx_set_port_mode(chip, port,
2671 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002672 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2673 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002674}
2675
2676static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2677{
2678 if (dsa_is_dsa_port(chip->ds, port))
2679 return mv88e6xxx_set_port_mode_dsa(chip, port);
2680
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002681 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002682 return mv88e6xxx_set_port_mode_normal(chip, port);
2683
2684 /* Setup CPU port mode depending on its supported tag format */
Tobias Waldekranz670bb802021-04-20 20:53:07 +02002685 if (chip->tag_protocol == DSA_TAG_PROTO_DSA)
Vivien Didelot43145572017-03-11 16:12:59 -05002686 return mv88e6xxx_set_port_mode_dsa(chip, port);
2687
Tobias Waldekranz670bb802021-04-20 20:53:07 +02002688 if (chip->tag_protocol == DSA_TAG_PROTO_EDSA)
Vivien Didelot43145572017-03-11 16:12:59 -05002689 return mv88e6xxx_set_port_mode_edsa(chip, port);
2690
2691 return -EINVAL;
2692}
2693
Vivien Didelotea698f42017-03-11 16:12:50 -05002694static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2695{
2696 bool message = dsa_is_dsa_port(chip->ds, port);
2697
2698 return mv88e6xxx_port_set_message_port(chip, port, message);
2699}
2700
Vivien Didelot601aeed2017-03-11 16:13:00 -05002701static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2702{
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002703 int err;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002704
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002705 if (chip->info->ops->port_set_ucast_flood) {
Tobias Waldekranz7b9f16f2021-03-18 20:25:38 +01002706 err = chip->info->ops->port_set_ucast_flood(chip, port, true);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002707 if (err)
2708 return err;
2709 }
2710 if (chip->info->ops->port_set_mcast_flood) {
Tobias Waldekranz7b9f16f2021-03-18 20:25:38 +01002711 err = chip->info->ops->port_set_mcast_flood(chip, port, true);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002712 if (err)
2713 return err;
2714 }
Vivien Didelot601aeed2017-03-11 16:13:00 -05002715
David S. Miller407308f2019-06-15 13:35:29 -07002716 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002717}
2718
Vivien Didelot45de77f2019-08-31 16:18:36 -04002719static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2720{
2721 struct mv88e6xxx_port *mvp = dev_id;
2722 struct mv88e6xxx_chip *chip = mvp->chip;
2723 irqreturn_t ret = IRQ_NONE;
2724 int port = mvp->port;
Pavana Sharma193c5b22021-03-17 14:46:40 +01002725 int lane;
Vivien Didelot45de77f2019-08-31 16:18:36 -04002726
2727 mv88e6xxx_reg_lock(chip);
2728 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +01002729 if (lane >= 0)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002730 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2731 mv88e6xxx_reg_unlock(chip);
2732
2733 return ret;
2734}
2735
2736static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
Pavana Sharma193c5b22021-03-17 14:46:40 +01002737 int lane)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002738{
2739 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2740 unsigned int irq;
2741 int err;
2742
2743 /* Nothing to request if this SERDES port has no IRQ */
2744 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2745 if (!irq)
2746 return 0;
2747
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002748 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2749 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2750
Vivien Didelot45de77f2019-08-31 16:18:36 -04002751 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2752 mv88e6xxx_reg_unlock(chip);
2753 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002754 IRQF_ONESHOT, dev_id->serdes_irq_name,
2755 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002756 mv88e6xxx_reg_lock(chip);
2757 if (err)
2758 return err;
2759
2760 dev_id->serdes_irq = irq;
2761
2762 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2763}
2764
2765static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
Pavana Sharma193c5b22021-03-17 14:46:40 +01002766 int lane)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002767{
2768 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2769 unsigned int irq = dev_id->serdes_irq;
2770 int err;
2771
2772 /* Nothing to free if no IRQ has been requested */
2773 if (!irq)
2774 return 0;
2775
2776 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2777
2778 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2779 mv88e6xxx_reg_unlock(chip);
2780 free_irq(irq, dev_id);
2781 mv88e6xxx_reg_lock(chip);
2782
2783 dev_id->serdes_irq = 0;
2784
2785 return err;
2786}
2787
Andrew Lunn6d917822017-05-26 01:03:21 +02002788static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2789 bool on)
2790{
Pavana Sharma193c5b22021-03-17 14:46:40 +01002791 int lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002792 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002793
Vivien Didelotdc272f62019-08-31 16:18:33 -04002794 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +01002795 if (lane < 0)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002796 return 0;
2797
2798 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002799 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002800 if (err)
2801 return err;
2802
Vivien Didelot45de77f2019-08-31 16:18:36 -04002803 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002804 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002805 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2806 if (err)
2807 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002808
Vivien Didelotdc272f62019-08-31 16:18:33 -04002809 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002810 }
2811
2812 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002813}
2814
Marek Behún2fda45f2021-03-17 14:46:41 +01002815static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip,
2816 enum mv88e6xxx_egress_direction direction,
2817 int port)
2818{
2819 int err;
2820
2821 if (!chip->info->ops->set_egress_port)
2822 return -EOPNOTSUPP;
2823
2824 err = chip->info->ops->set_egress_port(chip, direction, port);
2825 if (err)
2826 return err;
2827
2828 if (direction == MV88E6XXX_EGRESS_DIR_INGRESS)
2829 chip->ingress_dest_port = port;
2830 else
2831 chip->egress_dest_port = port;
2832
2833 return 0;
2834}
2835
Vivien Didelotfa371c82017-12-05 15:34:10 -05002836static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2837{
2838 struct dsa_switch *ds = chip->ds;
2839 int upstream_port;
2840 int err;
2841
Vivien Didelot07073c72017-12-05 15:34:13 -05002842 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002843 if (chip->info->ops->port_set_upstream_port) {
2844 err = chip->info->ops->port_set_upstream_port(chip, port,
2845 upstream_port);
2846 if (err)
2847 return err;
2848 }
2849
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002850 if (port == upstream_port) {
2851 if (chip->info->ops->set_cpu_port) {
2852 err = chip->info->ops->set_cpu_port(chip,
2853 upstream_port);
2854 if (err)
2855 return err;
2856 }
2857
Marek Behún2fda45f2021-03-17 14:46:41 +01002858 err = mv88e6xxx_set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002859 MV88E6XXX_EGRESS_DIR_INGRESS,
2860 upstream_port);
Marek Behún2fda45f2021-03-17 14:46:41 +01002861 if (err && err != -EOPNOTSUPP)
2862 return err;
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002863
Marek Behún2fda45f2021-03-17 14:46:41 +01002864 err = mv88e6xxx_set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002865 MV88E6XXX_EGRESS_DIR_EGRESS,
2866 upstream_port);
Marek Behún2fda45f2021-03-17 14:46:41 +01002867 if (err && err != -EOPNOTSUPP)
2868 return err;
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002869 }
2870
Vivien Didelotfa371c82017-12-05 15:34:10 -05002871 return 0;
2872}
2873
Vivien Didelotfad09c72016-06-21 12:28:20 -04002874static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002875{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002876 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002877 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002878 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002879
Andrew Lunn7b898462018-08-09 15:38:47 +02002880 chip->ports[port].chip = chip;
2881 chip->ports[port].port = port;
2882
Vivien Didelotd78343d2016-11-04 03:23:36 +01002883 /* MAC Forcing register: don't force link, speed, duplex or flow control
2884 * state to any particular values on physical ports, but force the CPU
2885 * port and all DSA ports to their maximum bandwidth and full duplex.
2886 */
2887 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2888 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2889 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002890 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002891 PHY_INTERFACE_MODE_NA);
2892 else
2893 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2894 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002895 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002896 PHY_INTERFACE_MODE_NA);
2897 if (err)
2898 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002899
2900 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2901 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2902 * tunneling, determine priority by looking at 802.1p and IP
2903 * priority fields (IP prio has precedence), and set STP state
2904 * to Forwarding.
2905 *
2906 * If this is the CPU link, use DSA or EDSA tagging depending
2907 * on which tagging mode was configured.
2908 *
2909 * If this is a link to another switch, use DSA tagging mode.
2910 *
2911 * If this is the upstream port for this switch, enable
2912 * forwarding of unknown unicasts and multicasts.
2913 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002914 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2915 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2916 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2917 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002918 if (err)
2919 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002920
Vivien Didelot601aeed2017-03-11 16:13:00 -05002921 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002922 if (err)
2923 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002924
Vivien Didelot601aeed2017-03-11 16:13:00 -05002925 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002926 if (err)
2927 return err;
2928
Andrew Lunnb92ce2f2021-09-26 19:41:25 +02002929 /* Port Control 2: don't force a good FCS, set the MTU size to
2930 * 10222 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002931 * untagged frames on this port, do a destination address lookup on all
2932 * received packets as usual, disable ARP mirroring and don't send a
2933 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002934 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002935 err = mv88e6xxx_port_set_map_da(chip, port);
2936 if (err)
2937 return err;
2938
Vivien Didelotfa371c82017-12-05 15:34:10 -05002939 err = mv88e6xxx_setup_upstream_port(chip, port);
2940 if (err)
2941 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002942
Andrew Lunna23b2962017-02-04 20:15:28 +01002943 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002944 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002945 if (err)
2946 return err;
2947
Vladimir Oltean5bded822021-10-07 19:47:11 +03002948 /* Associate MV88E6XXX_VID_BRIDGED with MV88E6XXX_FID_BRIDGED in the
2949 * ATU by virtue of the fact that mv88e6xxx_atu_new() will pick it as
2950 * the first free FID after MV88E6XXX_FID_STANDALONE. This will be used
2951 * as the private PVID on ports under a VLAN-unaware bridge.
2952 * Shared (DSA and CPU) ports must also be members of it, to translate
2953 * the VID from the DSA tag into MV88E6XXX_FID_BRIDGED, instead of
2954 * relying on their port default FID.
2955 */
2956 err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_BRIDGED,
2957 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED,
2958 false);
2959 if (err)
2960 return err;
2961
Vivien Didelotcd782652017-06-08 18:34:13 -04002962 if (chip->info->ops->port_set_jumbo_size) {
Andrew Lunnb92ce2f2021-09-26 19:41:25 +02002963 err = chip->info->ops->port_set_jumbo_size(chip, port, 10218);
Andrew Lunn5f436662016-12-03 04:45:17 +01002964 if (err)
2965 return err;
2966 }
2967
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002968 /* Port Association Vector: disable automatic address learning
2969 * on all user ports since they start out in standalone
2970 * mode. When joining a bridge, learning will be configured to
2971 * match the bridge port settings. Enable learning on all
2972 * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the
2973 * learning process.
2974 *
2975 * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData,
2976 * and RefreshLocked. I.e. setup standard automatic learning.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002977 */
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002978 if (dsa_is_user_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002979 reg = 0;
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002980 else
2981 reg = 1 << port;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002982
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002983 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2984 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002985 if (err)
2986 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002987
2988 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002989 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2990 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002991 if (err)
2992 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002993
Vivien Didelot08984322017-06-08 18:34:12 -04002994 if (chip->info->ops->port_pause_limit) {
2995 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002996 if (err)
2997 return err;
2998 }
2999
Vivien Didelotc8c94892017-03-11 16:13:01 -05003000 if (chip->info->ops->port_disable_learn_limit) {
3001 err = chip->info->ops->port_disable_learn_limit(chip, port);
3002 if (err)
3003 return err;
3004 }
3005
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003006 if (chip->info->ops->port_disable_pri_override) {
3007 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003008 if (err)
3009 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01003010 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003011
Andrew Lunnef0a7312016-12-03 04:35:16 +01003012 if (chip->info->ops->port_tag_remap) {
3013 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003014 if (err)
3015 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003016 }
3017
Andrew Lunnef70b112016-12-03 04:45:18 +01003018 if (chip->info->ops->port_egress_rate_limiting) {
3019 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003020 if (err)
3021 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003022 }
3023
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003024 if (chip->info->ops->port_setup_message_port) {
3025 err = chip->info->ops->port_setup_message_port(chip, port);
3026 if (err)
3027 return err;
3028 }
Guenter Roeckd827e882015-03-26 18:36:29 -07003029
Vivien Didelot207afda2016-04-14 14:42:09 -04003030 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05003031 * database, and allow bidirectional communication between the
3032 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07003033 */
Vladimir Oltean5bded822021-10-07 19:47:11 +03003034 err = mv88e6xxx_port_set_fid(chip, port, MV88E6XXX_FID_STANDALONE);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003035 if (err)
3036 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05003037
Vivien Didelot240ea3e2017-03-30 17:37:12 -04003038 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003039 if (err)
3040 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07003041
3042 /* Default VLAN ID and priority: don't set a default VLAN
3043 * ID, and set the default packet priority to zero.
3044 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04003045 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02003046}
3047
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003048static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
3049{
3050 struct mv88e6xxx_chip *chip = ds->priv;
3051
3052 if (chip->info->ops->port_set_jumbo_size)
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003053 return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
Chris Packham1baf0fa2020-07-24 11:21:22 +12003054 else if (chip->info->ops->set_max_frame_size)
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003055 return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
3056 return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003057}
3058
3059static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
3060{
3061 struct mv88e6xxx_chip *chip = ds->priv;
3062 int ret = 0;
3063
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003064 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
3065 new_mtu += EDSA_HLEN;
3066
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003067 mv88e6xxx_reg_lock(chip);
3068 if (chip->info->ops->port_set_jumbo_size)
3069 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Chris Packham1baf0fa2020-07-24 11:21:22 +12003070 else if (chip->info->ops->set_max_frame_size)
3071 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003072 else
3073 if (new_mtu > 1522)
3074 ret = -EINVAL;
3075 mv88e6xxx_reg_unlock(chip);
3076
3077 return ret;
3078}
3079
Andrew Lunn04aca992017-05-26 01:03:24 +02003080static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
3081 struct phy_device *phydev)
3082{
3083 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04003084 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02003085
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003086 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04003087 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003088 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02003089
3090 return err;
3091}
3092
Andrew Lunn75104db2019-02-24 20:44:43 +01003093static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02003094{
3095 struct mv88e6xxx_chip *chip = ds->priv;
3096
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003097 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04003098 if (mv88e6xxx_serdes_power(chip, port, false))
3099 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003100 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02003101}
3102
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003103static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
3104 unsigned int ageing_time)
3105{
Vivien Didelot04bed142016-08-31 18:06:13 -04003106 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003107 int err;
3108
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003109 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05003110 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003111 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003112
3113 return err;
3114}
3115
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003116static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04003117{
3118 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04003119
Andrew Lunnde2273872016-11-21 23:27:01 +01003120 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003121 if (chip->info->ops->stats_set_histogram) {
3122 err = chip->info->ops->stats_set_histogram(chip);
3123 if (err)
3124 return err;
3125 }
Andrew Lunnde2273872016-11-21 23:27:01 +01003126
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003127 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04003128}
3129
Andrew Lunnea890982019-01-09 00:24:03 +01003130/* Check if the errata has already been applied. */
3131static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
3132{
3133 int port;
3134 int err;
3135 u16 val;
3136
3137 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02003138 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01003139 if (err) {
3140 dev_err(chip->dev,
3141 "Error reading hidden register: %d\n", err);
3142 return false;
3143 }
3144 if (val != 0x01c0)
3145 return false;
3146 }
3147
3148 return true;
3149}
3150
3151/* The 6390 copper ports have an errata which require poking magic
3152 * values into undocumented hidden registers and then performing a
3153 * software reset.
3154 */
3155static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
3156{
3157 int port;
3158 int err;
3159
3160 if (mv88e6390_setup_errata_applied(chip))
3161 return 0;
3162
3163 /* Set the ports into blocking mode */
3164 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
3165 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
3166 if (err)
3167 return err;
3168 }
3169
3170 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02003171 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01003172 if (err)
3173 return err;
3174 }
3175
3176 return mv88e6xxx_software_reset(chip);
3177}
3178
Andrew Lunn23e8b472019-10-25 01:03:52 +02003179static void mv88e6xxx_teardown(struct dsa_switch *ds)
3180{
3181 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003182 dsa_devlink_resources_unregister(ds);
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003183 mv88e6xxx_teardown_devlink_regions_global(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02003184}
3185
Vivien Didelotf81ec902016-05-09 13:22:58 -04003186static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07003187{
Vivien Didelot04bed142016-08-31 18:06:13 -04003188 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003189 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04003190 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04003191 int i;
3192
Vivien Didelotfad09c72016-06-21 12:28:20 -04003193 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003194 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003195
Vladimir Olteance5df682021-07-22 18:55:41 +03003196 /* Since virtual bridges are mapped in the PVT, the number we support
3197 * depends on the physical switch topology. We need to let DSA figure
3198 * that out and therefore we cannot set this at dsa_register_switch()
3199 * time.
3200 */
3201 if (mv88e6xxx_has_pvt(chip))
3202 ds->num_fwd_offloading_bridges = MV88E6XXX_MAX_PVT_SWITCHES -
3203 ds->dst->last_switch - 1;
3204
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003205 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003206
Andrew Lunnea890982019-01-09 00:24:03 +01003207 if (chip->info->ops->setup_errata) {
3208 err = chip->info->ops->setup_errata(chip);
3209 if (err)
3210 goto unlock;
3211 }
3212
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003213 /* Cache the cmode of each port. */
3214 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3215 if (chip->info->ops->port_get_cmode) {
3216 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3217 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003218 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003219
3220 chip->ports[i].cmode = cmode;
3221 }
3222 }
3223
Vladimir Oltean5bded822021-10-07 19:47:11 +03003224 err = mv88e6xxx_vtu_setup(chip);
3225 if (err)
3226 goto unlock;
3227
Vivien Didelot97299342016-07-18 20:45:30 -04003228 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003229 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003230 if (dsa_is_unused_port(ds, i))
3231 continue;
3232
Hubert Feursteinc8574862019-07-31 10:23:48 +02003233 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003234 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003235 dev_err(chip->dev, "port %d is invalid\n", i);
3236 err = -EINVAL;
3237 goto unlock;
3238 }
3239
Vivien Didelot97299342016-07-18 20:45:30 -04003240 err = mv88e6xxx_setup_port(chip, i);
3241 if (err)
3242 goto unlock;
3243 }
3244
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003245 err = mv88e6xxx_irl_setup(chip);
3246 if (err)
3247 goto unlock;
3248
Vivien Didelot04a69a12017-10-13 14:18:05 -04003249 err = mv88e6xxx_mac_setup(chip);
3250 if (err)
3251 goto unlock;
3252
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003253 err = mv88e6xxx_phy_setup(chip);
3254 if (err)
3255 goto unlock;
3256
Vivien Didelot81228992017-03-30 17:37:08 -04003257 err = mv88e6xxx_pvt_setup(chip);
3258 if (err)
3259 goto unlock;
3260
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003261 err = mv88e6xxx_atu_setup(chip);
3262 if (err)
3263 goto unlock;
3264
Andrew Lunn87fa8862017-11-09 22:29:56 +01003265 err = mv88e6xxx_broadcast_setup(chip, 0);
3266 if (err)
3267 goto unlock;
3268
Vivien Didelot9e907d72017-07-17 13:03:43 -04003269 err = mv88e6xxx_pot_setup(chip);
3270 if (err)
3271 goto unlock;
3272
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003273 err = mv88e6xxx_rmu_setup(chip);
3274 if (err)
3275 goto unlock;
3276
Vivien Didelot51c901a2017-07-17 13:03:41 -04003277 err = mv88e6xxx_rsvd2cpu_setup(chip);
3278 if (err)
3279 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003280
Vivien Didelotb28f8722018-04-26 21:56:44 -04003281 err = mv88e6xxx_trunk_setup(chip);
3282 if (err)
3283 goto unlock;
3284
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003285 err = mv88e6xxx_devmap_setup(chip);
3286 if (err)
3287 goto unlock;
3288
Vivien Didelot93e18d62018-05-11 17:16:35 -04003289 err = mv88e6xxx_pri_setup(chip);
3290 if (err)
3291 goto unlock;
3292
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003293 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003294 if (chip->info->ptp_support) {
3295 err = mv88e6xxx_ptp_setup(chip);
3296 if (err)
3297 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003298
3299 err = mv88e6xxx_hwtstamp_setup(chip);
3300 if (err)
3301 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003302 }
3303
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003304 err = mv88e6xxx_stats_setup(chip);
3305 if (err)
3306 goto unlock;
3307
Vivien Didelot6b17e862015-08-13 12:52:18 -04003308unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003309 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003310
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003311 if (err)
3312 return err;
3313
3314 /* Have to be called without holding the register lock, since
3315 * they take the devlink lock, and we later take the locks in
3316 * the reverse order when getting/setting parameters or
3317 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003318 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003319 err = mv88e6xxx_setup_devlink_resources(ds);
3320 if (err)
3321 return err;
3322
3323 err = mv88e6xxx_setup_devlink_params(ds);
3324 if (err)
Andrew Lunnbfb25542020-09-18 21:11:07 +02003325 goto out_resources;
3326
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003327 err = mv88e6xxx_setup_devlink_regions_global(ds);
Andrew Lunnbfb25542020-09-18 21:11:07 +02003328 if (err)
3329 goto out_params;
3330
3331 return 0;
3332
3333out_params:
3334 mv88e6xxx_teardown_devlink_params(ds);
3335out_resources:
3336 dsa_devlink_resources_unregister(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003337
3338 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003339}
3340
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003341static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port)
3342{
3343 return mv88e6xxx_setup_devlink_regions_port(ds, port);
3344}
3345
3346static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port)
3347{
3348 mv88e6xxx_teardown_devlink_regions_port(ds, port);
3349}
3350
Pali Rohár1fe976d2021-04-12 18:57:39 +02003351/* prod_id for switch families which do not have a PHY model number */
3352static const u16 family_prod_id_table[] = {
3353 [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
3354 [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Marek Behúnc5d015b2021-04-20 09:54:02 +02003355 [MV88E6XXX_FAMILY_6393] = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
Pali Rohár1fe976d2021-04-12 18:57:39 +02003356};
3357
Vivien Didelote57e5e72016-08-15 17:19:00 -04003358static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003359{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003360 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3361 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Pali Rohár1fe976d2021-04-12 18:57:39 +02003362 u16 prod_id;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003363 u16 val;
3364 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003365
Andrew Lunnee26a222017-01-24 14:53:48 +01003366 if (!chip->info->ops->phy_read)
3367 return -EOPNOTSUPP;
3368
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003369 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003370 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003371 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003372
Pali Rohár1fe976d2021-04-12 18:57:39 +02003373 /* Some internal PHYs don't have a model number. */
3374 if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
3375 chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
3376 prod_id = family_prod_id_table[chip->info->family];
3377 if (prod_id)
3378 val |= prod_id >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003379 }
3380
Vivien Didelote57e5e72016-08-15 17:19:00 -04003381 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003382}
3383
Vivien Didelote57e5e72016-08-15 17:19:00 -04003384static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003385{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003386 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3387 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003388 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003389
Andrew Lunnee26a222017-01-24 14:53:48 +01003390 if (!chip->info->ops->phy_write)
3391 return -EOPNOTSUPP;
3392
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003393 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003394 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003395 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003396
3397 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003398}
3399
Vivien Didelotfad09c72016-06-21 12:28:20 -04003400static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003401 struct device_node *np,
3402 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003403{
3404 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003405 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003406 struct mii_bus *bus;
3407 int err;
3408
Andrew Lunn2510bab2018-02-22 01:51:49 +01003409 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003410 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003411 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003412 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003413
3414 if (err)
3415 return err;
3416 }
3417
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003418 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003419 if (!bus)
3420 return -ENOMEM;
3421
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003422 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003423 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003424 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003425 INIT_LIST_HEAD(&mdio_bus->list);
3426 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003427
Andrew Lunnb516d452016-06-04 21:17:06 +02003428 if (np) {
3429 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003430 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003431 } else {
3432 bus->name = "mv88e6xxx SMI";
3433 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3434 }
3435
3436 bus->read = mv88e6xxx_mdio_read;
3437 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003438 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003439
Andrew Lunn6f882842018-03-17 20:32:05 +01003440 if (!external) {
3441 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3442 if (err)
3443 return err;
3444 }
3445
Florian Fainelli00e798c2018-05-15 16:56:19 -07003446 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003447 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003448 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003449 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003450 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003451 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003452
3453 if (external)
3454 list_add_tail(&mdio_bus->list, &chip->mdios);
3455 else
3456 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003457
3458 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003459}
3460
Andrew Lunn3126aee2017-12-07 01:05:57 +01003461static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3462
3463{
3464 struct mv88e6xxx_mdio_bus *mdio_bus;
3465 struct mii_bus *bus;
3466
3467 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3468 bus = mdio_bus->bus;
3469
Andrew Lunn6f882842018-03-17 20:32:05 +01003470 if (!mdio_bus->external)
3471 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3472
Andrew Lunn3126aee2017-12-07 01:05:57 +01003473 mdiobus_unregister(bus);
3474 }
3475}
3476
Andrew Lunna3c53be52017-01-24 14:53:50 +01003477static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3478 struct device_node *np)
3479{
Andrew Lunna3c53be52017-01-24 14:53:50 +01003480 struct device_node *child;
3481 int err;
3482
3483 /* Always register one mdio bus for the internal/default mdio
3484 * bus. This maybe represented in the device tree, but is
3485 * optional.
3486 */
3487 child = of_get_child_by_name(np, "mdio");
3488 err = mv88e6xxx_mdio_register(chip, child, false);
3489 if (err)
3490 return err;
3491
3492 /* Walk the device tree, and see if there are any other nodes
3493 * which say they are compatible with the external mdio
3494 * bus.
3495 */
3496 for_each_available_child_of_node(np, child) {
Andrew Lunnceb96fa2020-09-01 04:32:57 +02003497 if (of_device_is_compatible(
3498 child, "marvell,mv88e6xxx-mdio-external")) {
Andrew Lunna3c53be52017-01-24 14:53:50 +01003499 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003500 if (err) {
3501 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303502 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003503 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003504 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003505 }
3506 }
3507
3508 return 0;
3509}
3510
Vivien Didelot855b1932016-07-20 18:18:35 -04003511static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3512{
Vivien Didelot04bed142016-08-31 18:06:13 -04003513 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003514
3515 return chip->eeprom_len;
3516}
3517
Vivien Didelot855b1932016-07-20 18:18:35 -04003518static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3519 struct ethtool_eeprom *eeprom, u8 *data)
3520{
Vivien Didelot04bed142016-08-31 18:06:13 -04003521 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003522 int err;
3523
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003524 if (!chip->info->ops->get_eeprom)
3525 return -EOPNOTSUPP;
3526
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003527 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003528 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003529 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003530
3531 if (err)
3532 return err;
3533
3534 eeprom->magic = 0xc3ec4951;
3535
3536 return 0;
3537}
3538
Vivien Didelot855b1932016-07-20 18:18:35 -04003539static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3540 struct ethtool_eeprom *eeprom, u8 *data)
3541{
Vivien Didelot04bed142016-08-31 18:06:13 -04003542 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003543 int err;
3544
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003545 if (!chip->info->ops->set_eeprom)
3546 return -EOPNOTSUPP;
3547
Vivien Didelot855b1932016-07-20 18:18:35 -04003548 if (eeprom->magic != 0xc3ec4951)
3549 return -EINVAL;
3550
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003551 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003552 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003553 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003554
3555 return err;
3556}
3557
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003558static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003559 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003560 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3561 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003562 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003563 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003564 .phy_read = mv88e6185_phy_ppu_read,
3565 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003566 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003567 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003568 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003569 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003570 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003571 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3572 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003573 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003574 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003575 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003576 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003577 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003578 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003579 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003580 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003581 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003582 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3583 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003584 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003585 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3586 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003587 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003588 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003589 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003590 .ppu_enable = mv88e6185_g1_ppu_enable,
3591 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003592 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003593 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003594 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003595 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003596 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003597 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003598};
3599
3600static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003601 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003602 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3603 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003604 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003605 .phy_read = mv88e6185_phy_ppu_read,
3606 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003607 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003608 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003609 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003610 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003611 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3612 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunna23b2962017-02-04 20:15:28 +01003613 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003614 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003615 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003616 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003617 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003618 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3619 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003620 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003621 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003622 .serdes_power = mv88e6185_serdes_power,
3623 .serdes_get_lane = mv88e6185_serdes_get_lane,
3624 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003625 .ppu_enable = mv88e6185_g1_ppu_enable,
3626 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003627 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003628 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003629 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003630 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003631 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003632};
3633
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003634static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003635 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003636 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3637 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003638 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003639 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3640 .phy_read = mv88e6xxx_g2_smi_phy_read,
3641 .phy_write = mv88e6xxx_g2_smi_phy_write,
3642 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003643 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003644 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003645 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003646 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003647 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3648 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003649 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003650 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003651 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003652 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003653 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003654 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003655 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003656 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003657 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003658 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3659 .stats_get_strings = mv88e6095_stats_get_strings,
3660 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003661 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3662 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003663 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003664 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003665 .serdes_power = mv88e6185_serdes_power,
3666 .serdes_get_lane = mv88e6185_serdes_get_lane,
3667 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Chris Packham5c19bc82020-11-24 17:34:39 +13003668 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
3669 .serdes_irq_enable = mv88e6097_serdes_irq_enable,
3670 .serdes_irq_status = mv88e6097_serdes_irq_status,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003671 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003672 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003673 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003674 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003675 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003676 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003677 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003678};
3679
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003680static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003681 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003682 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3683 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003684 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003685 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003686 .phy_read = mv88e6xxx_g2_smi_phy_read,
3687 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003688 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003689 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003690 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003691 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003692 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3693 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003694 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003695 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003696 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003697 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003698 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003699 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003700 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3701 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003702 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003703 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3704 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003705 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003706 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003707 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003708 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003709 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3710 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003711 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003712 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003713 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003714 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003715};
3716
3717static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003718 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003719 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3720 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003721 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003722 .phy_read = mv88e6185_phy_ppu_read,
3723 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003724 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003725 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003726 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003727 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003728 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003729 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3730 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003731 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003732 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003733 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003734 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003735 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003736 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003737 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003738 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003739 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003740 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003741 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3742 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003743 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003744 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3745 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003746 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003747 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003748 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003749 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003750 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003751 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003752 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003753 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003754 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003755};
3756
Vivien Didelot990e27b2017-03-28 13:50:32 -04003757static const struct mv88e6xxx_ops mv88e6141_ops = {
3758 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003759 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3760 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003761 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003762 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3763 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3764 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3765 .phy_read = mv88e6xxx_g2_smi_phy_read,
3766 .phy_write = mv88e6xxx_g2_smi_phy_write,
3767 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003768 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003769 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003770 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003771 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003772 .port_tag_remap = mv88e6095_port_tag_remap,
Marek Behún7da467d2021-07-01 00:22:26 +02003773 .port_set_policy = mv88e6352_port_set_policy,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003774 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003775 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3776 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003777 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003778 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003779 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003780 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003781 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3782 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003783 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003784 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003785 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003786 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Marek Behún11527f32021-07-01 00:22:27 +02003787 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003788 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3789 .stats_get_strings = mv88e6320_stats_get_strings,
3790 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003791 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3792 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003793 .watchdog_ops = &mv88e6390_watchdog_ops,
3794 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003795 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003796 .reset = mv88e6352_g1_reset,
Marek Behún37094882021-07-01 00:22:28 +02003797 .rmu_disable = mv88e6390_g1_rmu_disable,
Marek Behúnc07fff32021-07-01 00:22:29 +02003798 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3799 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003800 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003801 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003802 .serdes_power = mv88e6390_serdes_power,
3803 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003804 /* Check status register pause & lpa register */
3805 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3806 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3807 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3808 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003809 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003810 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003811 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003812 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúna03b98d2021-07-01 00:22:30 +02003813 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
3814 .serdes_get_strings = mv88e6390_serdes_get_strings,
3815 .serdes_get_stats = mv88e6390_serdes_get_stats,
Marek Behún953b0dc2021-07-01 00:22:31 +02003816 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3817 .serdes_get_regs = mv88e6390_serdes_get_regs,
Marek Behúne3af71a2019-02-25 12:39:55 +01003818 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003819};
3820
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003821static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003822 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003823 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3824 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003825 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003826 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003827 .phy_read = mv88e6xxx_g2_smi_phy_read,
3828 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003829 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003830 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003831 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003832 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003833 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003834 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3835 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003836 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003837 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003838 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003839 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003840 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003841 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003842 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003843 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003844 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003845 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3846 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003847 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003848 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3849 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003850 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003851 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003852 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003853 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003854 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3855 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003856 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003857 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003858 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003859 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003860 .phylink_validate = mv88e6185_phylink_validate,
Andrew Lunnfe230362021-09-26 19:41:24 +02003861 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003862};
3863
3864static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003865 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003866 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3867 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003868 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003869 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003870 .phy_read = mv88e6165_phy_read,
3871 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003872 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003873 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003874 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003875 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003876 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003877 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003878 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003879 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003880 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003881 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3882 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003883 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003884 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3885 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003886 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003887 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003888 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003889 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003890 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3891 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003892 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003893 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003894 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003895 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003896 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003897};
3898
3899static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003900 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003901 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3902 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003903 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003904 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003905 .phy_read = mv88e6xxx_g2_smi_phy_read,
3906 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003907 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003908 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003909 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003910 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003911 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003912 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003913 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3914 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003915 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003916 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003917 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003918 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003919 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003920 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003921 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003922 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003923 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003924 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003925 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3926 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003927 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003928 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3929 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003930 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003931 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003932 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003933 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003934 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3935 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003936 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003937 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003938 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003939};
3940
3941static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003942 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003943 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3944 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003945 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003946 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3947 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003948 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003949 .phy_read = mv88e6xxx_g2_smi_phy_read,
3950 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003951 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003952 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003953 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003954 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003955 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003956 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003957 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003958 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3959 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003960 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003961 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003962 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003963 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003964 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003965 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003966 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003967 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003968 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003969 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003970 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3971 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003972 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003973 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3974 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003975 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003976 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003977 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003978 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003979 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003980 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3981 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003982 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003983 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003984 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003985 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3986 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3987 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3988 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003989 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003990 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3991 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003992 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003993 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003994};
3995
3996static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003997 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003998 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3999 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004000 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004001 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004002 .phy_read = mv88e6xxx_g2_smi_phy_read,
4003 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004004 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004005 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004006 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004007 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004008 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004009 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004010 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4011 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004012 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004013 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004014 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004015 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004016 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004017 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004018 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004019 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004020 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004021 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004022 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4023 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004024 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004025 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4026 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004027 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004028 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004029 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004030 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004031 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4032 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004033 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004034 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004035 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004036};
4037
4038static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004039 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004040 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4041 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004042 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004043 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4044 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004045 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004046 .phy_read = mv88e6xxx_g2_smi_phy_read,
4047 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004048 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004049 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004050 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004051 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004052 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004053 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004054 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004055 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4056 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004057 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004058 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004059 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004060 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004061 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004062 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004063 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004064 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004065 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004066 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004067 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4068 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004069 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004070 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4071 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004072 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004073 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004074 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004075 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004076 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004077 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4078 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004079 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004080 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004081 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004082 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4083 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4084 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4085 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004086 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004087 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004088 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004089 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004090 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4091 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004092 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004093 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004094};
4095
4096static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004097 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004098 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4099 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004100 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04004101 .phy_read = mv88e6185_phy_ppu_read,
4102 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004103 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004104 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004105 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004106 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004107 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
4108 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunnef70b112016-12-03 04:45:18 +01004109 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01004110 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02004111 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004112 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004113 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004114 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004115 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004116 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4117 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004118 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004119 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4120 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004121 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004122 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13004123 .serdes_power = mv88e6185_serdes_power,
4124 .serdes_get_lane = mv88e6185_serdes_get_lane,
4125 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelot02317e62018-05-09 11:38:49 -04004126 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05004127 .ppu_enable = mv88e6185_g1_ppu_enable,
4128 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004129 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004130 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004131 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004132 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12004133 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004134};
4135
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004136static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004137 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004138 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004139 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004140 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4141 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004142 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4143 .phy_read = mv88e6xxx_g2_smi_phy_read,
4144 .phy_write = mv88e6xxx_g2_smi_phy_write,
4145 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004146 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004147 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004148 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004149 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004150 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004151 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004152 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004153 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4154 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004155 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12004156 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04004157 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004158 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004159 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004160 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004161 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004162 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004163 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004164 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004165 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4166 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004167 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004168 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4169 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004170 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004171 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004172 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004173 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004174 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004175 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4176 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004177 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4178 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004179 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004180 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004181 /* Check status register pause & lpa register */
4182 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4183 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4184 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4185 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004186 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004187 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004188 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004189 .serdes_get_strings = mv88e6390_serdes_get_strings,
4190 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004191 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4192 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004193 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004194 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004195};
4196
4197static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004198 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004199 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004200 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004201 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4202 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004203 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4204 .phy_read = mv88e6xxx_g2_smi_phy_read,
4205 .phy_write = mv88e6xxx_g2_smi_phy_write,
4206 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004207 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004208 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004209 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004210 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004211 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004212 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004213 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004214 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4215 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004216 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12004217 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04004218 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004219 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004220 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004221 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004222 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004223 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004224 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004225 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004226 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4227 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004228 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004229 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4230 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004231 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004232 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004233 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004234 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004235 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004236 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4237 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004238 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4239 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004240 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004241 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004242 /* Check status register pause & lpa register */
4243 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4244 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4245 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4246 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004247 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004248 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004249 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004250 .serdes_get_strings = mv88e6390_serdes_get_strings,
4251 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004252 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4253 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004254 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004255 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004256};
4257
4258static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004259 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004260 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004261 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004262 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4263 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004264 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4265 .phy_read = mv88e6xxx_g2_smi_phy_read,
4266 .phy_write = mv88e6xxx_g2_smi_phy_write,
4267 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004268 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004269 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004270 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004271 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004272 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004273 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004274 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4275 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004276 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004277 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004278 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004279 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004280 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004281 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004282 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004283 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004284 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004285 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4286 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004287 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004288 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4289 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004290 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004291 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004292 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004293 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004294 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004295 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4296 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004297 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4298 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004299 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004300 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004301 /* Check status register pause & lpa register */
4302 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4303 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4304 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4305 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004306 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004307 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004308 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004309 .serdes_get_strings = mv88e6390_serdes_get_strings,
4310 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004311 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4312 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004313 .avb_ops = &mv88e6390_avb_ops,
4314 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004315 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004316};
4317
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004318static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004319 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004320 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4321 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004322 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004323 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4324 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004325 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004326 .phy_read = mv88e6xxx_g2_smi_phy_read,
4327 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004328 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004329 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004330 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004331 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004332 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004333 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004334 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004335 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4336 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004337 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004338 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004339 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004340 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004341 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004342 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004343 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004344 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004345 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004346 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004347 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4348 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004349 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004350 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4351 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004352 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004353 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004354 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004355 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004356 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004357 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4358 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004359 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004360 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004361 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004362 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4363 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4364 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4365 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004366 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004367 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004368 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004369 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004370 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4371 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004372 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004373 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004374 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004375 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004376};
4377
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004378static const struct mv88e6xxx_ops mv88e6250_ops = {
4379 /* MV88E6XXX_FAMILY_6250 */
4380 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4381 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4382 .irl_init_all = mv88e6352_g2_irl_init_all,
4383 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4384 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4385 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4386 .phy_read = mv88e6xxx_g2_smi_phy_read,
4387 .phy_write = mv88e6xxx_g2_smi_phy_write,
4388 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004389 .port_sync_link = mv88e6xxx_port_sync_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004390 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004391 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004392 .port_tag_remap = mv88e6095_port_tag_remap,
4393 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004394 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4395 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004396 .port_set_ether_type = mv88e6351_port_set_ether_type,
4397 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4398 .port_pause_limit = mv88e6097_port_pause_limit,
4399 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004400 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4401 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4402 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4403 .stats_get_strings = mv88e6250_stats_get_strings,
4404 .stats_get_stats = mv88e6250_stats_get_stats,
4405 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4406 .set_egress_port = mv88e6095_g1_set_egress_port,
4407 .watchdog_ops = &mv88e6250_watchdog_ops,
4408 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4409 .pot_clear = mv88e6xxx_g2_pot_clear,
4410 .reset = mv88e6250_g1_reset,
Rasmus Villemoes67c9ed12021-01-25 16:04:48 +01004411 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Rasmus Villemoesb28f3f32021-01-25 16:04:49 +01004412 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004413 .avb_ops = &mv88e6352_avb_ops,
4414 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004415 .phylink_validate = mv88e6065_phylink_validate,
4416};
4417
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004418static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004419 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004420 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004421 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004422 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4423 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004424 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4425 .phy_read = mv88e6xxx_g2_smi_phy_read,
4426 .phy_write = mv88e6xxx_g2_smi_phy_write,
4427 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004428 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004429 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004430 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004431 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004432 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004433 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004434 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004435 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4436 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004437 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004438 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004439 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004440 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004441 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004442 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004443 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004444 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004445 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004446 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4447 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004448 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004449 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4450 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004451 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004452 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004453 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004454 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004455 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004456 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4457 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004458 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4459 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004460 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004461 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004462 /* Check status register pause & lpa register */
4463 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4464 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4465 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4466 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004467 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004468 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004469 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004470 .serdes_get_strings = mv88e6390_serdes_get_strings,
4471 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004472 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4473 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004474 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004475 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004476 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004477 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004478};
4479
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004480static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004481 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004482 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4483 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004484 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004485 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4486 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004487 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004488 .phy_read = mv88e6xxx_g2_smi_phy_read,
4489 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004490 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004491 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004492 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004493 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004494 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004495 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4496 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004497 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004498 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004499 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004500 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004501 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004502 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004503 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004504 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004505 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004506 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004507 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4508 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004509 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004510 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4511 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004512 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004513 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004514 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004515 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004516 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004517 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004518 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004519 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004520 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004521 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004522};
4523
4524static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004525 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004526 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4527 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004528 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004529 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4530 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004531 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004532 .phy_read = mv88e6xxx_g2_smi_phy_read,
4533 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004534 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004535 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004536 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004537 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004538 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004539 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4540 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004541 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004542 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004543 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004544 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004545 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004546 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004547 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004548 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004549 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004550 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004551 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4552 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004553 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004554 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4555 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004556 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004557 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004558 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004559 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004560 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004561 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004562 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004563 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004564};
4565
Vivien Didelot16e329a2017-03-28 13:50:33 -04004566static const struct mv88e6xxx_ops mv88e6341_ops = {
4567 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004568 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4569 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004570 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004571 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4572 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4573 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4574 .phy_read = mv88e6xxx_g2_smi_phy_read,
4575 .phy_write = mv88e6xxx_g2_smi_phy_write,
4576 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004577 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004578 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004579 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004580 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004581 .port_tag_remap = mv88e6095_port_tag_remap,
Marek Behún7da467d2021-07-01 00:22:26 +02004582 .port_set_policy = mv88e6352_port_set_policy,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004583 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004584 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4585 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004586 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004587 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004588 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004589 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004590 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4591 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004592 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004593 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004594 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004595 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Marek Behún11527f32021-07-01 00:22:27 +02004596 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004597 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4598 .stats_get_strings = mv88e6320_stats_get_strings,
4599 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004600 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4601 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004602 .watchdog_ops = &mv88e6390_watchdog_ops,
4603 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004604 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004605 .reset = mv88e6352_g1_reset,
Marek Behún37094882021-07-01 00:22:28 +02004606 .rmu_disable = mv88e6390_g1_rmu_disable,
Marek Behúnc07fff32021-07-01 00:22:29 +02004607 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4608 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004609 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004610 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004611 .serdes_power = mv88e6390_serdes_power,
4612 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004613 /* Check status register pause & lpa register */
4614 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4615 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4616 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4617 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004618 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004619 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004620 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004621 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004622 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004623 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúna03b98d2021-07-01 00:22:30 +02004624 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4625 .serdes_get_strings = mv88e6390_serdes_get_strings,
4626 .serdes_get_stats = mv88e6390_serdes_get_stats,
Marek Behún953b0dc2021-07-01 00:22:31 +02004627 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4628 .serdes_get_regs = mv88e6390_serdes_get_regs,
Marek Behúne3af71a2019-02-25 12:39:55 +01004629 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004630};
4631
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004632static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004633 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004634 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4635 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004636 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004637 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004638 .phy_read = mv88e6xxx_g2_smi_phy_read,
4639 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004640 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004641 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004642 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004643 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004644 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004645 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004646 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4647 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004648 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004649 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004650 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004651 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004652 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004653 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004654 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004655 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004656 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004657 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004658 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4659 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004660 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004661 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4662 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004663 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004664 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004665 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004666 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004667 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4668 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004669 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004670 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004671 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004672};
4673
4674static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004675 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004676 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4677 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004678 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004679 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004680 .phy_read = mv88e6xxx_g2_smi_phy_read,
4681 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004682 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004683 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004684 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004685 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004686 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004687 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004688 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4689 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004690 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004691 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004692 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004693 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004694 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004695 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004696 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004697 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004698 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004699 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004700 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4701 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004702 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004703 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4704 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004705 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004706 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004707 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004708 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004709 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4710 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004711 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004712 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004713 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004714 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004715 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004716};
4717
4718static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004719 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004720 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4721 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004722 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004723 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4724 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004725 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004726 .phy_read = mv88e6xxx_g2_smi_phy_read,
4727 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004728 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004729 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004730 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004731 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004732 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004733 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004734 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004735 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4736 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004737 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004738 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004739 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004740 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004741 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004742 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004743 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004744 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004745 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004746 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004747 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4748 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004749 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004750 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4751 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004752 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004753 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004754 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004755 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004756 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004757 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4758 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004759 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004760 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004761 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004762 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4763 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4764 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4765 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004766 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004767 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004768 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004769 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004770 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004771 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004772 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004773 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4774 .serdes_get_strings = mv88e6352_serdes_get_strings,
4775 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004776 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4777 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004778 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004779};
4780
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004781static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004782 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004783 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004784 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004785 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4786 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004787 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4788 .phy_read = mv88e6xxx_g2_smi_phy_read,
4789 .phy_write = mv88e6xxx_g2_smi_phy_write,
4790 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004791 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004792 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004793 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004794 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004795 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004796 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004797 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004798 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4799 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004800 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004801 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004802 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004803 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004804 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004805 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004806 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004807 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004808 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004809 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004810 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004811 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4812 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004813 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004814 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4815 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004816 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004817 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004818 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004819 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004820 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004821 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4822 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004823 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4824 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004825 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004826 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004827 /* Check status register pause & lpa register */
4828 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4829 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4830 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4831 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004832 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004833 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004834 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004835 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004836 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004837 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004838 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4839 .serdes_get_strings = mv88e6390_serdes_get_strings,
4840 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004841 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4842 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004843 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004844};
4845
4846static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004847 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004848 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004849 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004850 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4851 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004852 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4853 .phy_read = mv88e6xxx_g2_smi_phy_read,
4854 .phy_write = mv88e6xxx_g2_smi_phy_write,
4855 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004856 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004857 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004858 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004859 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004860 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004861 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004862 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004863 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4864 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004865 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004866 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004867 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004868 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004869 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004870 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004871 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004872 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004873 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004874 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004875 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004876 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4877 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004878 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004879 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4880 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004881 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004882 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004883 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004884 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004885 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004886 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4887 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004888 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4889 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004890 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004891 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004892 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4893 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4894 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4895 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004896 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004897 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004898 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004899 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4900 .serdes_get_strings = mv88e6390_serdes_get_strings,
4901 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004902 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4903 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004904 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004905 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004906 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004907 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004908};
4909
Pavana Sharmade776d02021-03-17 14:46:42 +01004910static const struct mv88e6xxx_ops mv88e6393x_ops = {
4911 /* MV88E6XXX_FAMILY_6393 */
4912 .setup_errata = mv88e6393x_serdes_setup_errata,
4913 .irl_init_all = mv88e6390_g2_irl_init_all,
4914 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4915 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4916 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4917 .phy_read = mv88e6xxx_g2_smi_phy_read,
4918 .phy_write = mv88e6xxx_g2_smi_phy_write,
4919 .port_set_link = mv88e6xxx_port_set_link,
4920 .port_sync_link = mv88e6xxx_port_sync_link,
4921 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4922 .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex,
4923 .port_max_speed_mode = mv88e6393x_port_max_speed_mode,
4924 .port_tag_remap = mv88e6390_port_tag_remap,
Marek Behún6584b262021-03-17 14:46:43 +01004925 .port_set_policy = mv88e6393x_port_set_policy,
Pavana Sharmade776d02021-03-17 14:46:42 +01004926 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4927 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4928 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4929 .port_set_ether_type = mv88e6393x_port_set_ether_type,
4930 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4931 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4932 .port_pause_limit = mv88e6390_port_pause_limit,
4933 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4934 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4935 .port_get_cmode = mv88e6352_port_get_cmode,
4936 .port_set_cmode = mv88e6393x_port_set_cmode,
4937 .port_setup_message_port = mv88e6xxx_setup_message_port,
4938 .port_set_upstream_port = mv88e6393x_port_set_upstream_port,
4939 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4940 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4941 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4942 .stats_get_strings = mv88e6320_stats_get_strings,
4943 .stats_get_stats = mv88e6390_stats_get_stats,
4944 /* .set_cpu_port is missing because this family does not support a global
4945 * CPU port, only per port CPU port which is set via
4946 * .port_set_upstream_port method.
4947 */
4948 .set_egress_port = mv88e6393x_set_egress_port,
4949 .watchdog_ops = &mv88e6390_watchdog_ops,
4950 .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu,
4951 .pot_clear = mv88e6xxx_g2_pot_clear,
4952 .reset = mv88e6352_g1_reset,
4953 .rmu_disable = mv88e6390_g1_rmu_disable,
4954 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4955 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4956 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4957 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
4958 .serdes_power = mv88e6393x_serdes_power,
4959 .serdes_get_lane = mv88e6393x_serdes_get_lane,
4960 .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state,
4961 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4962 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4963 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
4964 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4965 .serdes_irq_enable = mv88e6393x_serdes_irq_enable,
4966 .serdes_irq_status = mv88e6393x_serdes_irq_status,
4967 /* TODO: serdes stats */
4968 .gpio_ops = &mv88e6352_gpio_ops,
4969 .avb_ops = &mv88e6390_avb_ops,
4970 .ptp_ops = &mv88e6352_ptp_ops,
4971 .phylink_validate = mv88e6393x_phylink_validate,
4972};
4973
Vivien Didelotf81ec902016-05-09 13:22:58 -04004974static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4975 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004976 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004977 .family = MV88E6XXX_FAMILY_6097,
4978 .name = "Marvell 88E6085",
4979 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004980 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004981 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004982 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004983 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004984 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004985 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004986 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004987 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004988 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004989 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004990 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004991 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004992 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004993 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004994 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004995 },
4996
4997 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004998 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004999 .family = MV88E6XXX_FAMILY_6095,
5000 .name = "Marvell 88E6095/88E6095F",
5001 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005002 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005003 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01005004 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005005 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005006 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005007 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005008 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005009 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005010 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005011 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05005012 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005013 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005014 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005015 },
5016
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005017 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005018 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005019 .family = MV88E6XXX_FAMILY_6097,
5020 .name = "Marvell 88E6097/88E6097F",
5021 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005022 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005023 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01005024 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005025 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005026 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005027 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005028 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005029 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005030 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01005031 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005032 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005033 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005034 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005035 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005036 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005037 .ops = &mv88e6097_ops,
5038 },
5039
Vivien Didelotf81ec902016-05-09 13:22:58 -04005040 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005041 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005042 .family = MV88E6XXX_FAMILY_6165,
5043 .name = "Marvell 88E6123",
5044 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005045 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005046 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01005047 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005048 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005049 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005050 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005051 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005052 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005053 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005054 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005055 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005056 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005057 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005058 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005059 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005060 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005061 },
5062
5063 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005064 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005065 .family = MV88E6XXX_FAMILY_6185,
5066 .name = "Marvell 88E6131",
5067 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005068 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005069 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005070 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005071 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005072 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005073 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005074 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005075 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005076 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005077 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05005078 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005079 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005080 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005081 },
5082
Vivien Didelot990e27b2017-03-28 13:50:32 -04005083 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005084 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005085 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01005086 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04005087 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005088 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005089 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005090 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005091 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005092 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005093 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005094 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005095 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005096 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005097 .age_time_coeff = 3750,
5098 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005099 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005100 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005101 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005102 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005103 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005104 .ops = &mv88e6141_ops,
5105 },
5106
Vivien Didelotf81ec902016-05-09 13:22:58 -04005107 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005108 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005109 .family = MV88E6XXX_FAMILY_6165,
5110 .name = "Marvell 88E6161",
5111 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005112 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005113 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005114 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005115 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005116 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005117 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005118 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005119 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005120 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005121 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005122 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005123 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005124 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005125 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005126 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Andrew Lunndfa54342018-07-18 22:38:22 +02005127 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005128 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005129 },
5130
5131 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005132 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005133 .family = MV88E6XXX_FAMILY_6165,
5134 .name = "Marvell 88E6165",
5135 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005136 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005137 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005138 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005139 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005140 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005141 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005142 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005143 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005144 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005145 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005146 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005147 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005148 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005149 .multi_chip = true,
Andrew Lunndfa54342018-07-18 22:38:22 +02005150 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005151 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005152 },
5153
5154 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005155 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005156 .family = MV88E6XXX_FAMILY_6351,
5157 .name = "Marvell 88E6171",
5158 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005159 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005160 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005161 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005162 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005163 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005164 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005165 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005166 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005167 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005168 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005169 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005170 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005171 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005172 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005173 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005174 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005175 },
5176
5177 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005178 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005179 .family = MV88E6XXX_FAMILY_6352,
5180 .name = "Marvell 88E6172",
5181 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005182 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005183 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005184 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005185 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005186 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005187 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005188 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005189 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005190 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005191 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005192 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005193 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005194 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005195 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005196 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005197 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005198 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005199 },
5200
5201 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005202 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005203 .family = MV88E6XXX_FAMILY_6351,
5204 .name = "Marvell 88E6175",
5205 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005206 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005207 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005208 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005209 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005210 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005211 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005212 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005213 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005214 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005215 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005216 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005217 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005218 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005219 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005220 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005221 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005222 },
5223
5224 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005225 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005226 .family = MV88E6XXX_FAMILY_6352,
5227 .name = "Marvell 88E6176",
5228 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005229 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005230 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005231 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005232 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005233 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005234 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005235 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005236 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005237 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005238 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005239 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005240 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005241 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005242 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005243 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005244 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005245 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005246 },
5247
5248 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005249 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005250 .family = MV88E6XXX_FAMILY_6185,
5251 .name = "Marvell 88E6185",
5252 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005253 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005254 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01005255 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005256 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005257 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005258 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005259 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005260 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005261 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005262 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05005263 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005264 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005265 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005266 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005267 },
5268
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005269 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005270 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005271 .family = MV88E6XXX_FAMILY_6390,
5272 .name = "Marvell 88E6190",
5273 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005274 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005275 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005276 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005277 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005278 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005279 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005280 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005281 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005282 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005283 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005284 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005285 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04005286 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005287 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05005288 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005289 .ops = &mv88e6190_ops,
5290 },
5291
5292 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005293 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005294 .family = MV88E6XXX_FAMILY_6390,
5295 .name = "Marvell 88E6190X",
5296 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005297 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005298 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005299 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005300 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005301 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005302 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005303 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005304 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005305 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005306 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005307 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005308 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005309 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005310 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005311 .multi_chip = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005312 .ops = &mv88e6190x_ops,
5313 },
5314
5315 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005316 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005317 .family = MV88E6XXX_FAMILY_6390,
5318 .name = "Marvell 88E6191",
5319 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005320 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005321 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005322 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005323 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005324 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005325 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005326 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005327 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005328 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005329 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005330 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005331 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005332 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005333 .multi_chip = true,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005334 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005335 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005336 },
5337
Pavana Sharmade776d02021-03-17 14:46:42 +01005338 [MV88E6191X] = {
5339 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X,
5340 .family = MV88E6XXX_FAMILY_6393,
5341 .name = "Marvell 88E6191X",
5342 .num_databases = 4096,
5343 .num_ports = 11, /* 10 + Z80 */
5344 .num_internal_phys = 9,
5345 .max_vid = 8191,
5346 .port_base_addr = 0x0,
5347 .phy_base_addr = 0x0,
5348 .global1_addr = 0x1b,
5349 .global2_addr = 0x1c,
5350 .age_time_coeff = 3750,
5351 .g1_irqs = 10,
5352 .g2_irqs = 14,
5353 .atu_move_port_mask = 0x1f,
5354 .pvt = true,
5355 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005356 .ptp_support = true,
5357 .ops = &mv88e6393x_ops,
5358 },
5359
5360 [MV88E6193X] = {
5361 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X,
5362 .family = MV88E6XXX_FAMILY_6393,
5363 .name = "Marvell 88E6193X",
5364 .num_databases = 4096,
5365 .num_ports = 11, /* 10 + Z80 */
5366 .num_internal_phys = 9,
5367 .max_vid = 8191,
5368 .port_base_addr = 0x0,
5369 .phy_base_addr = 0x0,
5370 .global1_addr = 0x1b,
5371 .global2_addr = 0x1c,
5372 .age_time_coeff = 3750,
5373 .g1_irqs = 10,
5374 .g2_irqs = 14,
5375 .atu_move_port_mask = 0x1f,
5376 .pvt = true,
5377 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005378 .ptp_support = true,
5379 .ops = &mv88e6393x_ops,
5380 },
5381
Hubert Feurstein49022642019-07-31 10:23:46 +02005382 [MV88E6220] = {
5383 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5384 .family = MV88E6XXX_FAMILY_6250,
5385 .name = "Marvell 88E6220",
5386 .num_databases = 64,
5387
5388 /* Ports 2-4 are not routed to pins
5389 * => usable ports 0, 1, 5, 6
5390 */
5391 .num_ports = 7,
5392 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005393 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005394 .max_vid = 4095,
5395 .port_base_addr = 0x08,
5396 .phy_base_addr = 0x00,
5397 .global1_addr = 0x0f,
5398 .global2_addr = 0x07,
5399 .age_time_coeff = 15000,
5400 .g1_irqs = 9,
5401 .g2_irqs = 10,
5402 .atu_move_port_mask = 0xf,
5403 .dual_chip = true,
Hubert Feurstein71509612019-07-31 10:23:51 +02005404 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005405 .ops = &mv88e6250_ops,
5406 },
5407
Vivien Didelotf81ec902016-05-09 13:22:58 -04005408 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005409 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005410 .family = MV88E6XXX_FAMILY_6352,
5411 .name = "Marvell 88E6240",
5412 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005413 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005414 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005415 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005416 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005417 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005418 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005419 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005420 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005421 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005422 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005423 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005424 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005425 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005426 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005427 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005428 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005429 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005430 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005431 },
5432
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005433 [MV88E6250] = {
5434 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5435 .family = MV88E6XXX_FAMILY_6250,
5436 .name = "Marvell 88E6250",
5437 .num_databases = 64,
5438 .num_ports = 7,
5439 .num_internal_phys = 5,
5440 .max_vid = 4095,
5441 .port_base_addr = 0x08,
5442 .phy_base_addr = 0x00,
5443 .global1_addr = 0x0f,
5444 .global2_addr = 0x07,
5445 .age_time_coeff = 15000,
5446 .g1_irqs = 9,
5447 .g2_irqs = 10,
5448 .atu_move_port_mask = 0xf,
5449 .dual_chip = true,
Hubert Feurstein71509612019-07-31 10:23:51 +02005450 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005451 .ops = &mv88e6250_ops,
5452 },
5453
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005454 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005455 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005456 .family = MV88E6XXX_FAMILY_6390,
5457 .name = "Marvell 88E6290",
5458 .num_databases = 4096,
5459 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005460 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005461 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005462 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005463 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005464 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005465 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005466 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005467 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005468 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005469 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005470 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005471 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005472 .multi_chip = true,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005473 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005474 .ops = &mv88e6290_ops,
5475 },
5476
Vivien Didelotf81ec902016-05-09 13:22:58 -04005477 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005478 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005479 .family = MV88E6XXX_FAMILY_6320,
5480 .name = "Marvell 88E6320",
5481 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005482 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005483 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005484 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005485 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005486 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005487 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005488 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005489 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005490 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005491 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005492 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005493 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005494 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005495 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005496 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005497 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005498 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005499 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005500 },
5501
5502 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005503 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005504 .family = MV88E6XXX_FAMILY_6320,
5505 .name = "Marvell 88E6321",
5506 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005507 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005508 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005509 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005510 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005511 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005512 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005513 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005514 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005515 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005516 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005517 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005518 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005519 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005520 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005521 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005522 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005523 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005524 },
5525
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005526 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005527 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005528 .family = MV88E6XXX_FAMILY_6341,
5529 .name = "Marvell 88E6341",
5530 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005531 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005532 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005533 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005534 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005535 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005536 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005537 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005538 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005539 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005540 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005541 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005542 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005543 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005544 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005545 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005546 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005547 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005548 .ops = &mv88e6341_ops,
5549 },
5550
Vivien Didelotf81ec902016-05-09 13:22:58 -04005551 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005552 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005553 .family = MV88E6XXX_FAMILY_6351,
5554 .name = "Marvell 88E6350",
5555 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005556 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005557 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005558 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005559 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005560 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005561 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005562 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005563 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005564 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005565 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005566 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005567 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005568 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005569 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005570 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005571 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005572 },
5573
5574 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005575 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005576 .family = MV88E6XXX_FAMILY_6351,
5577 .name = "Marvell 88E6351",
5578 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005579 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005580 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005581 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005582 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005583 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005584 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005585 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005586 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005587 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005588 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005589 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005590 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005591 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005592 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005593 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005594 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005595 },
5596
5597 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005598 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005599 .family = MV88E6XXX_FAMILY_6352,
5600 .name = "Marvell 88E6352",
5601 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005602 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005603 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005604 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005605 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005606 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005607 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005608 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005609 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005610 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005611 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005612 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005613 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005614 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005615 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005616 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005617 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005618 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005619 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005620 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005621 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005622 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005623 .family = MV88E6XXX_FAMILY_6390,
5624 .name = "Marvell 88E6390",
5625 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005626 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005627 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005628 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005629 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005630 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005631 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005632 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005633 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005634 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005635 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005636 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005637 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005638 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005639 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005640 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005641 .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005642 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005643 .ops = &mv88e6390_ops,
5644 },
5645 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005646 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005647 .family = MV88E6XXX_FAMILY_6390,
5648 .name = "Marvell 88E6390X",
5649 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005650 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005651 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005652 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005653 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005654 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005655 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005656 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005657 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005658 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005659 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005660 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005661 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005662 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005663 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005664 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005665 .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005666 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005667 .ops = &mv88e6390x_ops,
5668 },
Pavana Sharmade776d02021-03-17 14:46:42 +01005669
5670 [MV88E6393X] = {
5671 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
5672 .family = MV88E6XXX_FAMILY_6393,
5673 .name = "Marvell 88E6393X",
5674 .num_databases = 4096,
5675 .num_ports = 11, /* 10 + Z80 */
5676 .num_internal_phys = 9,
5677 .max_vid = 8191,
5678 .port_base_addr = 0x0,
5679 .phy_base_addr = 0x0,
5680 .global1_addr = 0x1b,
5681 .global2_addr = 0x1c,
5682 .age_time_coeff = 3750,
5683 .g1_irqs = 10,
5684 .g2_irqs = 14,
5685 .atu_move_port_mask = 0x1f,
5686 .pvt = true,
5687 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005688 .ptp_support = true,
5689 .ops = &mv88e6393x_ops,
5690 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005691};
5692
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005693static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005694{
Vivien Didelota439c062016-04-17 13:23:58 -04005695 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005696
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005697 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5698 if (mv88e6xxx_table[i].prod_num == prod_num)
5699 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005700
Vivien Didelotb9b37712015-10-30 19:39:48 -04005701 return NULL;
5702}
5703
Vivien Didelotfad09c72016-06-21 12:28:20 -04005704static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005705{
5706 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005707 unsigned int prod_num, rev;
5708 u16 id;
5709 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005710
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005711 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005712 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005713 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005714 if (err)
5715 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005716
Vivien Didelot107fcc12017-06-12 12:37:36 -04005717 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5718 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005719
5720 info = mv88e6xxx_lookup_info(prod_num);
5721 if (!info)
5722 return -ENODEV;
5723
Vivien Didelotcaac8542016-06-20 13:14:09 -04005724 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005725 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005726
Vivien Didelotfad09c72016-06-21 12:28:20 -04005727 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5728 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005729
5730 return 0;
5731}
5732
Vivien Didelotfad09c72016-06-21 12:28:20 -04005733static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005734{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005735 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005736
Vivien Didelotfad09c72016-06-21 12:28:20 -04005737 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5738 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005739 return NULL;
5740
Vivien Didelotfad09c72016-06-21 12:28:20 -04005741 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005742
Vivien Didelotfad09c72016-06-21 12:28:20 -04005743 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005744 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005745 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005746
Vivien Didelotfad09c72016-06-21 12:28:20 -04005747 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005748}
5749
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005750static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005751 int port,
5752 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005753{
Vivien Didelot04bed142016-08-31 18:06:13 -04005754 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005755
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005756 return chip->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005757}
5758
Tobias Waldekranz9a99bef2021-04-20 20:53:08 +02005759static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds, int port,
5760 enum dsa_tag_protocol proto)
5761{
5762 struct mv88e6xxx_chip *chip = ds->priv;
5763 enum dsa_tag_protocol old_protocol;
5764 int err;
5765
5766 switch (proto) {
5767 case DSA_TAG_PROTO_EDSA:
5768 switch (chip->info->edsa_support) {
5769 case MV88E6XXX_EDSA_UNSUPPORTED:
5770 return -EPROTONOSUPPORT;
5771 case MV88E6XXX_EDSA_UNDOCUMENTED:
5772 dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n");
5773 fallthrough;
5774 case MV88E6XXX_EDSA_SUPPORTED:
5775 break;
5776 }
5777 break;
5778 case DSA_TAG_PROTO_DSA:
5779 break;
5780 default:
5781 return -EPROTONOSUPPORT;
5782 }
5783
5784 old_protocol = chip->tag_protocol;
5785 chip->tag_protocol = proto;
5786
5787 mv88e6xxx_reg_lock(chip);
5788 err = mv88e6xxx_setup_port_mode(chip, port);
5789 mv88e6xxx_reg_unlock(chip);
5790
5791 if (err)
5792 chip->tag_protocol = old_protocol;
5793
5794 return err;
5795}
5796
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005797static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
5798 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005799{
Vivien Didelot04bed142016-08-31 18:06:13 -04005800 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005801 int err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005802
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005803 mv88e6xxx_reg_lock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005804 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
5805 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005806 mv88e6xxx_reg_unlock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005807
5808 return err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005809}
5810
5811static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5812 const struct switchdev_obj_port_mdb *mdb)
5813{
Vivien Didelot04bed142016-08-31 18:06:13 -04005814 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005815 int err;
5816
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005817 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005818 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005819 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005820
5821 return err;
5822}
5823
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005824static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5825 struct dsa_mall_mirror_tc_entry *mirror,
5826 bool ingress)
5827{
5828 enum mv88e6xxx_egress_direction direction = ingress ?
5829 MV88E6XXX_EGRESS_DIR_INGRESS :
5830 MV88E6XXX_EGRESS_DIR_EGRESS;
5831 struct mv88e6xxx_chip *chip = ds->priv;
5832 bool other_mirrors = false;
5833 int i;
5834 int err;
5835
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005836 mutex_lock(&chip->reg_lock);
5837 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5838 mirror->to_local_port) {
5839 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5840 other_mirrors |= ingress ?
5841 chip->ports[i].mirror_ingress :
5842 chip->ports[i].mirror_egress;
5843
5844 /* Can't change egress port when other mirror is active */
5845 if (other_mirrors) {
5846 err = -EBUSY;
5847 goto out;
5848 }
5849
Marek Behún2fda45f2021-03-17 14:46:41 +01005850 err = mv88e6xxx_set_egress_port(chip, direction,
5851 mirror->to_local_port);
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005852 if (err)
5853 goto out;
5854 }
5855
5856 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5857out:
5858 mutex_unlock(&chip->reg_lock);
5859
5860 return err;
5861}
5862
5863static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5864 struct dsa_mall_mirror_tc_entry *mirror)
5865{
5866 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5867 MV88E6XXX_EGRESS_DIR_INGRESS :
5868 MV88E6XXX_EGRESS_DIR_EGRESS;
5869 struct mv88e6xxx_chip *chip = ds->priv;
5870 bool other_mirrors = false;
5871 int i;
5872
5873 mutex_lock(&chip->reg_lock);
5874 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5875 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5876
5877 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5878 other_mirrors |= mirror->ingress ?
5879 chip->ports[i].mirror_ingress :
5880 chip->ports[i].mirror_egress;
5881
5882 /* Reset egress port when no other mirror is active */
5883 if (!other_mirrors) {
Marek Behún2fda45f2021-03-17 14:46:41 +01005884 if (mv88e6xxx_set_egress_port(chip, direction,
5885 dsa_upstream_port(ds, port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005886 dev_err(ds->dev, "failed to set egress port\n");
5887 }
5888
5889 mutex_unlock(&chip->reg_lock);
5890}
5891
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005892static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port,
5893 struct switchdev_brport_flags flags,
5894 struct netlink_ext_ack *extack)
5895{
5896 struct mv88e6xxx_chip *chip = ds->priv;
5897 const struct mv88e6xxx_ops *ops;
5898
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01005899 if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD |
5900 BR_BCAST_FLOOD))
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005901 return -EINVAL;
5902
5903 ops = chip->info->ops;
5904
5905 if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood)
5906 return -EINVAL;
5907
5908 if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood)
5909 return -EINVAL;
5910
5911 return 0;
5912}
5913
5914static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port,
5915 struct switchdev_brport_flags flags,
5916 struct netlink_ext_ack *extack)
Russell King4f859012019-02-20 15:35:05 -08005917{
5918 struct mv88e6xxx_chip *chip = ds->priv;
5919 int err = -EOPNOTSUPP;
5920
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005921 mv88e6xxx_reg_lock(chip);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005922
Tobias Waldekranz041bd542021-03-18 20:25:39 +01005923 if (flags.mask & BR_LEARNING) {
5924 bool learning = !!(flags.val & BR_LEARNING);
5925 u16 pav = learning ? (1 << port) : 0;
5926
5927 err = mv88e6xxx_port_set_assoc_vector(chip, port, pav);
5928 if (err)
5929 goto out;
Tobias Waldekranz041bd542021-03-18 20:25:39 +01005930 }
5931
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005932 if (flags.mask & BR_FLOOD) {
5933 bool unicast = !!(flags.val & BR_FLOOD);
5934
5935 err = chip->info->ops->port_set_ucast_flood(chip, port,
5936 unicast);
5937 if (err)
5938 goto out;
5939 }
5940
5941 if (flags.mask & BR_MCAST_FLOOD) {
5942 bool multicast = !!(flags.val & BR_MCAST_FLOOD);
5943
5944 err = chip->info->ops->port_set_mcast_flood(chip, port,
5945 multicast);
5946 if (err)
5947 goto out;
5948 }
5949
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01005950 if (flags.mask & BR_BCAST_FLOOD) {
5951 bool broadcast = !!(flags.val & BR_BCAST_FLOOD);
5952
5953 err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast);
5954 if (err)
5955 goto out;
5956 }
5957
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005958out:
5959 mv88e6xxx_reg_unlock(chip);
5960
5961 return err;
5962}
5963
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005964static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds,
5965 struct net_device *lag,
5966 struct netdev_lag_upper_info *info)
5967{
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01005968 struct mv88e6xxx_chip *chip = ds->priv;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005969 struct dsa_port *dp;
5970 int id, members = 0;
5971
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01005972 if (!mv88e6xxx_has_lag(chip))
5973 return false;
5974
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005975 id = dsa_lag_id(ds->dst, lag);
5976 if (id < 0 || id >= ds->num_lag_ids)
5977 return false;
5978
5979 dsa_lag_foreach_port(dp, ds->dst, lag)
5980 /* Includes the port joining the LAG */
5981 members++;
5982
5983 if (members > 8)
5984 return false;
5985
5986 /* We could potentially relax this to include active
5987 * backup in the future.
5988 */
5989 if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH)
5990 return false;
5991
5992 /* Ideally we would also validate that the hash type matches
5993 * the hardware. Alas, this is always set to unknown on team
5994 * interfaces.
5995 */
5996 return true;
5997}
5998
5999static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct net_device *lag)
6000{
6001 struct mv88e6xxx_chip *chip = ds->priv;
6002 struct dsa_port *dp;
6003 u16 map = 0;
6004 int id;
6005
6006 id = dsa_lag_id(ds->dst, lag);
6007
6008 /* Build the map of all ports to distribute flows destined for
6009 * this LAG. This can be either a local user port, or a DSA
6010 * port if the LAG port is on a remote chip.
6011 */
6012 dsa_lag_foreach_port(dp, ds->dst, lag)
6013 map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index));
6014
6015 return mv88e6xxx_g2_trunk_mapping_write(chip, id, map);
6016}
6017
6018static const u8 mv88e6xxx_lag_mask_table[8][8] = {
6019 /* Row number corresponds to the number of active members in a
6020 * LAG. Each column states which of the eight hash buckets are
6021 * mapped to the column:th port in the LAG.
6022 *
6023 * Example: In a LAG with three active ports, the second port
6024 * ([2][1]) would be selected for traffic mapped to buckets
6025 * 3,4,5 (0x38).
6026 */
6027 { 0xff, 0, 0, 0, 0, 0, 0, 0 },
6028 { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 },
6029 { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 },
6030 { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 },
6031 { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 },
6032 { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 },
6033 { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 },
6034 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 },
6035};
6036
6037static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port,
6038 int num_tx, int nth)
6039{
6040 u8 active = 0;
6041 int i;
6042
6043 num_tx = num_tx <= 8 ? num_tx : 8;
6044 if (nth < num_tx)
6045 active = mv88e6xxx_lag_mask_table[num_tx - 1][nth];
6046
6047 for (i = 0; i < 8; i++) {
6048 if (BIT(i) & active)
6049 mask[i] |= BIT(port);
6050 }
6051}
6052
6053static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds)
6054{
6055 struct mv88e6xxx_chip *chip = ds->priv;
6056 unsigned int id, num_tx;
6057 struct net_device *lag;
6058 struct dsa_port *dp;
6059 int i, err, nth;
6060 u16 mask[8];
6061 u16 ivec;
6062
6063 /* Assume no port is a member of any LAG. */
6064 ivec = BIT(mv88e6xxx_num_ports(chip)) - 1;
6065
6066 /* Disable all masks for ports that _are_ members of a LAG. */
6067 list_for_each_entry(dp, &ds->dst->ports, list) {
6068 if (!dp->lag_dev || dp->ds != ds)
6069 continue;
6070
6071 ivec &= ~BIT(dp->index);
6072 }
6073
6074 for (i = 0; i < 8; i++)
6075 mask[i] = ivec;
6076
6077 /* Enable the correct subset of masks for all LAG ports that
6078 * are in the Tx set.
6079 */
6080 dsa_lags_foreach_id(id, ds->dst) {
6081 lag = dsa_lag_dev(ds->dst, id);
6082 if (!lag)
6083 continue;
6084
6085 num_tx = 0;
6086 dsa_lag_foreach_port(dp, ds->dst, lag) {
6087 if (dp->lag_tx_enabled)
6088 num_tx++;
6089 }
6090
6091 if (!num_tx)
6092 continue;
6093
6094 nth = 0;
6095 dsa_lag_foreach_port(dp, ds->dst, lag) {
6096 if (!dp->lag_tx_enabled)
6097 continue;
6098
6099 if (dp->ds == ds)
6100 mv88e6xxx_lag_set_port_mask(mask, dp->index,
6101 num_tx, nth);
6102
6103 nth++;
6104 }
6105 }
6106
6107 for (i = 0; i < 8; i++) {
6108 err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]);
6109 if (err)
6110 return err;
6111 }
6112
6113 return 0;
6114}
6115
6116static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds,
6117 struct net_device *lag)
6118{
6119 int err;
6120
6121 err = mv88e6xxx_lag_sync_masks(ds);
6122
6123 if (!err)
6124 err = mv88e6xxx_lag_sync_map(ds, lag);
6125
6126 return err;
6127}
6128
6129static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port)
6130{
6131 struct mv88e6xxx_chip *chip = ds->priv;
6132 int err;
6133
6134 mv88e6xxx_reg_lock(chip);
6135 err = mv88e6xxx_lag_sync_masks(ds);
6136 mv88e6xxx_reg_unlock(chip);
6137 return err;
6138}
6139
6140static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port,
6141 struct net_device *lag,
6142 struct netdev_lag_upper_info *info)
6143{
6144 struct mv88e6xxx_chip *chip = ds->priv;
6145 int err, id;
6146
6147 if (!mv88e6xxx_lag_can_offload(ds, lag, info))
6148 return -EOPNOTSUPP;
6149
6150 id = dsa_lag_id(ds->dst, lag);
6151
6152 mv88e6xxx_reg_lock(chip);
6153
6154 err = mv88e6xxx_port_set_trunk(chip, port, true, id);
6155 if (err)
6156 goto err_unlock;
6157
6158 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
6159 if (err)
6160 goto err_clear_trunk;
6161
6162 mv88e6xxx_reg_unlock(chip);
6163 return 0;
6164
6165err_clear_trunk:
6166 mv88e6xxx_port_set_trunk(chip, port, false, 0);
6167err_unlock:
6168 mv88e6xxx_reg_unlock(chip);
6169 return err;
6170}
6171
6172static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port,
6173 struct net_device *lag)
6174{
6175 struct mv88e6xxx_chip *chip = ds->priv;
6176 int err_sync, err_trunk;
6177
6178 mv88e6xxx_reg_lock(chip);
6179 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
6180 err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0);
6181 mv88e6xxx_reg_unlock(chip);
6182 return err_sync ? : err_trunk;
6183}
6184
6185static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index,
6186 int port)
6187{
6188 struct mv88e6xxx_chip *chip = ds->priv;
6189 int err;
6190
6191 mv88e6xxx_reg_lock(chip);
6192 err = mv88e6xxx_lag_sync_masks(ds);
6193 mv88e6xxx_reg_unlock(chip);
6194 return err;
6195}
6196
6197static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index,
6198 int port, struct net_device *lag,
6199 struct netdev_lag_upper_info *info)
6200{
6201 struct mv88e6xxx_chip *chip = ds->priv;
6202 int err;
6203
6204 if (!mv88e6xxx_lag_can_offload(ds, lag, info))
6205 return -EOPNOTSUPP;
6206
6207 mv88e6xxx_reg_lock(chip);
6208
6209 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
6210 if (err)
6211 goto unlock;
6212
6213 err = mv88e6xxx_pvt_map(chip, sw_index, port);
6214
6215unlock:
6216 mv88e6xxx_reg_unlock(chip);
6217 return err;
6218}
6219
6220static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index,
6221 int port, struct net_device *lag)
6222{
6223 struct mv88e6xxx_chip *chip = ds->priv;
6224 int err_sync, err_pvt;
6225
6226 mv88e6xxx_reg_lock(chip);
6227 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
6228 err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port);
6229 mv88e6xxx_reg_unlock(chip);
6230 return err_sync ? : err_pvt;
6231}
6232
Florian Fainellia82f67a2017-01-08 14:52:08 -08006233static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02006234 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Tobias Waldekranz9a99bef2021-04-20 20:53:08 +02006235 .change_tag_protocol = mv88e6xxx_change_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006236 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02006237 .teardown = mv88e6xxx_teardown,
Vladimir Olteanfd292c12021-09-17 17:29:16 +03006238 .port_setup = mv88e6xxx_port_setup,
6239 .port_teardown = mv88e6xxx_port_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07006240 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00006241 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07006242 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00006243 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07006244 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
6245 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006246 .get_strings = mv88e6xxx_get_strings,
6247 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
6248 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02006249 .port_enable = mv88e6xxx_port_enable,
6250 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02006251 .port_max_mtu = mv88e6xxx_get_max_mtu,
6252 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04006253 .get_mac_eee = mv88e6xxx_get_mac_eee,
6254 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006255 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006256 .get_eeprom = mv88e6xxx_get_eeprom,
6257 .set_eeprom = mv88e6xxx_set_eeprom,
6258 .get_regs_len = mv88e6xxx_get_regs_len,
6259 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04006260 .get_rxnfc = mv88e6xxx_get_rxnfc,
6261 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04006262 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006263 .port_bridge_join = mv88e6xxx_port_bridge_join,
6264 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02006265 .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags,
6266 .port_bridge_flags = mv88e6xxx_port_bridge_flags,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006267 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04006268 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006269 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006270 .port_vlan_add = mv88e6xxx_port_vlan_add,
6271 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006272 .port_fdb_add = mv88e6xxx_port_fdb_add,
6273 .port_fdb_del = mv88e6xxx_port_fdb_del,
6274 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04006275 .port_mdb_add = mv88e6xxx_port_mdb_add,
6276 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01006277 .port_mirror_add = mv88e6xxx_port_mirror_add,
6278 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04006279 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
6280 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006281 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
6282 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
6283 .port_txtstamp = mv88e6xxx_port_txtstamp,
6284 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
6285 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02006286 .devlink_param_get = mv88e6xxx_devlink_param_get,
6287 .devlink_param_set = mv88e6xxx_devlink_param_set,
Andrew Lunn93157302020-09-18 21:11:09 +02006288 .devlink_info_get = mv88e6xxx_devlink_info_get,
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006289 .port_lag_change = mv88e6xxx_port_lag_change,
6290 .port_lag_join = mv88e6xxx_port_lag_join,
6291 .port_lag_leave = mv88e6xxx_port_lag_leave,
6292 .crosschip_lag_change = mv88e6xxx_crosschip_lag_change,
6293 .crosschip_lag_join = mv88e6xxx_crosschip_lag_join,
6294 .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave,
Vladimir Olteance5df682021-07-22 18:55:41 +03006295 .port_bridge_tx_fwd_offload = mv88e6xxx_bridge_tx_fwd_offload,
6296 .port_bridge_tx_fwd_unoffload = mv88e6xxx_bridge_tx_fwd_unoffload,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006297};
6298
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08006299static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006300{
Vivien Didelotfad09c72016-06-21 12:28:20 -04006301 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006302 struct dsa_switch *ds;
6303
Vivien Didelot7e99e342019-10-21 16:51:30 -04006304 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006305 if (!ds)
6306 return -ENOMEM;
6307
Vivien Didelot7e99e342019-10-21 16:51:30 -04006308 ds->dev = dev;
6309 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04006310 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006311 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04006312 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04006313 ds->ageing_time_min = chip->info->age_time_coeff;
6314 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006315
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006316 /* Some chips support up to 32, but that requires enabling the
6317 * 5-bit port mode, which we do not support. 640k^W16 ought to
6318 * be enough for anyone.
6319 */
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01006320 ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006321
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006322 dev_set_drvdata(dev, ds);
6323
Vivien Didelot23c9ee42017-05-26 18:12:51 -04006324 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006325}
6326
Vivien Didelotfad09c72016-06-21 12:28:20 -04006327static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006328{
Vivien Didelotfad09c72016-06-21 12:28:20 -04006329 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006330}
6331
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006332static const void *pdata_device_get_match_data(struct device *dev)
6333{
6334 const struct of_device_id *matches = dev->driver->of_match_table;
6335 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
6336
6337 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
6338 matches++) {
6339 if (!strcmp(pdata->compatible, matches->compatible))
6340 return matches->data;
6341 }
6342 return NULL;
6343}
6344
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01006345/* There is no suspend to RAM support at DSA level yet, the switch configuration
6346 * would be lost after a power cycle so prevent it to be suspended.
6347 */
6348static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
6349{
6350 return -EOPNOTSUPP;
6351}
6352
6353static int __maybe_unused mv88e6xxx_resume(struct device *dev)
6354{
6355 return 0;
6356}
6357
6358static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
6359
Vivien Didelot57d32312016-06-20 13:13:58 -04006360static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006361{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006362 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04006363 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006364 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006365 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04006366 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006367 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02006368 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006369
Andrew Lunn7bb8c992018-05-31 00:15:42 +02006370 if (!np && !pdata)
6371 return -EINVAL;
6372
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006373 if (np)
6374 compat_info = of_device_get_match_data(dev);
6375
6376 if (pdata) {
6377 compat_info = pdata_device_get_match_data(dev);
6378
6379 if (!pdata->netdev)
6380 return -EINVAL;
6381
6382 for (port = 0; port < DSA_MAX_PORTS; port++) {
6383 if (!(pdata->enabled_ports & (1 << port)))
6384 continue;
6385 if (strcmp(pdata->cd.port_names[port], "cpu"))
6386 continue;
6387 pdata->cd.netdev[port] = &pdata->netdev->dev;
6388 break;
6389 }
6390 }
6391
Vivien Didelotcaac8542016-06-20 13:14:09 -04006392 if (!compat_info)
6393 return -EINVAL;
6394
Vivien Didelotfad09c72016-06-21 12:28:20 -04006395 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006396 if (!chip) {
6397 err = -ENOMEM;
6398 goto out;
6399 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006400
Vivien Didelotfad09c72016-06-21 12:28:20 -04006401 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04006402
Vivien Didelotfad09c72016-06-21 12:28:20 -04006403 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04006404 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006405 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006406
Andrew Lunnb4308f02016-11-21 23:26:55 +01006407 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006408 if (IS_ERR(chip->reset)) {
6409 err = PTR_ERR(chip->reset);
6410 goto out;
6411 }
Baruch Siach7b75e492019-06-27 21:17:39 +03006412 if (chip->reset)
6413 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01006414
Vivien Didelotfad09c72016-06-21 12:28:20 -04006415 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04006416 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006417 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006418
Tobias Waldekranz670bb802021-04-20 20:53:07 +02006419 if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED)
6420 chip->tag_protocol = DSA_TAG_PROTO_EDSA;
6421 else
6422 chip->tag_protocol = DSA_TAG_PROTO_DSA;
6423
Vivien Didelote57e5e72016-08-15 17:19:00 -04006424 mv88e6xxx_phy_init(chip);
6425
Andrew Lunn00baabe2018-05-19 22:31:35 +02006426 if (chip->info->ops->get_eeprom) {
6427 if (np)
6428 of_property_read_u32(np, "eeprom-length",
6429 &chip->eeprom_len);
6430 else
6431 chip->eeprom_len = pdata->eeprom_len;
6432 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006433
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006434 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006435 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006436 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02006437 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02006438 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02006439
Andrew Lunna27415d2019-05-01 00:10:50 +02006440 if (np) {
6441 chip->irq = of_irq_get(np, 0);
6442 if (chip->irq == -EPROBE_DEFER) {
6443 err = chip->irq;
6444 goto out;
6445 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02006446 }
6447
Andrew Lunna27415d2019-05-01 00:10:50 +02006448 if (pdata)
6449 chip->irq = pdata->irq;
6450
Andrew Lunn294d7112018-02-22 22:58:32 +01006451 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01006452 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01006453 * controllers
6454 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006455 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006456 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02006457 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006458 else
6459 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006460 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006461
Andrew Lunn294d7112018-02-22 22:58:32 +01006462 if (err)
6463 goto out;
6464
6465 if (chip->info->g2_irqs > 0) {
6466 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006467 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01006468 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02006469 }
6470
Andrew Lunn294d7112018-02-22 22:58:32 +01006471 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
6472 if (err)
6473 goto out_g2_irq;
6474
6475 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
6476 if (err)
6477 goto out_g1_atu_prob_irq;
6478
Andrew Lunna3c53be52017-01-24 14:53:50 +01006479 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02006480 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01006481 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02006482
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08006483 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006484 if (err)
6485 goto out_mdio;
6486
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006487 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02006488
6489out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01006490 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01006491out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006492 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01006493out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006494 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006495out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006496 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02006497 mv88e6xxx_g2_irq_free(chip);
6498out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006499 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01006500 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006501 else
6502 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006503out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006504 if (pdata)
6505 dev_put(pdata->netdev);
6506
Andrew Lunndc30c352016-10-16 19:56:49 +02006507 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006508}
6509
6510static void mv88e6xxx_remove(struct mdio_device *mdiodev)
6511{
6512 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006513 struct mv88e6xxx_chip *chip;
6514
6515 if (!ds)
6516 return;
6517
6518 chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006519
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006520 if (chip->info->ptp_support) {
6521 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01006522 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006523 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01006524
Andrew Lunn930188c2016-08-22 16:01:03 +02006525 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04006526 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01006527 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006528
Andrew Lunn76f38f12018-03-17 20:21:09 +01006529 mv88e6xxx_g1_vtu_prob_irq_free(chip);
6530 mv88e6xxx_g1_atu_prob_irq_free(chip);
6531
6532 if (chip->info->g2_irqs > 0)
6533 mv88e6xxx_g2_irq_free(chip);
6534
Andrew Lunn76f38f12018-03-17 20:21:09 +01006535 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01006536 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01006537 else
6538 mv88e6xxx_irq_poll_free(chip);
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006539
6540 dev_set_drvdata(&mdiodev->dev, NULL);
6541}
6542
6543static void mv88e6xxx_shutdown(struct mdio_device *mdiodev)
6544{
6545 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
6546
6547 if (!ds)
6548 return;
6549
6550 dsa_switch_shutdown(ds);
6551
6552 dev_set_drvdata(&mdiodev->dev, NULL);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006553}
6554
6555static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04006556 {
6557 .compatible = "marvell,mv88e6085",
6558 .data = &mv88e6xxx_table[MV88E6085],
6559 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01006560 {
6561 .compatible = "marvell,mv88e6190",
6562 .data = &mv88e6xxx_table[MV88E6190],
6563 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00006564 {
6565 .compatible = "marvell,mv88e6250",
6566 .data = &mv88e6xxx_table[MV88E6250],
6567 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006568 { /* sentinel */ },
6569};
6570
6571MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
6572
6573static struct mdio_driver mv88e6xxx_driver = {
6574 .probe = mv88e6xxx_probe,
6575 .remove = mv88e6xxx_remove,
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006576 .shutdown = mv88e6xxx_shutdown,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006577 .mdiodrv.driver = {
6578 .name = "mv88e6085",
6579 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01006580 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006581 },
6582};
6583
Andrew Lunn7324d502019-04-27 19:19:10 +02006584mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00006585
6586MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
6587MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
6588MODULE_LICENSE("GPL");