blob: 14f87f6ac479a9922cb9474f78174be182bded83 [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);
Russell King5d5b2312020-03-14 10:16:03 +0000771 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000772
Russell King5d5b2312020-03-14 10:16:03 +0000773 if (err)
774 dev_err(chip->dev,
775 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700776}
777
778static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
779 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000780 struct phy_device *phydev,
781 int speed, int duplex,
782 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700783{
Russell King30c4a5b2020-02-26 10:23:51 +0000784 struct mv88e6xxx_chip *chip = ds->priv;
785 const struct mv88e6xxx_ops *ops;
786 int err = 0;
787
788 ops = chip->info->ops;
789
Russell King5d5b2312020-03-14 10:16:03 +0000790 mv88e6xxx_reg_lock(chip);
Russell King (Oracle)2b29cb92021-12-07 10:32:43 +0000791 /* Configure and force the link up if we know that the port may not
792 * automatically updated by the switch or if we are using fixed-link
793 * mode.
Maarten Zanders4a3e0ae2021-10-11 16:27:20 +0200794 */
Russell King (Oracle)2b29cb92021-12-07 10:32:43 +0000795 if (!mv88e6xxx_port_ppu_updates(chip, port) ||
Maarten Zanders4a3e0ae2021-10-11 16:27:20 +0200796 mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000797 /* FIXME: for an automedia port, should we force the link
798 * down here - what if the link comes up due to "other" media
799 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000800 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000801 * shared between internal PHY and Serdes.
802 */
Russell Kinga5a68582020-03-14 10:15:43 +0000803 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
804 duplex);
805 if (err)
806 goto error;
807
Russell Kingf365c6f2020-03-14 10:15:53 +0000808 if (ops->port_set_speed_duplex) {
809 err = ops->port_set_speed_duplex(chip, port,
810 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000811 if (err && err != -EOPNOTSUPP)
812 goto error;
813 }
814
Chris Packham4efe76622020-11-24 17:34:37 +1300815 if (ops->port_sync_link)
816 err = ops->port_sync_link(chip, port, mode, true);
Russell King30c4a5b2020-02-26 10:23:51 +0000817 }
Russell King5d5b2312020-03-14 10:16:03 +0000818error:
819 mv88e6xxx_reg_unlock(chip);
820
821 if (err && err != -EOPNOTSUPP)
822 dev_err(ds->dev,
823 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700824}
825
Andrew Lunna605a0f2016-11-21 23:26:58 +0100826static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000827{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100828 if (!chip->info->ops->stats_snapshot)
829 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000830
Andrew Lunna605a0f2016-11-21 23:26:58 +0100831 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000832}
833
Andrew Lunne413e7e2015-04-02 04:06:38 +0200834static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100835 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
836 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
837 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
838 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
839 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
840 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
841 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
842 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
843 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
844 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
845 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
846 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
847 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
848 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
849 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
850 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
851 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
852 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
853 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
854 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
855 { "single", 4, 0x14, STATS_TYPE_BANK0, },
856 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
857 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
858 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
859 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
860 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
861 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
862 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
863 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
864 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
865 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
866 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
867 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
868 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
869 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
870 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
871 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
872 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
873 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
874 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
875 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
876 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
877 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
878 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
879 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
880 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
881 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
882 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
883 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
884 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
885 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
886 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
887 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
888 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
889 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
890 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
891 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
892 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
893 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200894};
895
Vivien Didelotfad09c72016-06-21 12:28:20 -0400896static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100897 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100898 int port, u16 bank1_select,
899 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200900{
Andrew Lunn80c46272015-06-20 18:42:30 +0200901 u32 low;
902 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100903 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200904 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200905 u64 value;
906
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100907 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100908 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200909 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
910 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800911 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200912
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200913 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100914 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200915 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
916 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800917 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000918 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200919 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100920 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100921 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100922 reg = bank1_select;
Gustavo A. R. Silvadf561f662020-08-23 17:36:59 -0500923 fallthrough;
Andrew Lunndfafe442016-11-21 23:27:02 +0100924 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100925 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100926 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100927 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100928 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500929 break;
930 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800931 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200932 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100933 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200934 return value;
935}
936
Andrew Lunn436fe172018-03-01 02:02:29 +0100937static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
938 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100939{
940 struct mv88e6xxx_hw_stat *stat;
941 int i, j;
942
943 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
944 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100945 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100946 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
947 ETH_GSTRING_LEN);
948 j++;
949 }
950 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100951
952 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100953}
954
Andrew Lunn436fe172018-03-01 02:02:29 +0100955static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
956 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100957{
Andrew Lunn436fe172018-03-01 02:02:29 +0100958 return mv88e6xxx_stats_get_strings(chip, data,
959 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100960}
961
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000962static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
963 uint8_t *data)
964{
965 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
966}
967
Andrew Lunn436fe172018-03-01 02:02:29 +0100968static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
969 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100970{
Andrew Lunn436fe172018-03-01 02:02:29 +0100971 return mv88e6xxx_stats_get_strings(chip, data,
972 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100973}
974
Andrew Lunn65f60e42018-03-28 23:50:28 +0200975static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
976 "atu_member_violation",
977 "atu_miss_violation",
978 "atu_full_violation",
979 "vtu_member_violation",
980 "vtu_miss_violation",
981};
982
983static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
984{
985 unsigned int i;
986
987 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
988 strlcpy(data + i * ETH_GSTRING_LEN,
989 mv88e6xxx_atu_vtu_stats_strings[i],
990 ETH_GSTRING_LEN);
991}
992
Andrew Lunndfafe442016-11-21 23:27:02 +0100993static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700994 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100995{
Vivien Didelot04bed142016-08-31 18:06:13 -0400996 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100997 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100998
Florian Fainelli89f09042018-04-25 12:12:50 -0700999 if (stringset != ETH_SS_STATS)
1000 return;
1001
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001002 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001003
Andrew Lunndfafe442016-11-21 23:27:02 +01001004 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +01001005 count = chip->info->ops->stats_get_strings(chip, data);
1006
1007 if (chip->info->ops->serdes_get_strings) {
1008 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001009 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001010 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +01001011
Andrew Lunn65f60e42018-03-28 23:50:28 +02001012 data += count * ETH_GSTRING_LEN;
1013 mv88e6xxx_atu_vtu_get_strings(data);
1014
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001015 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001016}
1017
1018static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
1019 int types)
1020{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001021 struct mv88e6xxx_hw_stat *stat;
1022 int i, j;
1023
1024 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1025 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +01001026 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001027 j++;
1028 }
1029 return j;
1030}
1031
Andrew Lunndfafe442016-11-21 23:27:02 +01001032static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1033{
1034 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1035 STATS_TYPE_PORT);
1036}
1037
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001038static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1039{
1040 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
1041}
1042
Andrew Lunndfafe442016-11-21 23:27:02 +01001043static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1044{
1045 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1046 STATS_TYPE_BANK1);
1047}
1048
Florian Fainelli89f09042018-04-25 12:12:50 -07001049static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001050{
1051 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001052 int serdes_count = 0;
1053 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001054
Florian Fainelli89f09042018-04-25 12:12:50 -07001055 if (sset != ETH_SS_STATS)
1056 return 0;
1057
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001058 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001059 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001060 count = chip->info->ops->stats_get_sset_count(chip);
1061 if (count < 0)
1062 goto out;
1063
1064 if (chip->info->ops->serdes_get_sset_count)
1065 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1066 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001067 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001068 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001069 goto out;
1070 }
1071 count += serdes_count;
1072 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1073
Andrew Lunn436fe172018-03-01 02:02:29 +01001074out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001075 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001076
Andrew Lunn436fe172018-03-01 02:02:29 +01001077 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001078}
1079
Andrew Lunn436fe172018-03-01 02:02:29 +01001080static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1081 uint64_t *data, int types,
1082 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001083{
1084 struct mv88e6xxx_hw_stat *stat;
1085 int i, j;
1086
1087 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1088 stat = &mv88e6xxx_hw_stats[i];
1089 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001090 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001091 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1092 bank1_select,
1093 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001094 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001095
Andrew Lunn052f9472016-11-21 23:27:03 +01001096 j++;
1097 }
1098 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001099 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001100}
1101
Andrew Lunn436fe172018-03-01 02:02:29 +01001102static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1103 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001104{
1105 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001106 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001107 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001108}
1109
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001110static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1111 uint64_t *data)
1112{
1113 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1114 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1115}
1116
Andrew Lunn436fe172018-03-01 02:02:29 +01001117static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1118 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001119{
1120 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001121 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001122 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1123 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001124}
1125
Andrew Lunn436fe172018-03-01 02:02:29 +01001126static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1127 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001128{
1129 return mv88e6xxx_stats_get_stats(chip, port, data,
1130 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001131 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1132 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001133}
1134
Andrew Lunn65f60e42018-03-28 23:50:28 +02001135static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1136 uint64_t *data)
1137{
1138 *data++ = chip->ports[port].atu_member_violation;
1139 *data++ = chip->ports[port].atu_miss_violation;
1140 *data++ = chip->ports[port].atu_full_violation;
1141 *data++ = chip->ports[port].vtu_member_violation;
1142 *data++ = chip->ports[port].vtu_miss_violation;
1143}
1144
Andrew Lunn052f9472016-11-21 23:27:03 +01001145static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1146 uint64_t *data)
1147{
Andrew Lunn436fe172018-03-01 02:02:29 +01001148 int count = 0;
1149
Andrew Lunn052f9472016-11-21 23:27:03 +01001150 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001151 count = chip->info->ops->stats_get_stats(chip, port, data);
1152
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001153 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001154 if (chip->info->ops->serdes_get_stats) {
1155 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001156 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001157 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001158 data += count;
1159 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001160 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001161}
1162
Vivien Didelotf81ec902016-05-09 13:22:58 -04001163static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1164 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001165{
Vivien Didelot04bed142016-08-31 18:06:13 -04001166 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001167 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001168
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001169 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001170
Andrew Lunna605a0f2016-11-21 23:26:58 +01001171 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001172 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001173
1174 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001175 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001176
1177 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001178
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001179}
Ben Hutchings98e67302011-11-25 14:36:19 +00001180
Vivien Didelotf81ec902016-05-09 13:22:58 -04001181static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001182{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001183 struct mv88e6xxx_chip *chip = ds->priv;
1184 int len;
1185
1186 len = 32 * sizeof(u16);
1187 if (chip->info->ops->serdes_get_regs_len)
1188 len += chip->info->ops->serdes_get_regs_len(chip, port);
1189
1190 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001191}
1192
Vivien Didelotf81ec902016-05-09 13:22:58 -04001193static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1194 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001195{
Vivien Didelot04bed142016-08-31 18:06:13 -04001196 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001197 int err;
1198 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001199 u16 *p = _p;
1200 int i;
1201
Vivien Didelota5f39322018-12-17 16:05:21 -05001202 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001203
1204 memset(p, 0xff, 32 * sizeof(u16));
1205
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001206 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001207
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001208 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001209
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001210 err = mv88e6xxx_port_read(chip, port, i, &reg);
1211 if (!err)
1212 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001213 }
Vivien Didelot23062512016-05-09 13:22:45 -04001214
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001215 if (chip->info->ops->serdes_get_regs)
1216 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1217
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001218 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001219}
1220
Vivien Didelot08f50062017-08-01 16:32:41 -04001221static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1222 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001223{
Vivien Didelot5480db62017-08-01 16:32:40 -04001224 /* Nothing to do on the port's MAC */
1225 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001226}
1227
Vivien Didelot08f50062017-08-01 16:32:41 -04001228static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1229 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001230{
Vivien Didelot5480db62017-08-01 16:32:40 -04001231 /* Nothing to do on the port's MAC */
1232 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001233}
1234
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001235/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001236static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001237{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001238 struct dsa_switch *ds = chip->ds;
1239 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001240 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001241 struct dsa_port *dp;
1242 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001243 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001244
Vladimir Olteance5df682021-07-22 18:55:41 +03001245 /* dev is a physical switch */
1246 if (dev <= dst->last_switch) {
1247 list_for_each_entry(dp, &dst->ports, list) {
1248 if (dp->ds->index == dev && dp->index == port) {
1249 /* dp might be a DSA link or a user port, so it
1250 * might or might not have a bridge_dev
1251 * pointer. Use the "found" variable for both
1252 * cases.
1253 */
1254 br = dp->bridge_dev;
1255 found = true;
1256 break;
1257 }
1258 }
1259 /* dev is a virtual bridge */
1260 } else {
1261 list_for_each_entry(dp, &dst->ports, list) {
1262 if (dp->bridge_num < 0)
1263 continue;
1264
1265 if (dp->bridge_num + 1 + dst->last_switch != dev)
1266 continue;
1267
1268 br = dp->bridge_dev;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001269 found = true;
1270 break;
1271 }
1272 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001273
Vladimir Olteance5df682021-07-22 18:55:41 +03001274 /* Prevent frames from unknown switch or virtual bridge */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001275 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001276 return 0;
1277
1278 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001279 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001280 return mv88e6xxx_port_mask(chip);
1281
Vivien Didelote5887a22017-03-30 17:37:11 -04001282 pvlan = 0;
1283
1284 /* Frames from user ports can egress any local DSA links and CPU ports,
1285 * as well as any local member of their bridge group.
1286 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001287 list_for_each_entry(dp, &dst->ports, list)
1288 if (dp->ds == ds &&
1289 (dp->type == DSA_PORT_TYPE_CPU ||
1290 dp->type == DSA_PORT_TYPE_DSA ||
1291 (br && dp->bridge_dev == br)))
1292 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001293
1294 return pvlan;
1295}
1296
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001297static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001298{
1299 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001300
1301 /* prevent frames from going back out of the port they came in on */
1302 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001303
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001304 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001305}
1306
Vivien Didelotf81ec902016-05-09 13:22:58 -04001307static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1308 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001309{
Vivien Didelot04bed142016-08-31 18:06:13 -04001310 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001311 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001312
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001313 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001314 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001315 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001316
1317 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001318 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001319}
1320
Vivien Didelot93e18d62018-05-11 17:16:35 -04001321static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1322{
1323 int err;
1324
1325 if (chip->info->ops->ieee_pri_map) {
1326 err = chip->info->ops->ieee_pri_map(chip);
1327 if (err)
1328 return err;
1329 }
1330
1331 if (chip->info->ops->ip_pri_map) {
1332 err = chip->info->ops->ip_pri_map(chip);
1333 if (err)
1334 return err;
1335 }
1336
1337 return 0;
1338}
1339
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001340static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1341{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001342 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001343 int target, port;
1344 int err;
1345
1346 if (!chip->info->global2_addr)
1347 return 0;
1348
1349 /* Initialize the routing port to the 32 possible target devices */
1350 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001351 port = dsa_routing_port(ds, target);
1352 if (port == ds->num_ports)
1353 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001354
1355 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1356 if (err)
1357 return err;
1358 }
1359
Vivien Didelot02317e62018-05-09 11:38:49 -04001360 if (chip->info->ops->set_cascade_port) {
1361 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1362 err = chip->info->ops->set_cascade_port(chip, port);
1363 if (err)
1364 return err;
1365 }
1366
Vivien Didelot23c98912018-05-09 11:38:50 -04001367 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1368 if (err)
1369 return err;
1370
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001371 return 0;
1372}
1373
Vivien Didelotb28f8722018-04-26 21:56:44 -04001374static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1375{
1376 /* Clear all trunk masks and mapping */
1377 if (chip->info->global2_addr)
1378 return mv88e6xxx_g2_trunk_clear(chip);
1379
1380 return 0;
1381}
1382
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001383static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1384{
1385 if (chip->info->ops->rmu_disable)
1386 return chip->info->ops->rmu_disable(chip);
1387
1388 return 0;
1389}
1390
Vivien Didelot9e907d72017-07-17 13:03:43 -04001391static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1392{
1393 if (chip->info->ops->pot_clear)
1394 return chip->info->ops->pot_clear(chip);
1395
1396 return 0;
1397}
1398
Vivien Didelot51c901a2017-07-17 13:03:41 -04001399static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1400{
1401 if (chip->info->ops->mgmt_rsvd2cpu)
1402 return chip->info->ops->mgmt_rsvd2cpu(chip);
1403
1404 return 0;
1405}
1406
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001407static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1408{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001409 int err;
1410
Vivien Didelotdaefc942017-03-11 16:12:54 -05001411 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1412 if (err)
1413 return err;
1414
Rasmus Villemoes49506a92020-12-10 12:06:44 +01001415 /* The chips that have a "learn2all" bit in Global1, ATU
1416 * Control are precisely those whose port registers have a
1417 * Message Port bit in Port Control 1 and hence implement
1418 * ->port_setup_message_port.
1419 */
1420 if (chip->info->ops->port_setup_message_port) {
1421 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1422 if (err)
1423 return err;
1424 }
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001425
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001426 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1427}
1428
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001429static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1430{
1431 int port;
1432 int err;
1433
1434 if (!chip->info->ops->irl_init_all)
1435 return 0;
1436
1437 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1438 /* Disable ingress rate limiting by resetting all per port
1439 * ingress rate limit resources to their initial state.
1440 */
1441 err = chip->info->ops->irl_init_all(chip, port);
1442 if (err)
1443 return err;
1444 }
1445
1446 return 0;
1447}
1448
Vivien Didelot04a69a12017-10-13 14:18:05 -04001449static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1450{
1451 if (chip->info->ops->set_switch_mac) {
1452 u8 addr[ETH_ALEN];
1453
1454 eth_random_addr(addr);
1455
1456 return chip->info->ops->set_switch_mac(chip, addr);
1457 }
1458
1459 return 0;
1460}
1461
Vivien Didelot17a15942017-03-30 17:37:09 -04001462static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1463{
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001464 struct dsa_switch_tree *dst = chip->ds->dst;
1465 struct dsa_switch *ds;
1466 struct dsa_port *dp;
Vivien Didelot17a15942017-03-30 17:37:09 -04001467 u16 pvlan = 0;
1468
1469 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001470 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001471
1472 /* Skip the local source device, which uses in-chip port VLAN */
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001473 if (dev != chip->ds->index) {
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001474 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001475
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001476 ds = dsa_switch_find(dst->index, dev);
1477 dp = ds ? dsa_to_port(ds, port) : NULL;
1478 if (dp && dp->lag_dev) {
1479 /* As the PVT is used to limit flooding of
1480 * FORWARD frames, which use the LAG ID as the
1481 * source port, we must translate dev/port to
1482 * the special "LAG device" in the PVT, using
1483 * the LAG ID as the port number.
1484 */
Tobias Waldekranz78e70db2021-04-21 14:04:52 +02001485 dev = MV88E6XXX_G2_PVT_ADDR_DEV_TRUNK;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001486 port = dsa_lag_id(dst, dp->lag_dev);
1487 }
1488 }
1489
Vivien Didelot17a15942017-03-30 17:37:09 -04001490 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1491}
1492
Vivien Didelot81228992017-03-30 17:37:08 -04001493static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1494{
Vivien Didelot17a15942017-03-30 17:37:09 -04001495 int dev, port;
1496 int err;
1497
Vivien Didelot81228992017-03-30 17:37:08 -04001498 if (!mv88e6xxx_has_pvt(chip))
1499 return 0;
1500
1501 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1502 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1503 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001504 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1505 if (err)
1506 return err;
1507
1508 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1509 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1510 err = mv88e6xxx_pvt_map(chip, dev, port);
1511 if (err)
1512 return err;
1513 }
1514 }
1515
1516 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001517}
1518
Vivien Didelot749efcb2016-09-22 16:49:24 -04001519static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1520{
1521 struct mv88e6xxx_chip *chip = ds->priv;
1522 int err;
1523
Tobias Waldekranzffcec3f2021-03-18 20:25:34 +01001524 if (dsa_to_port(ds, port)->lag_dev)
1525 /* Hardware is incapable of fast-aging a LAG through a
1526 * regular ATU move operation. Until we have something
1527 * more fancy in place this is a no-op.
1528 */
1529 return;
1530
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001531 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001532 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001533 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001534
1535 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001536 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001537}
1538
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001539static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1540{
Tobias Waldekranze545f862020-11-10 19:57:20 +01001541 if (!mv88e6xxx_max_vid(chip))
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001542 return 0;
1543
1544 return mv88e6xxx_g1_vtu_flush(chip);
1545}
1546
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001547static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid,
1548 struct mv88e6xxx_vtu_entry *entry)
Vivien Didelotf1394b782017-05-01 14:05:22 -04001549{
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001550 int err;
1551
Vivien Didelotf1394b782017-05-01 14:05:22 -04001552 if (!chip->info->ops->vtu_getnext)
1553 return -EOPNOTSUPP;
1554
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001555 entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip);
1556 entry->valid = false;
1557
1558 err = chip->info->ops->vtu_getnext(chip, entry);
1559
1560 if (entry->vid != vid)
1561 entry->valid = false;
1562
1563 return err;
Vivien Didelotf1394b782017-05-01 14:05:22 -04001564}
1565
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001566static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip,
1567 int (*cb)(struct mv88e6xxx_chip *chip,
1568 const struct mv88e6xxx_vtu_entry *entry,
1569 void *priv),
1570 void *priv)
1571{
1572 struct mv88e6xxx_vtu_entry entry = {
1573 .vid = mv88e6xxx_max_vid(chip),
1574 .valid = false,
1575 };
1576 int err;
1577
1578 if (!chip->info->ops->vtu_getnext)
1579 return -EOPNOTSUPP;
1580
1581 do {
1582 err = chip->info->ops->vtu_getnext(chip, &entry);
1583 if (err)
1584 return err;
1585
1586 if (!entry.valid)
1587 break;
1588
1589 err = cb(chip, &entry, priv);
1590 if (err)
1591 return err;
1592 } while (entry.vid < mv88e6xxx_max_vid(chip));
1593
1594 return 0;
1595}
1596
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001597static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1598 struct mv88e6xxx_vtu_entry *entry)
1599{
1600 if (!chip->info->ops->vtu_loadpurge)
1601 return -EOPNOTSUPP;
1602
1603 return chip->info->ops->vtu_loadpurge(chip, entry);
1604}
1605
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001606static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip,
1607 const struct mv88e6xxx_vtu_entry *entry,
1608 void *_fid_bitmap)
1609{
1610 unsigned long *fid_bitmap = _fid_bitmap;
1611
1612 set_bit(entry->fid, fid_bitmap);
1613 return 0;
1614}
1615
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001616int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001617{
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001618 int i, err;
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001619 u16 fid;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001620
1621 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1622
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001623 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001624 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001625 err = mv88e6xxx_port_get_fid(chip, i, &fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001626 if (err)
1627 return err;
1628
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001629 set_bit(fid, fid_bitmap);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001630 }
1631
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001632 /* Set every FID bit used by the VLAN entries */
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01001633 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap);
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001634}
1635
1636static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1637{
1638 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1639 int err;
1640
1641 err = mv88e6xxx_fid_map(chip, fid_bitmap);
1642 if (err)
1643 return err;
1644
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001645 /* The reset value 0x000 is used to indicate that multiple address
1646 * databases are not needed. Return the next positive available.
1647 */
1648 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001649 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001650 return -ENOSPC;
1651
1652 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001653 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001654}
1655
Vivien Didelotda9c3592016-02-12 12:09:40 -05001656static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001657 u16 vid)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001658{
Vivien Didelot04bed142016-08-31 18:06:13 -04001659 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001660 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001661 int i, err;
1662
Andrew Lunndb06ae412017-09-25 23:32:20 +02001663 /* DSA and CPU ports have to be members of multiple vlans */
1664 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1665 return 0;
1666
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001667 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001668 if (err)
1669 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001670
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001671 if (!vlan.valid)
1672 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001673
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001674 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
1675 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1676 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001677
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001678 if (!dsa_to_port(ds, i)->slave)
1679 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001680
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001681 if (vlan.member[i] ==
1682 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
1683 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001684
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001685 if (dsa_to_port(ds, i)->bridge_dev ==
1686 dsa_to_port(ds, port)->bridge_dev)
1687 break; /* same bridge, check next VLAN */
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 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001691
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001692 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1693 port, vlan.vid, i,
1694 netdev_name(dsa_to_port(ds, i)->bridge_dev));
1695 return -EOPNOTSUPP;
1696 }
Vivien Didelotda9c3592016-02-12 12:09:40 -05001697
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001698 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001699}
1700
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001701static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port)
1702{
1703 struct dsa_port *dp = dsa_to_port(chip->ds, port);
1704 struct mv88e6xxx_port *p = &chip->ports[port];
Vladimir Oltean5bded822021-10-07 19:47:11 +03001705 u16 pvid = MV88E6XXX_VID_STANDALONE;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001706 bool drop_untagged = false;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001707 int err;
1708
Vladimir Oltean5bded822021-10-07 19:47:11 +03001709 if (dp->bridge_dev) {
1710 if (br_vlan_enabled(dp->bridge_dev)) {
1711 pvid = p->bridge_pvid.vid;
1712 drop_untagged = !p->bridge_pvid.valid;
1713 } else {
1714 pvid = MV88E6XXX_VID_BRIDGED;
1715 }
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001716 }
1717
1718 err = mv88e6xxx_port_set_pvid(chip, port, pvid);
1719 if (err)
1720 return err;
1721
1722 return mv88e6xxx_port_drop_untagged(chip, port, drop_untagged);
1723}
1724
Vivien Didelotf81ec902016-05-09 13:22:58 -04001725static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
Vladimir Oltean89153ed2021-02-13 22:43:19 +02001726 bool vlan_filtering,
1727 struct netlink_ext_ack *extack)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001728{
Vivien Didelot04bed142016-08-31 18:06:13 -04001729 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001730 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1731 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001732 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001733
Vladimir Olteanbae33f22021-01-09 02:01:50 +02001734 if (!mv88e6xxx_max_vid(chip))
1735 return -EOPNOTSUPP;
Vivien Didelot54d77b52016-05-09 13:22:47 -04001736
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001737 mv88e6xxx_reg_lock(chip);
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001738
Vivien Didelot385a0992016-11-04 03:23:31 +01001739 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03001740 if (err)
1741 goto unlock;
1742
1743 err = mv88e6xxx_port_commit_pvid(chip, port);
1744 if (err)
1745 goto unlock;
1746
1747unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001748 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001749
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001750 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001751}
1752
Vivien Didelot57d32312016-06-20 13:13:58 -04001753static int
1754mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001755 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001756{
Vivien Didelot04bed142016-08-31 18:06:13 -04001757 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001758 int err;
1759
Tobias Waldekranze545f862020-11-10 19:57:20 +01001760 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001761 return -EOPNOTSUPP;
1762
Vivien Didelotda9c3592016-02-12 12:09:40 -05001763 /* If the requested port doesn't belong to the same bridge as the VLAN
1764 * members, do not support it (yet) and fallback to software VLAN.
1765 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001766 mv88e6xxx_reg_lock(chip);
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001767 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001768 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001769
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001770 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001771}
1772
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001773static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1774 const unsigned char *addr, u16 vid,
1775 u8 state)
1776{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001777 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001778 struct mv88e6xxx_vtu_entry vlan;
1779 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001780 int err;
1781
Vladimir Oltean5bded822021-10-07 19:47:11 +03001782 /* Ports have two private address databases: one for when the port is
1783 * standalone and one for when the port is under a bridge and the
1784 * 802.1Q mode is disabled. When the port is standalone, DSA wants its
1785 * address database to remain 100% empty, so we never load an ATU entry
1786 * into a standalone port's database. Therefore, translate the null
1787 * VLAN ID into the port's database used for VLAN-unaware bridging.
1788 */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001789 if (vid == 0) {
Vladimir Oltean5bded822021-10-07 19:47:11 +03001790 fid = MV88E6XXX_FID_BRIDGED;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001791 } else {
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001792 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001793 if (err)
1794 return err;
1795
1796 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
Tobias Waldekranz34065c52021-03-18 20:25:36 +01001797 if (!vlan.valid)
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001798 return -EOPNOTSUPP;
1799
1800 fid = vlan.fid;
1801 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001802
Vivien Didelotd8291a92019-09-07 16:00:47 -04001803 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001804 ether_addr_copy(entry.mac, addr);
1805 eth_addr_dec(entry.mac);
1806
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001807 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001808 if (err)
1809 return err;
1810
1811 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001812 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001813 memset(&entry, 0, sizeof(entry));
1814 ether_addr_copy(entry.mac, addr);
1815 }
1816
1817 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001818 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001819 entry.portvec &= ~BIT(port);
1820 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001821 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001822 } else {
DENG Qingfangf72f2fb2021-01-30 21:43:34 +08001823 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
1824 entry.portvec = BIT(port);
1825 else
1826 entry.portvec |= BIT(port);
1827
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001828 entry.state = state;
1829 }
1830
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001831 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001832}
1833
Vivien Didelotda7dc872019-09-07 16:00:49 -04001834static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1835 const struct mv88e6xxx_policy *policy)
1836{
1837 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1838 enum mv88e6xxx_policy_action action = policy->action;
1839 const u8 *addr = policy->addr;
1840 u16 vid = policy->vid;
1841 u8 state;
1842 int err;
1843 int id;
1844
1845 if (!chip->info->ops->port_set_policy)
1846 return -EOPNOTSUPP;
1847
1848 switch (mapping) {
1849 case MV88E6XXX_POLICY_MAPPING_DA:
1850 case MV88E6XXX_POLICY_MAPPING_SA:
1851 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1852 state = 0; /* Dissociate the port and address */
1853 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1854 is_multicast_ether_addr(addr))
1855 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1856 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1857 is_unicast_ether_addr(addr))
1858 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1859 else
1860 return -EOPNOTSUPP;
1861
1862 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1863 state);
1864 if (err)
1865 return err;
1866 break;
1867 default:
1868 return -EOPNOTSUPP;
1869 }
1870
1871 /* Skip the port's policy clearing if the mapping is still in use */
1872 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1873 idr_for_each_entry(&chip->policies, policy, id)
1874 if (policy->port == port &&
1875 policy->mapping == mapping &&
1876 policy->action != action)
1877 return 0;
1878
1879 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1880}
1881
1882static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1883 struct ethtool_rx_flow_spec *fs)
1884{
1885 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1886 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1887 enum mv88e6xxx_policy_mapping mapping;
1888 enum mv88e6xxx_policy_action action;
1889 struct mv88e6xxx_policy *policy;
1890 u16 vid = 0;
1891 u8 *addr;
1892 int err;
1893 int id;
1894
1895 if (fs->location != RX_CLS_LOC_ANY)
1896 return -EINVAL;
1897
1898 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1899 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1900 else
1901 return -EOPNOTSUPP;
1902
1903 switch (fs->flow_type & ~FLOW_EXT) {
1904 case ETHER_FLOW:
1905 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1906 is_zero_ether_addr(mac_mask->h_source)) {
1907 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1908 addr = mac_entry->h_dest;
1909 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1910 !is_zero_ether_addr(mac_mask->h_source)) {
1911 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1912 addr = mac_entry->h_source;
1913 } else {
1914 /* Cannot support DA and SA mapping in the same rule */
1915 return -EOPNOTSUPP;
1916 }
1917 break;
1918 default:
1919 return -EOPNOTSUPP;
1920 }
1921
1922 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001923 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001924 return -EOPNOTSUPP;
1925 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1926 }
1927
1928 idr_for_each_entry(&chip->policies, policy, id) {
1929 if (policy->port == port && policy->mapping == mapping &&
1930 policy->action == action && policy->vid == vid &&
1931 ether_addr_equal(policy->addr, addr))
1932 return -EEXIST;
1933 }
1934
1935 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1936 if (!policy)
1937 return -ENOMEM;
1938
1939 fs->location = 0;
1940 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1941 GFP_KERNEL);
1942 if (err) {
1943 devm_kfree(chip->dev, policy);
1944 return err;
1945 }
1946
1947 memcpy(&policy->fs, fs, sizeof(*fs));
1948 ether_addr_copy(policy->addr, addr);
1949 policy->mapping = mapping;
1950 policy->action = action;
1951 policy->port = port;
1952 policy->vid = vid;
1953
1954 err = mv88e6xxx_policy_apply(chip, port, policy);
1955 if (err) {
1956 idr_remove(&chip->policies, fs->location);
1957 devm_kfree(chip->dev, policy);
1958 return err;
1959 }
1960
1961 return 0;
1962}
1963
1964static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1965 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1966{
1967 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1968 struct mv88e6xxx_chip *chip = ds->priv;
1969 struct mv88e6xxx_policy *policy;
1970 int err;
1971 int id;
1972
1973 mv88e6xxx_reg_lock(chip);
1974
1975 switch (rxnfc->cmd) {
1976 case ETHTOOL_GRXCLSRLCNT:
1977 rxnfc->data = 0;
1978 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1979 rxnfc->rule_cnt = 0;
1980 idr_for_each_entry(&chip->policies, policy, id)
1981 if (policy->port == port)
1982 rxnfc->rule_cnt++;
1983 err = 0;
1984 break;
1985 case ETHTOOL_GRXCLSRULE:
1986 err = -ENOENT;
1987 policy = idr_find(&chip->policies, fs->location);
1988 if (policy) {
1989 memcpy(fs, &policy->fs, sizeof(*fs));
1990 err = 0;
1991 }
1992 break;
1993 case ETHTOOL_GRXCLSRLALL:
1994 rxnfc->data = 0;
1995 rxnfc->rule_cnt = 0;
1996 idr_for_each_entry(&chip->policies, policy, id)
1997 if (policy->port == port)
1998 rule_locs[rxnfc->rule_cnt++] = id;
1999 err = 0;
2000 break;
2001 default:
2002 err = -EOPNOTSUPP;
2003 break;
2004 }
2005
2006 mv88e6xxx_reg_unlock(chip);
2007
2008 return err;
2009}
2010
2011static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
2012 struct ethtool_rxnfc *rxnfc)
2013{
2014 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
2015 struct mv88e6xxx_chip *chip = ds->priv;
2016 struct mv88e6xxx_policy *policy;
2017 int err;
2018
2019 mv88e6xxx_reg_lock(chip);
2020
2021 switch (rxnfc->cmd) {
2022 case ETHTOOL_SRXCLSRLINS:
2023 err = mv88e6xxx_policy_insert(chip, port, fs);
2024 break;
2025 case ETHTOOL_SRXCLSRLDEL:
2026 err = -ENOENT;
2027 policy = idr_remove(&chip->policies, fs->location);
2028 if (policy) {
2029 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
2030 err = mv88e6xxx_policy_apply(chip, port, policy);
2031 devm_kfree(chip->dev, policy);
2032 }
2033 break;
2034 default:
2035 err = -EOPNOTSUPP;
2036 break;
2037 }
2038
2039 mv88e6xxx_reg_unlock(chip);
2040
2041 return err;
2042}
2043
Andrew Lunn87fa8862017-11-09 22:29:56 +01002044static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
2045 u16 vid)
2046{
Andrew Lunn87fa8862017-11-09 22:29:56 +01002047 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
Tobias Waldekranz0806dd462021-03-18 20:25:37 +01002048 u8 broadcast[ETH_ALEN];
2049
2050 eth_broadcast_addr(broadcast);
Andrew Lunn87fa8862017-11-09 22:29:56 +01002051
2052 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
2053}
2054
2055static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
2056{
2057 int port;
2058 int err;
2059
2060 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01002061 struct dsa_port *dp = dsa_to_port(chip->ds, port);
2062 struct net_device *brport;
2063
2064 if (dsa_is_unused_port(chip->ds, port))
2065 continue;
2066
2067 brport = dsa_port_to_bridge_port(dp);
2068 if (brport && !br_port_flag_is_set(brport, BR_BCAST_FLOOD))
2069 /* Skip bridged user ports where broadcast
2070 * flooding is disabled.
2071 */
2072 continue;
2073
Andrew Lunn87fa8862017-11-09 22:29:56 +01002074 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
2075 if (err)
2076 return err;
2077 }
2078
2079 return 0;
2080}
2081
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01002082struct mv88e6xxx_port_broadcast_sync_ctx {
2083 int port;
2084 bool flood;
2085};
2086
2087static int
2088mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip,
2089 const struct mv88e6xxx_vtu_entry *vlan,
2090 void *_ctx)
2091{
2092 struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx;
2093 u8 broadcast[ETH_ALEN];
2094 u8 state;
2095
2096 if (ctx->flood)
2097 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
2098 else
2099 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED;
2100
2101 eth_broadcast_addr(broadcast);
2102
2103 return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast,
2104 vlan->vid, state);
2105}
2106
2107static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port,
2108 bool flood)
2109{
2110 struct mv88e6xxx_port_broadcast_sync_ctx ctx = {
2111 .port = port,
2112 .flood = flood,
2113 };
2114 struct mv88e6xxx_vtu_entry vid0 = {
2115 .vid = 0,
2116 };
2117 int err;
2118
2119 /* Update the port's private database... */
2120 err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx);
2121 if (err)
2122 return err;
2123
2124 /* ...and the database for all VLANs. */
2125 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan,
2126 &ctx);
2127}
2128
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002129static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00002130 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002131{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002132 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002133 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002134 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002135
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002136 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002137 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002138 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002139
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002140 if (!vlan.valid) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002141 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002142
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002143 err = mv88e6xxx_atu_new(chip, &vlan.fid);
2144 if (err)
2145 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01002146
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002147 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
2148 if (i == port)
2149 vlan.member[i] = member;
2150 else
2151 vlan.member[i] = non_member;
2152
2153 vlan.vid = vid;
2154 vlan.valid = true;
2155
2156 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2157 if (err)
2158 return err;
2159
2160 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
2161 if (err)
2162 return err;
2163 } else if (vlan.member[port] != member) {
2164 vlan.member[port] = member;
2165
2166 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2167 if (err)
2168 return err;
Russell King933b4422020-02-26 17:14:26 +00002169 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002170 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
2171 port, vid);
2172 }
2173
2174 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002175}
2176
Vladimir Oltean1958d582021-01-09 02:01:53 +02002177static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vladimir Oltean31046a52021-02-13 22:43:18 +02002178 const struct switchdev_obj_port_vlan *vlan,
2179 struct netlink_ext_ack *extack)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002180{
Vivien Didelot04bed142016-08-31 18:06:13 -04002181 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002182 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
2183 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002184 struct mv88e6xxx_port *p = &chip->ports[port];
Russell King933b4422020-02-26 17:14:26 +00002185 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002186 u8 member;
Vladimir Oltean1958d582021-01-09 02:01:53 +02002187 int err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002188
Eldar Gasanovb8b79c42021-06-21 11:54:38 +03002189 if (!vlan->vid)
2190 return 0;
2191
Vladimir Oltean1958d582021-01-09 02:01:53 +02002192 err = mv88e6xxx_port_vlan_prepare(ds, port, vlan);
2193 if (err)
2194 return err;
Vivien Didelot54d77b52016-05-09 13:22:47 -04002195
Vivien Didelotc91498e2017-06-07 18:12:13 -04002196 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002197 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002198 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002199 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002200 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002201 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002202
Russell King933b4422020-02-26 17:14:26 +00002203 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
2204 * and then the CPU port. Do not warn for duplicates for the CPU port.
2205 */
2206 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
2207
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002208 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002209
Vladimir Oltean1958d582021-01-09 02:01:53 +02002210 err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn);
2211 if (err) {
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002212 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
2213 vlan->vid, untagged ? 'u' : 't');
Vladimir Oltean1958d582021-01-09 02:01:53 +02002214 goto out;
2215 }
Vivien Didelot76e398a2015-11-01 12:33:55 -05002216
Vladimir Oltean1958d582021-01-09 02:01:53 +02002217 if (pvid) {
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002218 p->bridge_pvid.vid = vlan->vid;
2219 p->bridge_pvid.valid = true;
2220
2221 err = mv88e6xxx_port_commit_pvid(chip, port);
2222 if (err)
Vladimir Oltean1958d582021-01-09 02:01:53 +02002223 goto out;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002224 } else if (vlan->vid && p->bridge_pvid.vid == vlan->vid) {
2225 /* The old pvid was reinstalled as a non-pvid VLAN */
2226 p->bridge_pvid.valid = false;
2227
2228 err = mv88e6xxx_port_commit_pvid(chip, port);
2229 if (err)
2230 goto out;
Vladimir Oltean1958d582021-01-09 02:01:53 +02002231 }
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002232
Vladimir Oltean1958d582021-01-09 02:01:53 +02002233out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002234 mv88e6xxx_reg_unlock(chip);
Vladimir Oltean1958d582021-01-09 02:01:53 +02002235
2236 return err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002237}
2238
Vivien Didelot521098922019-08-01 14:36:36 -04002239static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2240 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002241{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002242 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002243 int i, err;
2244
Vivien Didelot521098922019-08-01 14:36:36 -04002245 if (!vid)
Vladimir Olteanc92c7412021-07-22 16:05:51 +03002246 return 0;
Vivien Didelot521098922019-08-01 14:36:36 -04002247
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002248 err = mv88e6xxx_vtu_get(chip, vid, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002249 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002250 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002251
Vivien Didelot521098922019-08-01 14:36:36 -04002252 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2253 * tell switchdev that this VLAN is likely handled in software.
2254 */
Tobias Waldekranz34065c52021-03-18 20:25:36 +01002255 if (!vlan.valid ||
Vivien Didelot521098922019-08-01 14:36:36 -04002256 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002257 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002258
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002259 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002260
2261 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002262 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002263 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002264 if (vlan.member[i] !=
2265 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002266 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002267 break;
2268 }
2269 }
2270
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002271 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002272 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002273 return err;
2274
Vivien Didelote606ca32017-03-11 16:12:55 -05002275 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002276}
2277
Vivien Didelotf81ec902016-05-09 13:22:58 -04002278static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2279 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002280{
Vivien Didelot04bed142016-08-31 18:06:13 -04002281 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002282 struct mv88e6xxx_port *p = &chip->ports[port];
Vivien Didelot76e398a2015-11-01 12:33:55 -05002283 int err = 0;
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002284 u16 pvid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002285
Tobias Waldekranze545f862020-11-10 19:57:20 +01002286 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04002287 return -EOPNOTSUPP;
2288
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002289 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002290
Vivien Didelot77064f32016-11-04 03:23:30 +01002291 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002292 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002293 goto unlock;
2294
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002295 err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid);
2296 if (err)
2297 goto unlock;
2298
2299 if (vlan->vid == pvid) {
Vladimir Oltean8b6836d2021-10-07 19:47:10 +03002300 p->bridge_pvid.valid = false;
2301
2302 err = mv88e6xxx_port_commit_pvid(chip, port);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002303 if (err)
2304 goto unlock;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002305 }
2306
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002307unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002308 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002309
2310 return err;
2311}
2312
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002313static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2314 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002315{
Vivien Didelot04bed142016-08-31 18:06:13 -04002316 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002317 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002318
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002319 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002320 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2321 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002322 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002323
2324 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002325}
2326
Vivien Didelotf81ec902016-05-09 13:22:58 -04002327static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002328 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002329{
Vivien Didelot04bed142016-08-31 18:06:13 -04002330 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002331 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002332
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002333 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002334 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002335 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002336
Vivien Didelot83dabd12016-08-31 11:50:04 -04002337 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002338}
2339
Vivien Didelot83dabd12016-08-31 11:50:04 -04002340static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2341 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002342 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002343{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002344 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002345 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002346 int err;
2347
Vivien Didelotd8291a92019-09-07 16:00:47 -04002348 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002349 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002350
2351 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002352 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002353 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002354 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002355
Vivien Didelotd8291a92019-09-07 16:00:47 -04002356 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002357 break;
2358
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002359 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002360 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002361
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002362 if (!is_unicast_ether_addr(addr.mac))
2363 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002364
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002365 is_static = (addr.state ==
2366 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2367 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002368 if (err)
2369 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002370 } while (!is_broadcast_ether_addr(addr.mac));
2371
2372 return err;
2373}
2374
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002375struct mv88e6xxx_port_db_dump_vlan_ctx {
2376 int port;
2377 dsa_fdb_dump_cb_t *cb;
2378 void *data;
2379};
2380
2381static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip,
2382 const struct mv88e6xxx_vtu_entry *entry,
2383 void *_data)
2384{
2385 struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data;
2386
2387 return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid,
2388 ctx->port, ctx->cb, ctx->data);
2389}
2390
Vivien Didelot83dabd12016-08-31 11:50:04 -04002391static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002392 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002393{
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002394 struct mv88e6xxx_port_db_dump_vlan_ctx ctx = {
2395 .port = port,
2396 .cb = cb,
2397 .data = data,
2398 };
Vivien Didelot83dabd12016-08-31 11:50:04 -04002399 u16 fid;
2400 int err;
2401
2402 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002403 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002404 if (err)
2405 return err;
2406
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002407 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002408 if (err)
2409 return err;
2410
Tobias Waldekranzd89ef4b2021-03-18 20:25:35 +01002411 return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002412}
2413
Vivien Didelotf81ec902016-05-09 13:22:58 -04002414static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002415 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002416{
Vivien Didelot04bed142016-08-31 18:06:13 -04002417 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002418 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002419
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002420 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002421 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002422 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002423
2424 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002425}
2426
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002427static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2428 struct net_device *br)
2429{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002430 struct dsa_switch *ds = chip->ds;
2431 struct dsa_switch_tree *dst = ds->dst;
2432 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002433 int err;
2434
Vivien Didelotef2025e2019-10-21 16:51:27 -04002435 list_for_each_entry(dp, &dst->ports, list) {
2436 if (dp->bridge_dev == br) {
2437 if (dp->ds == ds) {
2438 /* This is a local bridge group member,
2439 * remap its Port VLAN Map.
2440 */
2441 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2442 if (err)
2443 return err;
2444 } else {
2445 /* This is an external bridge group member,
2446 * remap its cross-chip Port VLAN Table entry.
2447 */
2448 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2449 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002450 if (err)
2451 return err;
2452 }
2453 }
2454 }
2455
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002456 return 0;
2457}
2458
Vivien Didelotf81ec902016-05-09 13:22:58 -04002459static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002460 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002461{
Vivien Didelot04bed142016-08-31 18:06:13 -04002462 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002463 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002464
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002465 mv88e6xxx_reg_lock(chip);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002466
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002467 err = mv88e6xxx_bridge_map(chip, br);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002468 if (err)
2469 goto unlock;
2470
2471 err = mv88e6xxx_port_commit_pvid(chip, port);
2472 if (err)
2473 goto unlock;
2474
2475unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002476 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002477
Vivien Didelot466dfa02016-02-26 13:16:05 -05002478 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002479}
2480
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002481static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2482 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002483{
Vivien Didelot04bed142016-08-31 18:06:13 -04002484 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Oltean5bded822021-10-07 19:47:11 +03002485 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002486
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002487 mv88e6xxx_reg_lock(chip);
Vladimir Oltean5bded822021-10-07 19:47:11 +03002488
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002489 if (mv88e6xxx_bridge_map(chip, br) ||
2490 mv88e6xxx_port_vlan_map(chip, port))
2491 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Vladimir Oltean5bded822021-10-07 19:47:11 +03002492
2493 err = mv88e6xxx_port_commit_pvid(chip, port);
2494 if (err)
2495 dev_err(ds->dev,
2496 "port %d failed to restore standalone pvid: %pe\n",
2497 port, ERR_PTR(err));
2498
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002499 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002500}
2501
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002502static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2503 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002504 int port, struct net_device *br)
2505{
2506 struct mv88e6xxx_chip *chip = ds->priv;
2507 int err;
2508
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002509 if (tree_index != ds->dst->index)
2510 return 0;
2511
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002512 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002513 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002514 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002515
2516 return err;
2517}
2518
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002519static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2520 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002521 int port, struct net_device *br)
2522{
2523 struct mv88e6xxx_chip *chip = ds->priv;
2524
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002525 if (tree_index != ds->dst->index)
2526 return;
2527
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002528 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002529 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002530 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002531 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002532}
2533
Vladimir Olteance5df682021-07-22 18:55:41 +03002534/* Treat the software bridge as a virtual single-port switch behind the
2535 * CPU and map in the PVT. First dst->last_switch elements are taken by
2536 * physical switches, so start from beyond that range.
2537 */
2538static int mv88e6xxx_map_virtual_bridge_to_pvt(struct dsa_switch *ds,
2539 int bridge_num)
2540{
2541 u8 dev = bridge_num + ds->dst->last_switch + 1;
2542 struct mv88e6xxx_chip *chip = ds->priv;
2543 int err;
2544
2545 mv88e6xxx_reg_lock(chip);
2546 err = mv88e6xxx_pvt_map(chip, dev, 0);
2547 mv88e6xxx_reg_unlock(chip);
2548
2549 return err;
2550}
2551
2552static int mv88e6xxx_bridge_tx_fwd_offload(struct dsa_switch *ds, int port,
2553 struct net_device *br,
2554 int bridge_num)
2555{
2556 return mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num);
2557}
2558
2559static void mv88e6xxx_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port,
2560 struct net_device *br,
2561 int bridge_num)
2562{
2563 int err;
2564
2565 err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge_num);
2566 if (err) {
2567 dev_err(ds->dev, "failed to remap cross-chip Port VLAN: %pe\n",
2568 ERR_PTR(err));
2569 }
2570}
2571
Vivien Didelot17e708b2016-12-05 17:30:27 -05002572static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2573{
2574 if (chip->info->ops->reset)
2575 return chip->info->ops->reset(chip);
2576
2577 return 0;
2578}
2579
Vivien Didelot309eca62016-12-05 17:30:26 -05002580static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2581{
2582 struct gpio_desc *gpiod = chip->reset;
2583
2584 /* If there is a GPIO connected to the reset pin, toggle it */
2585 if (gpiod) {
2586 gpiod_set_value_cansleep(gpiod, 1);
2587 usleep_range(10000, 20000);
2588 gpiod_set_value_cansleep(gpiod, 0);
2589 usleep_range(10000, 20000);
Andrew Lunna3dcb3e2020-11-16 08:43:01 -08002590
2591 mv88e6xxx_g1_wait_eeprom_done(chip);
Vivien Didelot309eca62016-12-05 17:30:26 -05002592 }
2593}
2594
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002595static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2596{
2597 int i, err;
2598
2599 /* Set all ports to the Disabled state */
2600 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002601 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002602 if (err)
2603 return err;
2604 }
2605
2606 /* Wait for transmit queues to drain,
2607 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2608 */
2609 usleep_range(2000, 4000);
2610
2611 return 0;
2612}
2613
Vivien Didelotfad09c72016-06-21 12:28:20 -04002614static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002615{
Vivien Didelota935c052016-09-29 12:21:53 -04002616 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002617
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002618 err = mv88e6xxx_disable_ports(chip);
2619 if (err)
2620 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002621
Vivien Didelot309eca62016-12-05 17:30:26 -05002622 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002623
Vivien Didelot17e708b2016-12-05 17:30:27 -05002624 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002625}
2626
Vivien Didelot43145572017-03-11 16:12:59 -05002627static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002628 enum mv88e6xxx_frame_mode frame,
2629 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002630{
2631 int err;
2632
Vivien Didelot43145572017-03-11 16:12:59 -05002633 if (!chip->info->ops->port_set_frame_mode)
2634 return -EOPNOTSUPP;
2635
2636 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002637 if (err)
2638 return err;
2639
Vivien Didelot43145572017-03-11 16:12:59 -05002640 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2641 if (err)
2642 return err;
2643
2644 if (chip->info->ops->port_set_ether_type)
2645 return chip->info->ops->port_set_ether_type(chip, port, etype);
2646
2647 return 0;
2648}
2649
2650static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2651{
2652 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002653 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002654 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002655}
2656
2657static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2658{
2659 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002660 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002661 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002662}
2663
2664static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2665{
2666 return mv88e6xxx_set_port_mode(chip, port,
2667 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002668 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2669 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002670}
2671
2672static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2673{
2674 if (dsa_is_dsa_port(chip->ds, port))
2675 return mv88e6xxx_set_port_mode_dsa(chip, port);
2676
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002677 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002678 return mv88e6xxx_set_port_mode_normal(chip, port);
2679
2680 /* Setup CPU port mode depending on its supported tag format */
Tobias Waldekranz670bb802021-04-20 20:53:07 +02002681 if (chip->tag_protocol == DSA_TAG_PROTO_DSA)
Vivien Didelot43145572017-03-11 16:12:59 -05002682 return mv88e6xxx_set_port_mode_dsa(chip, port);
2683
Tobias Waldekranz670bb802021-04-20 20:53:07 +02002684 if (chip->tag_protocol == DSA_TAG_PROTO_EDSA)
Vivien Didelot43145572017-03-11 16:12:59 -05002685 return mv88e6xxx_set_port_mode_edsa(chip, port);
2686
2687 return -EINVAL;
2688}
2689
Vivien Didelotea698f42017-03-11 16:12:50 -05002690static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2691{
2692 bool message = dsa_is_dsa_port(chip->ds, port);
2693
2694 return mv88e6xxx_port_set_message_port(chip, port, message);
2695}
2696
Vivien Didelot601aeed2017-03-11 16:13:00 -05002697static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2698{
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002699 int err;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002700
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002701 if (chip->info->ops->port_set_ucast_flood) {
Tobias Waldekranz7b9f16f2021-03-18 20:25:38 +01002702 err = chip->info->ops->port_set_ucast_flood(chip, port, true);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002703 if (err)
2704 return err;
2705 }
2706 if (chip->info->ops->port_set_mcast_flood) {
Tobias Waldekranz7b9f16f2021-03-18 20:25:38 +01002707 err = chip->info->ops->port_set_mcast_flood(chip, port, true);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002708 if (err)
2709 return err;
2710 }
Vivien Didelot601aeed2017-03-11 16:13:00 -05002711
David S. Miller407308f2019-06-15 13:35:29 -07002712 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002713}
2714
Vivien Didelot45de77f2019-08-31 16:18:36 -04002715static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2716{
2717 struct mv88e6xxx_port *mvp = dev_id;
2718 struct mv88e6xxx_chip *chip = mvp->chip;
2719 irqreturn_t ret = IRQ_NONE;
2720 int port = mvp->port;
Pavana Sharma193c5b22021-03-17 14:46:40 +01002721 int lane;
Vivien Didelot45de77f2019-08-31 16:18:36 -04002722
2723 mv88e6xxx_reg_lock(chip);
2724 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +01002725 if (lane >= 0)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002726 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2727 mv88e6xxx_reg_unlock(chip);
2728
2729 return ret;
2730}
2731
2732static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
Pavana Sharma193c5b22021-03-17 14:46:40 +01002733 int lane)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002734{
2735 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2736 unsigned int irq;
2737 int err;
2738
2739 /* Nothing to request if this SERDES port has no IRQ */
2740 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2741 if (!irq)
2742 return 0;
2743
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002744 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2745 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2746
Vivien Didelot45de77f2019-08-31 16:18:36 -04002747 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2748 mv88e6xxx_reg_unlock(chip);
2749 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002750 IRQF_ONESHOT, dev_id->serdes_irq_name,
2751 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002752 mv88e6xxx_reg_lock(chip);
2753 if (err)
2754 return err;
2755
2756 dev_id->serdes_irq = irq;
2757
2758 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2759}
2760
2761static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
Pavana Sharma193c5b22021-03-17 14:46:40 +01002762 int lane)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002763{
2764 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2765 unsigned int irq = dev_id->serdes_irq;
2766 int err;
2767
2768 /* Nothing to free if no IRQ has been requested */
2769 if (!irq)
2770 return 0;
2771
2772 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2773
2774 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2775 mv88e6xxx_reg_unlock(chip);
2776 free_irq(irq, dev_id);
2777 mv88e6xxx_reg_lock(chip);
2778
2779 dev_id->serdes_irq = 0;
2780
2781 return err;
2782}
2783
Andrew Lunn6d917822017-05-26 01:03:21 +02002784static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2785 bool on)
2786{
Pavana Sharma193c5b22021-03-17 14:46:40 +01002787 int lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002788 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002789
Vivien Didelotdc272f62019-08-31 16:18:33 -04002790 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +01002791 if (lane < 0)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002792 return 0;
2793
2794 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002795 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002796 if (err)
2797 return err;
2798
Vivien Didelot45de77f2019-08-31 16:18:36 -04002799 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002800 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002801 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2802 if (err)
2803 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002804
Vivien Didelotdc272f62019-08-31 16:18:33 -04002805 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002806 }
2807
2808 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002809}
2810
Marek Behún2fda45f2021-03-17 14:46:41 +01002811static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip,
2812 enum mv88e6xxx_egress_direction direction,
2813 int port)
2814{
2815 int err;
2816
2817 if (!chip->info->ops->set_egress_port)
2818 return -EOPNOTSUPP;
2819
2820 err = chip->info->ops->set_egress_port(chip, direction, port);
2821 if (err)
2822 return err;
2823
2824 if (direction == MV88E6XXX_EGRESS_DIR_INGRESS)
2825 chip->ingress_dest_port = port;
2826 else
2827 chip->egress_dest_port = port;
2828
2829 return 0;
2830}
2831
Vivien Didelotfa371c82017-12-05 15:34:10 -05002832static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2833{
2834 struct dsa_switch *ds = chip->ds;
2835 int upstream_port;
2836 int err;
2837
Vivien Didelot07073c72017-12-05 15:34:13 -05002838 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002839 if (chip->info->ops->port_set_upstream_port) {
2840 err = chip->info->ops->port_set_upstream_port(chip, port,
2841 upstream_port);
2842 if (err)
2843 return err;
2844 }
2845
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002846 if (port == upstream_port) {
2847 if (chip->info->ops->set_cpu_port) {
2848 err = chip->info->ops->set_cpu_port(chip,
2849 upstream_port);
2850 if (err)
2851 return err;
2852 }
2853
Marek Behún2fda45f2021-03-17 14:46:41 +01002854 err = mv88e6xxx_set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002855 MV88E6XXX_EGRESS_DIR_INGRESS,
2856 upstream_port);
Marek Behún2fda45f2021-03-17 14:46:41 +01002857 if (err && err != -EOPNOTSUPP)
2858 return err;
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002859
Marek Behún2fda45f2021-03-17 14:46:41 +01002860 err = mv88e6xxx_set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002861 MV88E6XXX_EGRESS_DIR_EGRESS,
2862 upstream_port);
Marek Behún2fda45f2021-03-17 14:46:41 +01002863 if (err && err != -EOPNOTSUPP)
2864 return err;
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002865 }
2866
Vivien Didelotfa371c82017-12-05 15:34:10 -05002867 return 0;
2868}
2869
Vivien Didelotfad09c72016-06-21 12:28:20 -04002870static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002871{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002872 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002873 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002874 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002875
Andrew Lunn7b898462018-08-09 15:38:47 +02002876 chip->ports[port].chip = chip;
2877 chip->ports[port].port = port;
2878
Vivien Didelotd78343d2016-11-04 03:23:36 +01002879 /* MAC Forcing register: don't force link, speed, duplex or flow control
2880 * state to any particular values on physical ports, but force the CPU
2881 * port and all DSA ports to their maximum bandwidth and full duplex.
2882 */
2883 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2884 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2885 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002886 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002887 PHY_INTERFACE_MODE_NA);
2888 else
2889 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2890 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002891 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002892 PHY_INTERFACE_MODE_NA);
2893 if (err)
2894 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002895
2896 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2897 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2898 * tunneling, determine priority by looking at 802.1p and IP
2899 * priority fields (IP prio has precedence), and set STP state
2900 * to Forwarding.
2901 *
2902 * If this is the CPU link, use DSA or EDSA tagging depending
2903 * on which tagging mode was configured.
2904 *
2905 * If this is a link to another switch, use DSA tagging mode.
2906 *
2907 * If this is the upstream port for this switch, enable
2908 * forwarding of unknown unicasts and multicasts.
2909 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002910 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2911 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2912 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2913 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002914 if (err)
2915 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002916
Vivien Didelot601aeed2017-03-11 16:13:00 -05002917 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002918 if (err)
2919 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002920
Vivien Didelot601aeed2017-03-11 16:13:00 -05002921 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002922 if (err)
2923 return err;
2924
Andrew Lunnb92ce2f2021-09-26 19:41:25 +02002925 /* Port Control 2: don't force a good FCS, set the MTU size to
2926 * 10222 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002927 * untagged frames on this port, do a destination address lookup on all
2928 * received packets as usual, disable ARP mirroring and don't send a
2929 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002930 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002931 err = mv88e6xxx_port_set_map_da(chip, port);
2932 if (err)
2933 return err;
2934
Vivien Didelotfa371c82017-12-05 15:34:10 -05002935 err = mv88e6xxx_setup_upstream_port(chip, port);
2936 if (err)
2937 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002938
Andrew Lunna23b2962017-02-04 20:15:28 +01002939 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002940 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002941 if (err)
2942 return err;
2943
Vladimir Oltean5bded822021-10-07 19:47:11 +03002944 /* Associate MV88E6XXX_VID_BRIDGED with MV88E6XXX_FID_BRIDGED in the
2945 * ATU by virtue of the fact that mv88e6xxx_atu_new() will pick it as
2946 * the first free FID after MV88E6XXX_FID_STANDALONE. This will be used
2947 * as the private PVID on ports under a VLAN-unaware bridge.
2948 * Shared (DSA and CPU) ports must also be members of it, to translate
2949 * the VID from the DSA tag into MV88E6XXX_FID_BRIDGED, instead of
2950 * relying on their port default FID.
2951 */
2952 err = mv88e6xxx_port_vlan_join(chip, port, MV88E6XXX_VID_BRIDGED,
2953 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED,
2954 false);
2955 if (err)
2956 return err;
2957
Vivien Didelotcd782652017-06-08 18:34:13 -04002958 if (chip->info->ops->port_set_jumbo_size) {
Andrew Lunnb92ce2f2021-09-26 19:41:25 +02002959 err = chip->info->ops->port_set_jumbo_size(chip, port, 10218);
Andrew Lunn5f436662016-12-03 04:45:17 +01002960 if (err)
2961 return err;
2962 }
2963
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002964 /* Port Association Vector: disable automatic address learning
2965 * on all user ports since they start out in standalone
2966 * mode. When joining a bridge, learning will be configured to
2967 * match the bridge port settings. Enable learning on all
2968 * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the
2969 * learning process.
2970 *
2971 * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData,
2972 * and RefreshLocked. I.e. setup standard automatic learning.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002973 */
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002974 if (dsa_is_user_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002975 reg = 0;
Tobias Waldekranz041bd542021-03-18 20:25:39 +01002976 else
2977 reg = 1 << port;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002978
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002979 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2980 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002981 if (err)
2982 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002983
2984 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002985 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2986 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002987 if (err)
2988 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002989
Vivien Didelot08984322017-06-08 18:34:12 -04002990 if (chip->info->ops->port_pause_limit) {
2991 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002992 if (err)
2993 return err;
2994 }
2995
Vivien Didelotc8c94892017-03-11 16:13:01 -05002996 if (chip->info->ops->port_disable_learn_limit) {
2997 err = chip->info->ops->port_disable_learn_limit(chip, port);
2998 if (err)
2999 return err;
3000 }
3001
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003002 if (chip->info->ops->port_disable_pri_override) {
3003 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003004 if (err)
3005 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01003006 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02003007
Andrew Lunnef0a7312016-12-03 04:35:16 +01003008 if (chip->info->ops->port_tag_remap) {
3009 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003010 if (err)
3011 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003012 }
3013
Andrew Lunnef70b112016-12-03 04:45:18 +01003014 if (chip->info->ops->port_egress_rate_limiting) {
3015 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003016 if (err)
3017 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003018 }
3019
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003020 if (chip->info->ops->port_setup_message_port) {
3021 err = chip->info->ops->port_setup_message_port(chip, port);
3022 if (err)
3023 return err;
3024 }
Guenter Roeckd827e882015-03-26 18:36:29 -07003025
Vivien Didelot207afda2016-04-14 14:42:09 -04003026 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05003027 * database, and allow bidirectional communication between the
3028 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07003029 */
Vladimir Oltean5bded822021-10-07 19:47:11 +03003030 err = mv88e6xxx_port_set_fid(chip, port, MV88E6XXX_FID_STANDALONE);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003031 if (err)
3032 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05003033
Vivien Didelot240ea3e2017-03-30 17:37:12 -04003034 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02003035 if (err)
3036 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07003037
3038 /* Default VLAN ID and priority: don't set a default VLAN
3039 * ID, and set the default packet priority to zero.
3040 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04003041 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02003042}
3043
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003044static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
3045{
3046 struct mv88e6xxx_chip *chip = ds->priv;
3047
3048 if (chip->info->ops->port_set_jumbo_size)
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003049 return 10240 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
Chris Packham1baf0fa2020-07-24 11:21:22 +12003050 else if (chip->info->ops->set_max_frame_size)
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003051 return 1632 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
3052 return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003053}
3054
3055static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
3056{
3057 struct mv88e6xxx_chip *chip = ds->priv;
3058 int ret = 0;
3059
Andrew Lunnb9c587f2021-09-26 19:41:26 +02003060 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
3061 new_mtu += EDSA_HLEN;
3062
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003063 mv88e6xxx_reg_lock(chip);
3064 if (chip->info->ops->port_set_jumbo_size)
3065 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Chris Packham1baf0fa2020-07-24 11:21:22 +12003066 else if (chip->info->ops->set_max_frame_size)
3067 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
Andrew Lunn2a550ae2020-07-11 22:32:05 +02003068 else
3069 if (new_mtu > 1522)
3070 ret = -EINVAL;
3071 mv88e6xxx_reg_unlock(chip);
3072
3073 return ret;
3074}
3075
Andrew Lunn04aca992017-05-26 01:03:24 +02003076static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
3077 struct phy_device *phydev)
3078{
3079 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04003080 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02003081
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003082 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04003083 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003084 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02003085
3086 return err;
3087}
3088
Andrew Lunn75104db2019-02-24 20:44:43 +01003089static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02003090{
3091 struct mv88e6xxx_chip *chip = ds->priv;
3092
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003093 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04003094 if (mv88e6xxx_serdes_power(chip, port, false))
3095 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003096 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02003097}
3098
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003099static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
3100 unsigned int ageing_time)
3101{
Vivien Didelot04bed142016-08-31 18:06:13 -04003102 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003103 int err;
3104
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003105 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05003106 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003107 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04003108
3109 return err;
3110}
3111
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003112static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04003113{
3114 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04003115
Andrew Lunnde2273872016-11-21 23:27:01 +01003116 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003117 if (chip->info->ops->stats_set_histogram) {
3118 err = chip->info->ops->stats_set_histogram(chip);
3119 if (err)
3120 return err;
3121 }
Andrew Lunnde2273872016-11-21 23:27:01 +01003122
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003123 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04003124}
3125
Andrew Lunnea890982019-01-09 00:24:03 +01003126/* Check if the errata has already been applied. */
3127static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
3128{
3129 int port;
3130 int err;
3131 u16 val;
3132
3133 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02003134 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01003135 if (err) {
3136 dev_err(chip->dev,
3137 "Error reading hidden register: %d\n", err);
3138 return false;
3139 }
3140 if (val != 0x01c0)
3141 return false;
3142 }
3143
3144 return true;
3145}
3146
3147/* The 6390 copper ports have an errata which require poking magic
3148 * values into undocumented hidden registers and then performing a
3149 * software reset.
3150 */
3151static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
3152{
3153 int port;
3154 int err;
3155
3156 if (mv88e6390_setup_errata_applied(chip))
3157 return 0;
3158
3159 /* Set the ports into blocking mode */
3160 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
3161 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
3162 if (err)
3163 return err;
3164 }
3165
3166 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02003167 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01003168 if (err)
3169 return err;
3170 }
3171
3172 return mv88e6xxx_software_reset(chip);
3173}
3174
Andrew Lunn23e8b472019-10-25 01:03:52 +02003175static void mv88e6xxx_teardown(struct dsa_switch *ds)
3176{
3177 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003178 dsa_devlink_resources_unregister(ds);
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003179 mv88e6xxx_teardown_devlink_regions_global(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02003180}
3181
Vivien Didelotf81ec902016-05-09 13:22:58 -04003182static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07003183{
Vivien Didelot04bed142016-08-31 18:06:13 -04003184 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003185 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04003186 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04003187 int i;
3188
Vivien Didelotfad09c72016-06-21 12:28:20 -04003189 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003190 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003191
Vladimir Olteance5df682021-07-22 18:55:41 +03003192 /* Since virtual bridges are mapped in the PVT, the number we support
3193 * depends on the physical switch topology. We need to let DSA figure
3194 * that out and therefore we cannot set this at dsa_register_switch()
3195 * time.
3196 */
3197 if (mv88e6xxx_has_pvt(chip))
3198 ds->num_fwd_offloading_bridges = MV88E6XXX_MAX_PVT_SWITCHES -
3199 ds->dst->last_switch - 1;
3200
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003201 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003202
Andrew Lunnea890982019-01-09 00:24:03 +01003203 if (chip->info->ops->setup_errata) {
3204 err = chip->info->ops->setup_errata(chip);
3205 if (err)
3206 goto unlock;
3207 }
3208
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003209 /* Cache the cmode of each port. */
3210 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3211 if (chip->info->ops->port_get_cmode) {
3212 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3213 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003214 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003215
3216 chip->ports[i].cmode = cmode;
3217 }
3218 }
3219
Vladimir Oltean5bded822021-10-07 19:47:11 +03003220 err = mv88e6xxx_vtu_setup(chip);
3221 if (err)
3222 goto unlock;
3223
Vivien Didelot97299342016-07-18 20:45:30 -04003224 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003225 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003226 if (dsa_is_unused_port(ds, i))
3227 continue;
3228
Hubert Feursteinc8574862019-07-31 10:23:48 +02003229 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003230 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003231 dev_err(chip->dev, "port %d is invalid\n", i);
3232 err = -EINVAL;
3233 goto unlock;
3234 }
3235
Vivien Didelot97299342016-07-18 20:45:30 -04003236 err = mv88e6xxx_setup_port(chip, i);
3237 if (err)
3238 goto unlock;
3239 }
3240
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003241 err = mv88e6xxx_irl_setup(chip);
3242 if (err)
3243 goto unlock;
3244
Vivien Didelot04a69a12017-10-13 14:18:05 -04003245 err = mv88e6xxx_mac_setup(chip);
3246 if (err)
3247 goto unlock;
3248
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003249 err = mv88e6xxx_phy_setup(chip);
3250 if (err)
3251 goto unlock;
3252
Vivien Didelot81228992017-03-30 17:37:08 -04003253 err = mv88e6xxx_pvt_setup(chip);
3254 if (err)
3255 goto unlock;
3256
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003257 err = mv88e6xxx_atu_setup(chip);
3258 if (err)
3259 goto unlock;
3260
Andrew Lunn87fa8862017-11-09 22:29:56 +01003261 err = mv88e6xxx_broadcast_setup(chip, 0);
3262 if (err)
3263 goto unlock;
3264
Vivien Didelot9e907d72017-07-17 13:03:43 -04003265 err = mv88e6xxx_pot_setup(chip);
3266 if (err)
3267 goto unlock;
3268
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003269 err = mv88e6xxx_rmu_setup(chip);
3270 if (err)
3271 goto unlock;
3272
Vivien Didelot51c901a2017-07-17 13:03:41 -04003273 err = mv88e6xxx_rsvd2cpu_setup(chip);
3274 if (err)
3275 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003276
Vivien Didelotb28f8722018-04-26 21:56:44 -04003277 err = mv88e6xxx_trunk_setup(chip);
3278 if (err)
3279 goto unlock;
3280
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003281 err = mv88e6xxx_devmap_setup(chip);
3282 if (err)
3283 goto unlock;
3284
Vivien Didelot93e18d62018-05-11 17:16:35 -04003285 err = mv88e6xxx_pri_setup(chip);
3286 if (err)
3287 goto unlock;
3288
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003289 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003290 if (chip->info->ptp_support) {
3291 err = mv88e6xxx_ptp_setup(chip);
3292 if (err)
3293 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003294
3295 err = mv88e6xxx_hwtstamp_setup(chip);
3296 if (err)
3297 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003298 }
3299
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003300 err = mv88e6xxx_stats_setup(chip);
3301 if (err)
3302 goto unlock;
3303
Vivien Didelot6b17e862015-08-13 12:52:18 -04003304unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003305 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003306
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003307 if (err)
3308 return err;
3309
3310 /* Have to be called without holding the register lock, since
3311 * they take the devlink lock, and we later take the locks in
3312 * the reverse order when getting/setting parameters or
3313 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003314 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003315 err = mv88e6xxx_setup_devlink_resources(ds);
3316 if (err)
3317 return err;
3318
3319 err = mv88e6xxx_setup_devlink_params(ds);
3320 if (err)
Andrew Lunnbfb25542020-09-18 21:11:07 +02003321 goto out_resources;
3322
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003323 err = mv88e6xxx_setup_devlink_regions_global(ds);
Andrew Lunnbfb25542020-09-18 21:11:07 +02003324 if (err)
3325 goto out_params;
3326
3327 return 0;
3328
3329out_params:
3330 mv88e6xxx_teardown_devlink_params(ds);
3331out_resources:
3332 dsa_devlink_resources_unregister(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003333
3334 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003335}
3336
Vladimir Olteanfd292c12021-09-17 17:29:16 +03003337static int mv88e6xxx_port_setup(struct dsa_switch *ds, int port)
3338{
3339 return mv88e6xxx_setup_devlink_regions_port(ds, port);
3340}
3341
3342static void mv88e6xxx_port_teardown(struct dsa_switch *ds, int port)
3343{
3344 mv88e6xxx_teardown_devlink_regions_port(ds, port);
3345}
3346
Pali Rohár1fe976d2021-04-12 18:57:39 +02003347/* prod_id for switch families which do not have a PHY model number */
3348static const u16 family_prod_id_table[] = {
3349 [MV88E6XXX_FAMILY_6341] = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
3350 [MV88E6XXX_FAMILY_6390] = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Marek Behúnc5d015b2021-04-20 09:54:02 +02003351 [MV88E6XXX_FAMILY_6393] = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
Pali Rohár1fe976d2021-04-12 18:57:39 +02003352};
3353
Vivien Didelote57e5e72016-08-15 17:19:00 -04003354static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003355{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003356 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3357 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Pali Rohár1fe976d2021-04-12 18:57:39 +02003358 u16 prod_id;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003359 u16 val;
3360 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003361
Andrew Lunnee26a222017-01-24 14:53:48 +01003362 if (!chip->info->ops->phy_read)
3363 return -EOPNOTSUPP;
3364
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003365 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003366 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003367 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003368
Pali Rohár1fe976d2021-04-12 18:57:39 +02003369 /* Some internal PHYs don't have a model number. */
3370 if (reg == MII_PHYSID2 && !(val & 0x3f0) &&
3371 chip->info->family < ARRAY_SIZE(family_prod_id_table)) {
3372 prod_id = family_prod_id_table[chip->info->family];
3373 if (prod_id)
3374 val |= prod_id >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003375 }
3376
Vivien Didelote57e5e72016-08-15 17:19:00 -04003377 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003378}
3379
Vivien Didelote57e5e72016-08-15 17:19:00 -04003380static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003381{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003382 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3383 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003384 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003385
Andrew Lunnee26a222017-01-24 14:53:48 +01003386 if (!chip->info->ops->phy_write)
3387 return -EOPNOTSUPP;
3388
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003389 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003390 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003391 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003392
3393 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003394}
3395
Vivien Didelotfad09c72016-06-21 12:28:20 -04003396static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003397 struct device_node *np,
3398 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003399{
3400 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003401 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003402 struct mii_bus *bus;
3403 int err;
3404
Andrew Lunn2510bab2018-02-22 01:51:49 +01003405 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003406 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003407 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003408 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003409
3410 if (err)
3411 return err;
3412 }
3413
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003414 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003415 if (!bus)
3416 return -ENOMEM;
3417
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003418 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003419 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003420 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003421 INIT_LIST_HEAD(&mdio_bus->list);
3422 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003423
Andrew Lunnb516d452016-06-04 21:17:06 +02003424 if (np) {
3425 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003426 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003427 } else {
3428 bus->name = "mv88e6xxx SMI";
3429 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3430 }
3431
3432 bus->read = mv88e6xxx_mdio_read;
3433 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003434 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003435
Andrew Lunn6f882842018-03-17 20:32:05 +01003436 if (!external) {
3437 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3438 if (err)
3439 return err;
3440 }
3441
Florian Fainelli00e798c2018-05-15 16:56:19 -07003442 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003443 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003444 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003445 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003446 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003447 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003448
3449 if (external)
3450 list_add_tail(&mdio_bus->list, &chip->mdios);
3451 else
3452 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003453
3454 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003455}
3456
Andrew Lunn3126aee2017-12-07 01:05:57 +01003457static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3458
3459{
3460 struct mv88e6xxx_mdio_bus *mdio_bus;
3461 struct mii_bus *bus;
3462
3463 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3464 bus = mdio_bus->bus;
3465
Andrew Lunn6f882842018-03-17 20:32:05 +01003466 if (!mdio_bus->external)
3467 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3468
Andrew Lunn3126aee2017-12-07 01:05:57 +01003469 mdiobus_unregister(bus);
3470 }
3471}
3472
Andrew Lunna3c53be52017-01-24 14:53:50 +01003473static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3474 struct device_node *np)
3475{
Andrew Lunna3c53be52017-01-24 14:53:50 +01003476 struct device_node *child;
3477 int err;
3478
3479 /* Always register one mdio bus for the internal/default mdio
3480 * bus. This maybe represented in the device tree, but is
3481 * optional.
3482 */
3483 child = of_get_child_by_name(np, "mdio");
3484 err = mv88e6xxx_mdio_register(chip, child, false);
3485 if (err)
3486 return err;
3487
3488 /* Walk the device tree, and see if there are any other nodes
3489 * which say they are compatible with the external mdio
3490 * bus.
3491 */
3492 for_each_available_child_of_node(np, child) {
Andrew Lunnceb96fa2020-09-01 04:32:57 +02003493 if (of_device_is_compatible(
3494 child, "marvell,mv88e6xxx-mdio-external")) {
Andrew Lunna3c53be52017-01-24 14:53:50 +01003495 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003496 if (err) {
3497 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303498 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003499 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003500 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003501 }
3502 }
3503
3504 return 0;
3505}
3506
Vivien Didelot855b1932016-07-20 18:18:35 -04003507static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3508{
Vivien Didelot04bed142016-08-31 18:06:13 -04003509 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003510
3511 return chip->eeprom_len;
3512}
3513
Vivien Didelot855b1932016-07-20 18:18:35 -04003514static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3515 struct ethtool_eeprom *eeprom, u8 *data)
3516{
Vivien Didelot04bed142016-08-31 18:06:13 -04003517 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003518 int err;
3519
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003520 if (!chip->info->ops->get_eeprom)
3521 return -EOPNOTSUPP;
3522
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003523 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003524 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003525 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003526
3527 if (err)
3528 return err;
3529
3530 eeprom->magic = 0xc3ec4951;
3531
3532 return 0;
3533}
3534
Vivien Didelot855b1932016-07-20 18:18:35 -04003535static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3536 struct ethtool_eeprom *eeprom, u8 *data)
3537{
Vivien Didelot04bed142016-08-31 18:06:13 -04003538 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003539 int err;
3540
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003541 if (!chip->info->ops->set_eeprom)
3542 return -EOPNOTSUPP;
3543
Vivien Didelot855b1932016-07-20 18:18:35 -04003544 if (eeprom->magic != 0xc3ec4951)
3545 return -EINVAL;
3546
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003547 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003548 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003549 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003550
3551 return err;
3552}
3553
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003554static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003555 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003556 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3557 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003558 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003559 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003560 .phy_read = mv88e6185_phy_ppu_read,
3561 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003562 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003563 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003564 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003565 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003566 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003567 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3568 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003569 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003570 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003571 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003572 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003573 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003574 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003575 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003576 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003577 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003578 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3579 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003580 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003581 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3582 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003583 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003584 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003585 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003586 .ppu_enable = mv88e6185_g1_ppu_enable,
3587 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003588 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003589 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003590 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003591 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003592 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003593 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003594};
3595
3596static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003597 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003598 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3599 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003600 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003601 .phy_read = mv88e6185_phy_ppu_read,
3602 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003603 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003604 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003605 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003606 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003607 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3608 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunna23b2962017-02-04 20:15:28 +01003609 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003610 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003611 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003612 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003613 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003614 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3615 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003616 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003617 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003618 .serdes_power = mv88e6185_serdes_power,
3619 .serdes_get_lane = mv88e6185_serdes_get_lane,
3620 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003621 .ppu_enable = mv88e6185_g1_ppu_enable,
3622 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003623 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003624 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003625 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003626 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003627 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003628};
3629
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003630static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003631 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003632 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3633 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003634 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003635 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3636 .phy_read = mv88e6xxx_g2_smi_phy_read,
3637 .phy_write = mv88e6xxx_g2_smi_phy_write,
3638 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003639 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003640 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003641 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003642 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003643 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3644 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003645 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003646 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003647 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003648 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003649 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003650 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003651 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003652 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003653 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003654 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3655 .stats_get_strings = mv88e6095_stats_get_strings,
3656 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003657 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3658 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003659 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003660 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003661 .serdes_power = mv88e6185_serdes_power,
3662 .serdes_get_lane = mv88e6185_serdes_get_lane,
3663 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Chris Packham5c19bc82020-11-24 17:34:39 +13003664 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
3665 .serdes_irq_enable = mv88e6097_serdes_irq_enable,
3666 .serdes_irq_status = mv88e6097_serdes_irq_status,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003667 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003668 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003669 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003670 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003671 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003672 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003673 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003674};
3675
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003676static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003677 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003678 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3679 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003680 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003681 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003682 .phy_read = mv88e6xxx_g2_smi_phy_read,
3683 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003684 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003685 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003686 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003687 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003688 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3689 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003690 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003691 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003692 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003693 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003694 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003695 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003696 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3697 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003698 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003699 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3700 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003701 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003702 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003703 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003704 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003705 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3706 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003707 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003708 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003709 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003710 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003711};
3712
3713static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003714 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003715 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3716 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003717 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003718 .phy_read = mv88e6185_phy_ppu_read,
3719 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003720 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003721 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003722 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003723 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003724 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003725 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3726 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003727 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003728 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003729 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003730 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003731 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003732 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003733 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003734 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003735 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003736 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003737 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3738 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003739 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003740 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3741 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003742 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003743 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003744 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003745 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003746 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003747 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003748 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003749 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003750 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003751};
3752
Vivien Didelot990e27b2017-03-28 13:50:32 -04003753static const struct mv88e6xxx_ops mv88e6141_ops = {
3754 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003755 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3756 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003757 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003758 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3759 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3760 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3761 .phy_read = mv88e6xxx_g2_smi_phy_read,
3762 .phy_write = mv88e6xxx_g2_smi_phy_write,
3763 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003764 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003765 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003766 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003767 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003768 .port_tag_remap = mv88e6095_port_tag_remap,
Marek Behún7da467d2021-07-01 00:22:26 +02003769 .port_set_policy = mv88e6352_port_set_policy,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003770 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003771 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3772 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003773 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003774 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003775 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003776 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003777 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3778 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003779 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003780 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003781 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003782 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Marek Behún11527f32021-07-01 00:22:27 +02003783 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003784 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3785 .stats_get_strings = mv88e6320_stats_get_strings,
3786 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003787 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3788 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003789 .watchdog_ops = &mv88e6390_watchdog_ops,
3790 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003791 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003792 .reset = mv88e6352_g1_reset,
Marek Behún37094882021-07-01 00:22:28 +02003793 .rmu_disable = mv88e6390_g1_rmu_disable,
Marek Behúnc07fff32021-07-01 00:22:29 +02003794 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3795 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003796 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003797 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003798 .serdes_power = mv88e6390_serdes_power,
3799 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003800 /* Check status register pause & lpa register */
3801 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3802 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3803 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3804 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003805 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003806 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003807 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003808 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúna03b98d2021-07-01 00:22:30 +02003809 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
3810 .serdes_get_strings = mv88e6390_serdes_get_strings,
3811 .serdes_get_stats = mv88e6390_serdes_get_stats,
Marek Behún953b0dc2021-07-01 00:22:31 +02003812 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3813 .serdes_get_regs = mv88e6390_serdes_get_regs,
Marek Behúne3af71a2019-02-25 12:39:55 +01003814 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003815};
3816
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003817static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003818 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003819 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3820 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003821 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003822 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003823 .phy_read = mv88e6xxx_g2_smi_phy_read,
3824 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003825 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003826 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003827 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003828 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003829 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003830 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3831 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003832 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003833 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003834 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003835 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003836 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003837 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003838 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003839 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003840 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003841 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3842 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003843 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003844 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3845 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003846 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003847 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003848 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003849 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003850 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3851 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003852 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003853 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003854 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003855 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003856 .phylink_validate = mv88e6185_phylink_validate,
Andrew Lunnfe230362021-09-26 19:41:24 +02003857 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003858};
3859
3860static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003861 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003862 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3863 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003864 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003865 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003866 .phy_read = mv88e6165_phy_read,
3867 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003868 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003869 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003870 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003871 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003872 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003873 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003874 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003875 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003876 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003877 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3878 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003879 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003880 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3881 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003882 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003883 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003884 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003885 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003886 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3887 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003888 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003889 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003890 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003891 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003892 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003893};
3894
3895static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003896 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003897 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3898 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003899 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003900 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003901 .phy_read = mv88e6xxx_g2_smi_phy_read,
3902 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003903 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003904 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003905 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003906 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003907 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003908 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003909 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3910 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003911 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003912 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003913 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003914 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003915 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003916 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003917 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003918 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003919 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003920 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003921 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3922 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003923 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003924 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3925 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003926 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003927 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003928 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003929 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003930 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3931 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003932 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003933 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003934 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003935};
3936
3937static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003938 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003939 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3940 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003941 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003942 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3943 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003944 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003945 .phy_read = mv88e6xxx_g2_smi_phy_read,
3946 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003947 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003948 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003949 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003950 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003951 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003952 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003953 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003954 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3955 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003956 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003957 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003958 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003959 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003960 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003961 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003962 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003963 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003964 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003965 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003966 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3967 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003968 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003969 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3970 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003971 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003972 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003973 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003974 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003975 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003976 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3977 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003978 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003979 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003980 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003981 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3982 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3983 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3984 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003985 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003986 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3987 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003988 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003989 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003990};
3991
3992static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003993 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003994 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3995 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003996 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003997 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003998 .phy_read = mv88e6xxx_g2_smi_phy_read,
3999 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004000 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004001 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004002 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004003 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004004 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004005 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004006 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4007 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004008 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004009 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004010 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004011 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004012 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004013 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004014 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004015 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004016 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004017 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004018 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4019 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004020 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004021 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4022 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004023 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004024 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004025 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004026 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004027 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4028 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004029 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004030 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004031 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004032};
4033
4034static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004035 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004036 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4037 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004038 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004039 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4040 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004041 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004042 .phy_read = mv88e6xxx_g2_smi_phy_read,
4043 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004044 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004045 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004046 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004047 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004048 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004049 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004050 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004051 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4052 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004053 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004054 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004055 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004056 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004057 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004058 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004059 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004060 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004061 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004062 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004063 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4064 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004065 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004066 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4067 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004068 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004069 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004070 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004071 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004072 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004073 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4074 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004075 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004076 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004077 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004078 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4079 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4080 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4081 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004082 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004083 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004084 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004085 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004086 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4087 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004088 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004089 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004090};
4091
4092static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004093 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004094 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4095 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004096 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04004097 .phy_read = mv88e6185_phy_ppu_read,
4098 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004099 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004100 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004101 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004102 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004103 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
4104 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunnef70b112016-12-03 04:45:18 +01004105 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01004106 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02004107 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004108 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004109 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004110 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004111 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004112 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4113 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004114 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004115 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4116 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004117 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004118 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13004119 .serdes_power = mv88e6185_serdes_power,
4120 .serdes_get_lane = mv88e6185_serdes_get_lane,
4121 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelot02317e62018-05-09 11:38:49 -04004122 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05004123 .ppu_enable = mv88e6185_g1_ppu_enable,
4124 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004125 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004126 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004127 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004128 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12004129 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004130};
4131
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004132static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004133 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004134 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004135 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004136 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4137 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004138 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4139 .phy_read = mv88e6xxx_g2_smi_phy_read,
4140 .phy_write = mv88e6xxx_g2_smi_phy_write,
4141 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004142 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004143 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004144 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004145 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004146 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004147 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004148 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004149 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4150 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004151 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12004152 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04004153 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004154 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004155 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004156 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004157 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004158 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004159 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004160 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004161 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4162 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004163 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004164 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4165 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004166 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004167 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004168 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004169 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004170 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004171 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4172 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004173 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4174 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004175 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004176 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004177 /* Check status register pause & lpa register */
4178 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4179 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4180 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4181 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004182 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004183 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004184 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004185 .serdes_get_strings = mv88e6390_serdes_get_strings,
4186 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004187 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4188 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004189 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004190 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004191};
4192
4193static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004194 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004195 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004196 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004197 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4198 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004199 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4200 .phy_read = mv88e6xxx_g2_smi_phy_read,
4201 .phy_write = mv88e6xxx_g2_smi_phy_write,
4202 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004203 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004204 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004205 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004206 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004207 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004208 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004209 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004210 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4211 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004212 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12004213 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04004214 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004215 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004216 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004217 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004218 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004219 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004220 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004221 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004222 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4223 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004224 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004225 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4226 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004227 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004228 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004229 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004230 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004231 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004232 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4233 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004234 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4235 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004236 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004237 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004238 /* Check status register pause & lpa register */
4239 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4240 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4241 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4242 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004243 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004244 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004245 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004246 .serdes_get_strings = mv88e6390_serdes_get_strings,
4247 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004248 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4249 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004250 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004251 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004252};
4253
4254static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004255 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004256 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004257 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004258 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4259 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004260 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4261 .phy_read = mv88e6xxx_g2_smi_phy_read,
4262 .phy_write = mv88e6xxx_g2_smi_phy_write,
4263 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004264 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004265 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004266 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004267 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004268 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004269 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004270 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4271 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004272 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004273 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004274 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004275 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004276 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004277 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004278 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004279 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004280 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004281 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4282 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004283 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004284 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4285 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004286 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004287 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004288 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004289 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004290 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004291 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4292 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004293 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4294 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004295 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004296 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004297 /* Check status register pause & lpa register */
4298 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4299 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4300 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4301 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004302 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004303 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004304 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004305 .serdes_get_strings = mv88e6390_serdes_get_strings,
4306 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004307 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4308 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004309 .avb_ops = &mv88e6390_avb_ops,
4310 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004311 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004312};
4313
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004314static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004315 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004316 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4317 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004318 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004319 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4320 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004321 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004322 .phy_read = mv88e6xxx_g2_smi_phy_read,
4323 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004324 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004325 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004326 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004327 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004328 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004329 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004330 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004331 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4332 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004333 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004334 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004335 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004336 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004337 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004338 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004339 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004340 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004341 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004342 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004343 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4344 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004345 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004346 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4347 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004348 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004349 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004350 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004351 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004352 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004353 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4354 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004355 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004356 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004357 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004358 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4359 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4360 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4361 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004362 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004363 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004364 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004365 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004366 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4367 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004368 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004369 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004370 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004371 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004372};
4373
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004374static const struct mv88e6xxx_ops mv88e6250_ops = {
4375 /* MV88E6XXX_FAMILY_6250 */
4376 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4377 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4378 .irl_init_all = mv88e6352_g2_irl_init_all,
4379 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4380 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4381 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4382 .phy_read = mv88e6xxx_g2_smi_phy_read,
4383 .phy_write = mv88e6xxx_g2_smi_phy_write,
4384 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004385 .port_sync_link = mv88e6xxx_port_sync_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004386 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004387 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004388 .port_tag_remap = mv88e6095_port_tag_remap,
4389 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004390 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4391 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004392 .port_set_ether_type = mv88e6351_port_set_ether_type,
4393 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4394 .port_pause_limit = mv88e6097_port_pause_limit,
4395 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004396 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4397 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4398 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4399 .stats_get_strings = mv88e6250_stats_get_strings,
4400 .stats_get_stats = mv88e6250_stats_get_stats,
4401 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4402 .set_egress_port = mv88e6095_g1_set_egress_port,
4403 .watchdog_ops = &mv88e6250_watchdog_ops,
4404 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4405 .pot_clear = mv88e6xxx_g2_pot_clear,
4406 .reset = mv88e6250_g1_reset,
Rasmus Villemoes67c9ed12021-01-25 16:04:48 +01004407 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Rasmus Villemoesb28f3f32021-01-25 16:04:49 +01004408 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004409 .avb_ops = &mv88e6352_avb_ops,
4410 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004411 .phylink_validate = mv88e6065_phylink_validate,
4412};
4413
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004414static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004415 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004416 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004417 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004418 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4419 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004420 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4421 .phy_read = mv88e6xxx_g2_smi_phy_read,
4422 .phy_write = mv88e6xxx_g2_smi_phy_write,
4423 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004424 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004425 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004426 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004427 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004428 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004429 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004430 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004431 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4432 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004433 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004434 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004435 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004436 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004437 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004438 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004439 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004440 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004441 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004442 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4443 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004444 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004445 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4446 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004447 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004448 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004449 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004450 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004451 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004452 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4453 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004454 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4455 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004456 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004457 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004458 /* Check status register pause & lpa register */
4459 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4460 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4461 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4462 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004463 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004464 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004465 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004466 .serdes_get_strings = mv88e6390_serdes_get_strings,
4467 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004468 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4469 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004470 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004471 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004472 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004473 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004474};
4475
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004476static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004477 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004478 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4479 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004480 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004481 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4482 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004483 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004484 .phy_read = mv88e6xxx_g2_smi_phy_read,
4485 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004486 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004487 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004488 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004489 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004490 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004491 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4492 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004493 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004494 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004495 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004496 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004497 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004498 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004499 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004500 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004501 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004502 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004503 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4504 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004505 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004506 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4507 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004508 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004509 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004510 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004511 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004512 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004513 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004514 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004515 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004516 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004517 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004518};
4519
4520static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004521 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004522 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4523 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004524 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004525 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4526 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004527 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004528 .phy_read = mv88e6xxx_g2_smi_phy_read,
4529 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004530 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004531 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004532 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004533 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004534 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004535 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4536 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004537 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004538 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004539 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004540 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004541 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004542 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004543 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004544 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004545 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004546 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004547 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4548 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004549 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004550 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4551 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004552 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004553 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004554 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004555 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004556 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004557 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004558 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004559 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004560};
4561
Vivien Didelot16e329a2017-03-28 13:50:33 -04004562static const struct mv88e6xxx_ops mv88e6341_ops = {
4563 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004564 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4565 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004566 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004567 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4568 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4569 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4570 .phy_read = mv88e6xxx_g2_smi_phy_read,
4571 .phy_write = mv88e6xxx_g2_smi_phy_write,
4572 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004573 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004574 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004575 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004576 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004577 .port_tag_remap = mv88e6095_port_tag_remap,
Marek Behún7da467d2021-07-01 00:22:26 +02004578 .port_set_policy = mv88e6352_port_set_policy,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004579 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004580 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4581 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004582 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004583 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004584 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004585 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004586 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4587 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004588 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004589 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004590 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004591 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Marek Behún11527f32021-07-01 00:22:27 +02004592 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004593 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4594 .stats_get_strings = mv88e6320_stats_get_strings,
4595 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004596 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4597 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004598 .watchdog_ops = &mv88e6390_watchdog_ops,
4599 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004600 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004601 .reset = mv88e6352_g1_reset,
Marek Behún37094882021-07-01 00:22:28 +02004602 .rmu_disable = mv88e6390_g1_rmu_disable,
Marek Behúnc07fff32021-07-01 00:22:29 +02004603 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4604 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004605 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004606 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004607 .serdes_power = mv88e6390_serdes_power,
4608 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004609 /* Check status register pause & lpa register */
4610 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4611 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4612 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4613 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004614 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004615 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004616 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004617 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004618 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004619 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúna03b98d2021-07-01 00:22:30 +02004620 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4621 .serdes_get_strings = mv88e6390_serdes_get_strings,
4622 .serdes_get_stats = mv88e6390_serdes_get_stats,
Marek Behún953b0dc2021-07-01 00:22:31 +02004623 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4624 .serdes_get_regs = mv88e6390_serdes_get_regs,
Marek Behúne3af71a2019-02-25 12:39:55 +01004625 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004626};
4627
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004628static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004629 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004630 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4631 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004632 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004633 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004634 .phy_read = mv88e6xxx_g2_smi_phy_read,
4635 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004636 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004637 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004638 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004639 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004640 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004641 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004642 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4643 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004644 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004645 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004646 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004647 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004648 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004649 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004650 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004651 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004652 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004653 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004654 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4655 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004656 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004657 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4658 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004659 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004660 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004661 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004662 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004663 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4664 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004665 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004666 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004667 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004668};
4669
4670static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004671 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004672 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4673 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004674 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004675 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004676 .phy_read = mv88e6xxx_g2_smi_phy_read,
4677 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004678 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004679 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004680 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004681 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004682 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004683 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004684 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4685 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004686 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004687 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004688 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004689 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004690 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004691 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004692 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004693 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004694 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004695 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004696 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4697 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004698 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004699 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4700 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004701 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004702 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004703 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004704 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004705 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4706 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004707 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004708 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004709 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004710 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004711 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004712};
4713
4714static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004715 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004716 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4717 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004718 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004719 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4720 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004721 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004722 .phy_read = mv88e6xxx_g2_smi_phy_read,
4723 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004724 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004725 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004726 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004727 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004728 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004729 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004730 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004731 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4732 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004733 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004734 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004735 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004736 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004737 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004738 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004739 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004740 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004741 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004742 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004743 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4744 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004745 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004746 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4747 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004748 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004749 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004750 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004751 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004752 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004753 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4754 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004755 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004756 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004757 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004758 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4759 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4760 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4761 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004762 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004763 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004764 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004765 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004766 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004767 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004768 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004769 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4770 .serdes_get_strings = mv88e6352_serdes_get_strings,
4771 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004772 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4773 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004774 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004775};
4776
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004777static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004778 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004779 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004780 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004781 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4782 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004783 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4784 .phy_read = mv88e6xxx_g2_smi_phy_read,
4785 .phy_write = mv88e6xxx_g2_smi_phy_write,
4786 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004787 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004788 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004789 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004790 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004791 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004792 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004793 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004794 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4795 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004796 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004797 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004798 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004799 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004800 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004801 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004802 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004803 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004804 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004805 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004806 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004807 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4808 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004809 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004810 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4811 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004812 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004813 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004814 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004815 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004816 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004817 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4818 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004819 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4820 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004821 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004822 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004823 /* Check status register pause & lpa register */
4824 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4825 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4826 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4827 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004828 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004829 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004830 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004831 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004832 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004833 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004834 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4835 .serdes_get_strings = mv88e6390_serdes_get_strings,
4836 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004837 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4838 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004839 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004840};
4841
4842static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004843 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004844 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004845 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004846 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4847 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004848 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4849 .phy_read = mv88e6xxx_g2_smi_phy_read,
4850 .phy_write = mv88e6xxx_g2_smi_phy_write,
4851 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004852 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004853 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004854 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004855 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004856 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004857 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004858 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004859 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4860 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004861 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004862 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004863 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004864 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004865 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004866 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004867 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004868 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004869 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004870 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004871 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004872 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4873 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004874 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004875 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4876 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004877 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004878 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004879 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004880 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004881 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004882 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4883 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004884 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4885 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004886 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004887 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004888 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4889 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4890 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4891 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004892 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004893 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004894 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004895 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4896 .serdes_get_strings = mv88e6390_serdes_get_strings,
4897 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004898 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4899 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004900 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004901 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004902 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004903 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004904};
4905
Pavana Sharmade776d02021-03-17 14:46:42 +01004906static const struct mv88e6xxx_ops mv88e6393x_ops = {
4907 /* MV88E6XXX_FAMILY_6393 */
4908 .setup_errata = mv88e6393x_serdes_setup_errata,
4909 .irl_init_all = mv88e6390_g2_irl_init_all,
4910 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4911 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4912 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4913 .phy_read = mv88e6xxx_g2_smi_phy_read,
4914 .phy_write = mv88e6xxx_g2_smi_phy_write,
4915 .port_set_link = mv88e6xxx_port_set_link,
4916 .port_sync_link = mv88e6xxx_port_sync_link,
4917 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4918 .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex,
4919 .port_max_speed_mode = mv88e6393x_port_max_speed_mode,
4920 .port_tag_remap = mv88e6390_port_tag_remap,
Marek Behún6584b262021-03-17 14:46:43 +01004921 .port_set_policy = mv88e6393x_port_set_policy,
Pavana Sharmade776d02021-03-17 14:46:42 +01004922 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4923 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4924 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4925 .port_set_ether_type = mv88e6393x_port_set_ether_type,
4926 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4927 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4928 .port_pause_limit = mv88e6390_port_pause_limit,
4929 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4930 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4931 .port_get_cmode = mv88e6352_port_get_cmode,
4932 .port_set_cmode = mv88e6393x_port_set_cmode,
4933 .port_setup_message_port = mv88e6xxx_setup_message_port,
4934 .port_set_upstream_port = mv88e6393x_port_set_upstream_port,
4935 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4936 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4937 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4938 .stats_get_strings = mv88e6320_stats_get_strings,
4939 .stats_get_stats = mv88e6390_stats_get_stats,
4940 /* .set_cpu_port is missing because this family does not support a global
4941 * CPU port, only per port CPU port which is set via
4942 * .port_set_upstream_port method.
4943 */
4944 .set_egress_port = mv88e6393x_set_egress_port,
4945 .watchdog_ops = &mv88e6390_watchdog_ops,
4946 .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu,
4947 .pot_clear = mv88e6xxx_g2_pot_clear,
4948 .reset = mv88e6352_g1_reset,
4949 .rmu_disable = mv88e6390_g1_rmu_disable,
4950 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4951 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4952 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4953 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
4954 .serdes_power = mv88e6393x_serdes_power,
4955 .serdes_get_lane = mv88e6393x_serdes_get_lane,
4956 .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state,
4957 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4958 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4959 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
4960 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4961 .serdes_irq_enable = mv88e6393x_serdes_irq_enable,
4962 .serdes_irq_status = mv88e6393x_serdes_irq_status,
4963 /* TODO: serdes stats */
4964 .gpio_ops = &mv88e6352_gpio_ops,
4965 .avb_ops = &mv88e6390_avb_ops,
4966 .ptp_ops = &mv88e6352_ptp_ops,
4967 .phylink_validate = mv88e6393x_phylink_validate,
4968};
4969
Vivien Didelotf81ec902016-05-09 13:22:58 -04004970static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4971 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004972 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004973 .family = MV88E6XXX_FAMILY_6097,
4974 .name = "Marvell 88E6085",
4975 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004976 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004977 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004978 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004979 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004980 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004981 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004982 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004983 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004984 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004985 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004986 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004987 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004988 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004989 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004990 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004991 },
4992
4993 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004994 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004995 .family = MV88E6XXX_FAMILY_6095,
4996 .name = "Marvell 88E6095/88E6095F",
4997 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004998 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004999 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01005000 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005001 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005002 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005003 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005004 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005005 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005006 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005007 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05005008 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005009 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005010 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005011 },
5012
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005013 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005014 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005015 .family = MV88E6XXX_FAMILY_6097,
5016 .name = "Marvell 88E6097/88E6097F",
5017 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005018 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005019 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01005020 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005021 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005022 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005023 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005024 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005025 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005026 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01005027 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005028 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005029 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005030 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005031 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005032 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01005033 .ops = &mv88e6097_ops,
5034 },
5035
Vivien Didelotf81ec902016-05-09 13:22:58 -04005036 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005037 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005038 .family = MV88E6XXX_FAMILY_6165,
5039 .name = "Marvell 88E6123",
5040 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005041 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005042 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01005043 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005044 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005045 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005046 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005047 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005048 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005049 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005050 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005051 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005052 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005053 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005054 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005055 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005056 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005057 },
5058
5059 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005060 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005061 .family = MV88E6XXX_FAMILY_6185,
5062 .name = "Marvell 88E6131",
5063 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005064 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005065 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005066 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005067 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005068 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005069 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005070 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005071 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005072 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005073 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05005074 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005075 .multi_chip = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005076 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005077 },
5078
Vivien Didelot990e27b2017-03-28 13:50:32 -04005079 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005080 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005081 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01005082 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04005083 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005084 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005085 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005086 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005087 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005088 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005089 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005090 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005091 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005092 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005093 .age_time_coeff = 3750,
5094 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005095 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005096 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005097 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005098 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005099 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelot990e27b2017-03-28 13:50:32 -04005100 .ops = &mv88e6141_ops,
5101 },
5102
Vivien Didelotf81ec902016-05-09 13:22:58 -04005103 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005104 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005105 .family = MV88E6XXX_FAMILY_6165,
5106 .name = "Marvell 88E6161",
5107 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005108 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005109 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005110 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005111 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005112 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005113 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005114 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005115 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005116 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005117 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005118 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005119 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005120 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005121 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005122 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Andrew Lunndfa54342018-07-18 22:38:22 +02005123 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005124 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005125 },
5126
5127 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005128 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005129 .family = MV88E6XXX_FAMILY_6165,
5130 .name = "Marvell 88E6165",
5131 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005132 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005133 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01005134 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005135 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005136 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005137 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005138 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005139 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005140 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005141 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005142 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005143 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005144 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005145 .multi_chip = true,
Andrew Lunndfa54342018-07-18 22:38:22 +02005146 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005147 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005148 },
5149
5150 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005151 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005152 .family = MV88E6XXX_FAMILY_6351,
5153 .name = "Marvell 88E6171",
5154 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005155 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005156 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005157 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005158 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005159 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005160 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005161 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005162 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005163 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005164 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005165 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005166 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005167 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005168 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005169 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005170 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005171 },
5172
5173 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005174 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005175 .family = MV88E6XXX_FAMILY_6352,
5176 .name = "Marvell 88E6172",
5177 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005178 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005179 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005180 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005181 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005182 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005183 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005184 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005185 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005186 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005187 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005188 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005189 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005190 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005191 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005192 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005193 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005194 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005195 },
5196
5197 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005198 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005199 .family = MV88E6XXX_FAMILY_6351,
5200 .name = "Marvell 88E6175",
5201 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005202 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005203 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005204 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005205 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005206 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005207 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005208 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005209 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005210 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005211 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005212 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005213 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005214 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005215 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005216 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005217 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005218 },
5219
5220 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005221 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005222 .family = MV88E6XXX_FAMILY_6352,
5223 .name = "Marvell 88E6176",
5224 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005225 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005226 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005227 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005228 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005229 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005230 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005231 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005232 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005233 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005234 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005235 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005236 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005237 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005238 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005239 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005240 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005241 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005242 },
5243
5244 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005245 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005246 .family = MV88E6XXX_FAMILY_6185,
5247 .name = "Marvell 88E6185",
5248 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005249 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005250 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01005251 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005252 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005253 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005254 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005255 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005256 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005257 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005258 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05005259 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005260 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005261 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005262 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005263 },
5264
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005265 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005266 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005267 .family = MV88E6XXX_FAMILY_6390,
5268 .name = "Marvell 88E6190",
5269 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005270 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005271 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005272 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005273 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005274 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005275 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005276 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005277 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005278 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005279 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005280 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005281 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04005282 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005283 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05005284 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005285 .ops = &mv88e6190_ops,
5286 },
5287
5288 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005289 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005290 .family = MV88E6XXX_FAMILY_6390,
5291 .name = "Marvell 88E6190X",
5292 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005293 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005294 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005295 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005296 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005297 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005298 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005299 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005300 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005301 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005302 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005303 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005304 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005305 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005306 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005307 .multi_chip = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005308 .ops = &mv88e6190x_ops,
5309 },
5310
5311 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005312 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005313 .family = MV88E6XXX_FAMILY_6390,
5314 .name = "Marvell 88E6191",
5315 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005316 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005317 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005318 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005319 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005320 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005321 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005322 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005323 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005324 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005325 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005326 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005327 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005328 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005329 .multi_chip = true,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005330 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005331 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005332 },
5333
Pavana Sharmade776d02021-03-17 14:46:42 +01005334 [MV88E6191X] = {
5335 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X,
5336 .family = MV88E6XXX_FAMILY_6393,
5337 .name = "Marvell 88E6191X",
5338 .num_databases = 4096,
5339 .num_ports = 11, /* 10 + Z80 */
5340 .num_internal_phys = 9,
5341 .max_vid = 8191,
5342 .port_base_addr = 0x0,
5343 .phy_base_addr = 0x0,
5344 .global1_addr = 0x1b,
5345 .global2_addr = 0x1c,
5346 .age_time_coeff = 3750,
5347 .g1_irqs = 10,
5348 .g2_irqs = 14,
5349 .atu_move_port_mask = 0x1f,
5350 .pvt = true,
5351 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005352 .ptp_support = true,
5353 .ops = &mv88e6393x_ops,
5354 },
5355
5356 [MV88E6193X] = {
5357 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X,
5358 .family = MV88E6XXX_FAMILY_6393,
5359 .name = "Marvell 88E6193X",
5360 .num_databases = 4096,
5361 .num_ports = 11, /* 10 + Z80 */
5362 .num_internal_phys = 9,
5363 .max_vid = 8191,
5364 .port_base_addr = 0x0,
5365 .phy_base_addr = 0x0,
5366 .global1_addr = 0x1b,
5367 .global2_addr = 0x1c,
5368 .age_time_coeff = 3750,
5369 .g1_irqs = 10,
5370 .g2_irqs = 14,
5371 .atu_move_port_mask = 0x1f,
5372 .pvt = true,
5373 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005374 .ptp_support = true,
5375 .ops = &mv88e6393x_ops,
5376 },
5377
Hubert Feurstein49022642019-07-31 10:23:46 +02005378 [MV88E6220] = {
5379 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5380 .family = MV88E6XXX_FAMILY_6250,
5381 .name = "Marvell 88E6220",
5382 .num_databases = 64,
5383
5384 /* Ports 2-4 are not routed to pins
5385 * => usable ports 0, 1, 5, 6
5386 */
5387 .num_ports = 7,
5388 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005389 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005390 .max_vid = 4095,
5391 .port_base_addr = 0x08,
5392 .phy_base_addr = 0x00,
5393 .global1_addr = 0x0f,
5394 .global2_addr = 0x07,
5395 .age_time_coeff = 15000,
5396 .g1_irqs = 9,
5397 .g2_irqs = 10,
5398 .atu_move_port_mask = 0xf,
5399 .dual_chip = true,
Hubert Feurstein71509612019-07-31 10:23:51 +02005400 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005401 .ops = &mv88e6250_ops,
5402 },
5403
Vivien Didelotf81ec902016-05-09 13:22:58 -04005404 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005405 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005406 .family = MV88E6XXX_FAMILY_6352,
5407 .name = "Marvell 88E6240",
5408 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005409 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005410 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005411 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005412 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005413 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005414 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005415 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005416 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005417 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005418 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005419 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005420 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005421 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005422 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005423 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005424 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005425 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005426 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005427 },
5428
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005429 [MV88E6250] = {
5430 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5431 .family = MV88E6XXX_FAMILY_6250,
5432 .name = "Marvell 88E6250",
5433 .num_databases = 64,
5434 .num_ports = 7,
5435 .num_internal_phys = 5,
5436 .max_vid = 4095,
5437 .port_base_addr = 0x08,
5438 .phy_base_addr = 0x00,
5439 .global1_addr = 0x0f,
5440 .global2_addr = 0x07,
5441 .age_time_coeff = 15000,
5442 .g1_irqs = 9,
5443 .g2_irqs = 10,
5444 .atu_move_port_mask = 0xf,
5445 .dual_chip = true,
Hubert Feurstein71509612019-07-31 10:23:51 +02005446 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005447 .ops = &mv88e6250_ops,
5448 },
5449
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005450 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005451 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005452 .family = MV88E6XXX_FAMILY_6390,
5453 .name = "Marvell 88E6290",
5454 .num_databases = 4096,
5455 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005456 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005457 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005458 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005459 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005460 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005461 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005462 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005463 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005464 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005465 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005466 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005467 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005468 .multi_chip = true,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005469 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005470 .ops = &mv88e6290_ops,
5471 },
5472
Vivien Didelotf81ec902016-05-09 13:22:58 -04005473 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005474 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005475 .family = MV88E6XXX_FAMILY_6320,
5476 .name = "Marvell 88E6320",
5477 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005478 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005479 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005480 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005481 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005482 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005483 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005484 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005485 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005486 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005487 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005488 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005489 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005490 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005491 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005492 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005493 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005494 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005495 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005496 },
5497
5498 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005499 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005500 .family = MV88E6XXX_FAMILY_6320,
5501 .name = "Marvell 88E6321",
5502 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005503 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005504 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005505 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005506 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005507 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005508 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005509 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005510 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005511 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005512 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005513 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005514 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005515 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005516 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005517 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005518 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005519 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005520 },
5521
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005522 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005523 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005524 .family = MV88E6XXX_FAMILY_6341,
5525 .name = "Marvell 88E6341",
5526 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005527 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005528 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005529 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005530 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005531 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005532 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005533 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005534 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005535 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005536 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005537 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005538 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005539 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005540 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005541 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005542 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005543 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005544 .ops = &mv88e6341_ops,
5545 },
5546
Vivien Didelotf81ec902016-05-09 13:22:58 -04005547 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005548 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005549 .family = MV88E6XXX_FAMILY_6351,
5550 .name = "Marvell 88E6350",
5551 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005552 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005553 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005554 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005555 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005556 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005557 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005558 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005559 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005560 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005561 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005562 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005563 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005564 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005565 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005566 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005567 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005568 },
5569
5570 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005571 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005572 .family = MV88E6XXX_FAMILY_6351,
5573 .name = "Marvell 88E6351",
5574 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005575 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005576 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005577 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005578 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005579 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005580 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005581 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005582 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005583 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005584 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005585 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005586 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005587 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005588 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005589 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005590 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005591 },
5592
5593 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005594 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005595 .family = MV88E6XXX_FAMILY_6352,
5596 .name = "Marvell 88E6352",
5597 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005598 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005599 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005600 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005601 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005602 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005603 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005604 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005605 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005606 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005607 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005608 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005609 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005610 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005611 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005612 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005613 .edsa_support = MV88E6XXX_EDSA_SUPPORTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005614 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005615 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005616 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005617 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005618 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005619 .family = MV88E6XXX_FAMILY_6390,
5620 .name = "Marvell 88E6390",
5621 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005622 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005623 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005624 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005625 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005626 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005627 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005628 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005629 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005630 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005631 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005632 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005633 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005634 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005635 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005636 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005637 .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005638 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005639 .ops = &mv88e6390_ops,
5640 },
5641 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005642 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005643 .family = MV88E6XXX_FAMILY_6390,
5644 .name = "Marvell 88E6390X",
5645 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005646 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005647 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005648 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005649 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005650 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005651 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005652 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005653 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005654 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005655 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005656 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005657 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005658 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005659 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005660 .multi_chip = true,
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005661 .edsa_support = MV88E6XXX_EDSA_UNDOCUMENTED,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005662 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005663 .ops = &mv88e6390x_ops,
5664 },
Pavana Sharmade776d02021-03-17 14:46:42 +01005665
5666 [MV88E6393X] = {
5667 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
5668 .family = MV88E6XXX_FAMILY_6393,
5669 .name = "Marvell 88E6393X",
5670 .num_databases = 4096,
5671 .num_ports = 11, /* 10 + Z80 */
5672 .num_internal_phys = 9,
5673 .max_vid = 8191,
5674 .port_base_addr = 0x0,
5675 .phy_base_addr = 0x0,
5676 .global1_addr = 0x1b,
5677 .global2_addr = 0x1c,
5678 .age_time_coeff = 3750,
5679 .g1_irqs = 10,
5680 .g2_irqs = 14,
5681 .atu_move_port_mask = 0x1f,
5682 .pvt = true,
5683 .multi_chip = true,
Pavana Sharmade776d02021-03-17 14:46:42 +01005684 .ptp_support = true,
5685 .ops = &mv88e6393x_ops,
5686 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005687};
5688
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005689static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005690{
Vivien Didelota439c062016-04-17 13:23:58 -04005691 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005692
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005693 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5694 if (mv88e6xxx_table[i].prod_num == prod_num)
5695 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005696
Vivien Didelotb9b37712015-10-30 19:39:48 -04005697 return NULL;
5698}
5699
Vivien Didelotfad09c72016-06-21 12:28:20 -04005700static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005701{
5702 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005703 unsigned int prod_num, rev;
5704 u16 id;
5705 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005706
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005707 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005708 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005709 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005710 if (err)
5711 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005712
Vivien Didelot107fcc12017-06-12 12:37:36 -04005713 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5714 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005715
5716 info = mv88e6xxx_lookup_info(prod_num);
5717 if (!info)
5718 return -ENODEV;
5719
Vivien Didelotcaac8542016-06-20 13:14:09 -04005720 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005721 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005722
Vivien Didelotfad09c72016-06-21 12:28:20 -04005723 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5724 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005725
5726 return 0;
5727}
5728
Vivien Didelotfad09c72016-06-21 12:28:20 -04005729static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005730{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005731 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005732
Vivien Didelotfad09c72016-06-21 12:28:20 -04005733 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5734 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005735 return NULL;
5736
Vivien Didelotfad09c72016-06-21 12:28:20 -04005737 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005738
Vivien Didelotfad09c72016-06-21 12:28:20 -04005739 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005740 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005741 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005742
Vivien Didelotfad09c72016-06-21 12:28:20 -04005743 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005744}
5745
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005746static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005747 int port,
5748 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005749{
Vivien Didelot04bed142016-08-31 18:06:13 -04005750 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005751
Tobias Waldekranz670bb802021-04-20 20:53:07 +02005752 return chip->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005753}
5754
Tobias Waldekranz9a99bef2021-04-20 20:53:08 +02005755static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds, int port,
5756 enum dsa_tag_protocol proto)
5757{
5758 struct mv88e6xxx_chip *chip = ds->priv;
5759 enum dsa_tag_protocol old_protocol;
5760 int err;
5761
5762 switch (proto) {
5763 case DSA_TAG_PROTO_EDSA:
5764 switch (chip->info->edsa_support) {
5765 case MV88E6XXX_EDSA_UNSUPPORTED:
5766 return -EPROTONOSUPPORT;
5767 case MV88E6XXX_EDSA_UNDOCUMENTED:
5768 dev_warn(chip->dev, "Relying on undocumented EDSA tagging behavior\n");
5769 fallthrough;
5770 case MV88E6XXX_EDSA_SUPPORTED:
5771 break;
5772 }
5773 break;
5774 case DSA_TAG_PROTO_DSA:
5775 break;
5776 default:
5777 return -EPROTONOSUPPORT;
5778 }
5779
5780 old_protocol = chip->tag_protocol;
5781 chip->tag_protocol = proto;
5782
5783 mv88e6xxx_reg_lock(chip);
5784 err = mv88e6xxx_setup_port_mode(chip, port);
5785 mv88e6xxx_reg_unlock(chip);
5786
5787 if (err)
5788 chip->tag_protocol = old_protocol;
5789
5790 return err;
5791}
5792
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005793static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
5794 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005795{
Vivien Didelot04bed142016-08-31 18:06:13 -04005796 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005797 int err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005798
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005799 mv88e6xxx_reg_lock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005800 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
5801 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005802 mv88e6xxx_reg_unlock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005803
5804 return err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005805}
5806
5807static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5808 const struct switchdev_obj_port_mdb *mdb)
5809{
Vivien Didelot04bed142016-08-31 18:06:13 -04005810 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005811 int err;
5812
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005813 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005814 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005815 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005816
5817 return err;
5818}
5819
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005820static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5821 struct dsa_mall_mirror_tc_entry *mirror,
5822 bool ingress)
5823{
5824 enum mv88e6xxx_egress_direction direction = ingress ?
5825 MV88E6XXX_EGRESS_DIR_INGRESS :
5826 MV88E6XXX_EGRESS_DIR_EGRESS;
5827 struct mv88e6xxx_chip *chip = ds->priv;
5828 bool other_mirrors = false;
5829 int i;
5830 int err;
5831
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005832 mutex_lock(&chip->reg_lock);
5833 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5834 mirror->to_local_port) {
5835 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5836 other_mirrors |= ingress ?
5837 chip->ports[i].mirror_ingress :
5838 chip->ports[i].mirror_egress;
5839
5840 /* Can't change egress port when other mirror is active */
5841 if (other_mirrors) {
5842 err = -EBUSY;
5843 goto out;
5844 }
5845
Marek Behún2fda45f2021-03-17 14:46:41 +01005846 err = mv88e6xxx_set_egress_port(chip, direction,
5847 mirror->to_local_port);
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005848 if (err)
5849 goto out;
5850 }
5851
5852 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5853out:
5854 mutex_unlock(&chip->reg_lock);
5855
5856 return err;
5857}
5858
5859static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5860 struct dsa_mall_mirror_tc_entry *mirror)
5861{
5862 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5863 MV88E6XXX_EGRESS_DIR_INGRESS :
5864 MV88E6XXX_EGRESS_DIR_EGRESS;
5865 struct mv88e6xxx_chip *chip = ds->priv;
5866 bool other_mirrors = false;
5867 int i;
5868
5869 mutex_lock(&chip->reg_lock);
5870 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5871 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5872
5873 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5874 other_mirrors |= mirror->ingress ?
5875 chip->ports[i].mirror_ingress :
5876 chip->ports[i].mirror_egress;
5877
5878 /* Reset egress port when no other mirror is active */
5879 if (!other_mirrors) {
Marek Behún2fda45f2021-03-17 14:46:41 +01005880 if (mv88e6xxx_set_egress_port(chip, direction,
5881 dsa_upstream_port(ds, port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005882 dev_err(ds->dev, "failed to set egress port\n");
5883 }
5884
5885 mutex_unlock(&chip->reg_lock);
5886}
5887
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005888static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port,
5889 struct switchdev_brport_flags flags,
5890 struct netlink_ext_ack *extack)
5891{
5892 struct mv88e6xxx_chip *chip = ds->priv;
5893 const struct mv88e6xxx_ops *ops;
5894
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01005895 if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD |
5896 BR_BCAST_FLOOD))
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005897 return -EINVAL;
5898
5899 ops = chip->info->ops;
5900
5901 if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood)
5902 return -EINVAL;
5903
5904 if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood)
5905 return -EINVAL;
5906
5907 return 0;
5908}
5909
5910static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port,
5911 struct switchdev_brport_flags flags,
5912 struct netlink_ext_ack *extack)
Russell King4f859012019-02-20 15:35:05 -08005913{
5914 struct mv88e6xxx_chip *chip = ds->priv;
5915 int err = -EOPNOTSUPP;
5916
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005917 mv88e6xxx_reg_lock(chip);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005918
Tobias Waldekranz041bd542021-03-18 20:25:39 +01005919 if (flags.mask & BR_LEARNING) {
5920 bool learning = !!(flags.val & BR_LEARNING);
5921 u16 pav = learning ? (1 << port) : 0;
5922
5923 err = mv88e6xxx_port_set_assoc_vector(chip, port, pav);
5924 if (err)
5925 goto out;
Tobias Waldekranz041bd542021-03-18 20:25:39 +01005926 }
5927
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005928 if (flags.mask & BR_FLOOD) {
5929 bool unicast = !!(flags.val & BR_FLOOD);
5930
5931 err = chip->info->ops->port_set_ucast_flood(chip, port,
5932 unicast);
5933 if (err)
5934 goto out;
5935 }
5936
5937 if (flags.mask & BR_MCAST_FLOOD) {
5938 bool multicast = !!(flags.val & BR_MCAST_FLOOD);
5939
5940 err = chip->info->ops->port_set_mcast_flood(chip, port,
5941 multicast);
5942 if (err)
5943 goto out;
5944 }
5945
Tobias Waldekranz8d1d8292021-03-18 20:25:40 +01005946 if (flags.mask & BR_BCAST_FLOOD) {
5947 bool broadcast = !!(flags.val & BR_BCAST_FLOOD);
5948
5949 err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast);
5950 if (err)
5951 goto out;
5952 }
5953
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005954out:
5955 mv88e6xxx_reg_unlock(chip);
5956
5957 return err;
5958}
5959
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005960static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds,
5961 struct net_device *lag,
5962 struct netdev_lag_upper_info *info)
5963{
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01005964 struct mv88e6xxx_chip *chip = ds->priv;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005965 struct dsa_port *dp;
5966 int id, members = 0;
5967
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01005968 if (!mv88e6xxx_has_lag(chip))
5969 return false;
5970
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005971 id = dsa_lag_id(ds->dst, lag);
5972 if (id < 0 || id >= ds->num_lag_ids)
5973 return false;
5974
5975 dsa_lag_foreach_port(dp, ds->dst, lag)
5976 /* Includes the port joining the LAG */
5977 members++;
5978
5979 if (members > 8)
5980 return false;
5981
5982 /* We could potentially relax this to include active
5983 * backup in the future.
5984 */
5985 if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH)
5986 return false;
5987
5988 /* Ideally we would also validate that the hash type matches
5989 * the hardware. Alas, this is always set to unknown on team
5990 * interfaces.
5991 */
5992 return true;
5993}
5994
5995static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct net_device *lag)
5996{
5997 struct mv88e6xxx_chip *chip = ds->priv;
5998 struct dsa_port *dp;
5999 u16 map = 0;
6000 int id;
6001
6002 id = dsa_lag_id(ds->dst, lag);
6003
6004 /* Build the map of all ports to distribute flows destined for
6005 * this LAG. This can be either a local user port, or a DSA
6006 * port if the LAG port is on a remote chip.
6007 */
6008 dsa_lag_foreach_port(dp, ds->dst, lag)
6009 map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index));
6010
6011 return mv88e6xxx_g2_trunk_mapping_write(chip, id, map);
6012}
6013
6014static const u8 mv88e6xxx_lag_mask_table[8][8] = {
6015 /* Row number corresponds to the number of active members in a
6016 * LAG. Each column states which of the eight hash buckets are
6017 * mapped to the column:th port in the LAG.
6018 *
6019 * Example: In a LAG with three active ports, the second port
6020 * ([2][1]) would be selected for traffic mapped to buckets
6021 * 3,4,5 (0x38).
6022 */
6023 { 0xff, 0, 0, 0, 0, 0, 0, 0 },
6024 { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 },
6025 { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 },
6026 { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 },
6027 { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 },
6028 { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 },
6029 { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 },
6030 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 },
6031};
6032
6033static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port,
6034 int num_tx, int nth)
6035{
6036 u8 active = 0;
6037 int i;
6038
6039 num_tx = num_tx <= 8 ? num_tx : 8;
6040 if (nth < num_tx)
6041 active = mv88e6xxx_lag_mask_table[num_tx - 1][nth];
6042
6043 for (i = 0; i < 8; i++) {
6044 if (BIT(i) & active)
6045 mask[i] |= BIT(port);
6046 }
6047}
6048
6049static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds)
6050{
6051 struct mv88e6xxx_chip *chip = ds->priv;
6052 unsigned int id, num_tx;
6053 struct net_device *lag;
6054 struct dsa_port *dp;
6055 int i, err, nth;
6056 u16 mask[8];
6057 u16 ivec;
6058
6059 /* Assume no port is a member of any LAG. */
6060 ivec = BIT(mv88e6xxx_num_ports(chip)) - 1;
6061
6062 /* Disable all masks for ports that _are_ members of a LAG. */
6063 list_for_each_entry(dp, &ds->dst->ports, list) {
6064 if (!dp->lag_dev || dp->ds != ds)
6065 continue;
6066
6067 ivec &= ~BIT(dp->index);
6068 }
6069
6070 for (i = 0; i < 8; i++)
6071 mask[i] = ivec;
6072
6073 /* Enable the correct subset of masks for all LAG ports that
6074 * are in the Tx set.
6075 */
6076 dsa_lags_foreach_id(id, ds->dst) {
6077 lag = dsa_lag_dev(ds->dst, id);
6078 if (!lag)
6079 continue;
6080
6081 num_tx = 0;
6082 dsa_lag_foreach_port(dp, ds->dst, lag) {
6083 if (dp->lag_tx_enabled)
6084 num_tx++;
6085 }
6086
6087 if (!num_tx)
6088 continue;
6089
6090 nth = 0;
6091 dsa_lag_foreach_port(dp, ds->dst, lag) {
6092 if (!dp->lag_tx_enabled)
6093 continue;
6094
6095 if (dp->ds == ds)
6096 mv88e6xxx_lag_set_port_mask(mask, dp->index,
6097 num_tx, nth);
6098
6099 nth++;
6100 }
6101 }
6102
6103 for (i = 0; i < 8; i++) {
6104 err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]);
6105 if (err)
6106 return err;
6107 }
6108
6109 return 0;
6110}
6111
6112static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds,
6113 struct net_device *lag)
6114{
6115 int err;
6116
6117 err = mv88e6xxx_lag_sync_masks(ds);
6118
6119 if (!err)
6120 err = mv88e6xxx_lag_sync_map(ds, lag);
6121
6122 return err;
6123}
6124
6125static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port)
6126{
6127 struct mv88e6xxx_chip *chip = ds->priv;
6128 int err;
6129
6130 mv88e6xxx_reg_lock(chip);
6131 err = mv88e6xxx_lag_sync_masks(ds);
6132 mv88e6xxx_reg_unlock(chip);
6133 return err;
6134}
6135
6136static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port,
6137 struct net_device *lag,
6138 struct netdev_lag_upper_info *info)
6139{
6140 struct mv88e6xxx_chip *chip = ds->priv;
6141 int err, id;
6142
6143 if (!mv88e6xxx_lag_can_offload(ds, lag, info))
6144 return -EOPNOTSUPP;
6145
6146 id = dsa_lag_id(ds->dst, lag);
6147
6148 mv88e6xxx_reg_lock(chip);
6149
6150 err = mv88e6xxx_port_set_trunk(chip, port, true, id);
6151 if (err)
6152 goto err_unlock;
6153
6154 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
6155 if (err)
6156 goto err_clear_trunk;
6157
6158 mv88e6xxx_reg_unlock(chip);
6159 return 0;
6160
6161err_clear_trunk:
6162 mv88e6xxx_port_set_trunk(chip, port, false, 0);
6163err_unlock:
6164 mv88e6xxx_reg_unlock(chip);
6165 return err;
6166}
6167
6168static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port,
6169 struct net_device *lag)
6170{
6171 struct mv88e6xxx_chip *chip = ds->priv;
6172 int err_sync, err_trunk;
6173
6174 mv88e6xxx_reg_lock(chip);
6175 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
6176 err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0);
6177 mv88e6xxx_reg_unlock(chip);
6178 return err_sync ? : err_trunk;
6179}
6180
6181static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index,
6182 int port)
6183{
6184 struct mv88e6xxx_chip *chip = ds->priv;
6185 int err;
6186
6187 mv88e6xxx_reg_lock(chip);
6188 err = mv88e6xxx_lag_sync_masks(ds);
6189 mv88e6xxx_reg_unlock(chip);
6190 return err;
6191}
6192
6193static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index,
6194 int port, struct net_device *lag,
6195 struct netdev_lag_upper_info *info)
6196{
6197 struct mv88e6xxx_chip *chip = ds->priv;
6198 int err;
6199
6200 if (!mv88e6xxx_lag_can_offload(ds, lag, info))
6201 return -EOPNOTSUPP;
6202
6203 mv88e6xxx_reg_lock(chip);
6204
6205 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
6206 if (err)
6207 goto unlock;
6208
6209 err = mv88e6xxx_pvt_map(chip, sw_index, port);
6210
6211unlock:
6212 mv88e6xxx_reg_unlock(chip);
6213 return err;
6214}
6215
6216static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index,
6217 int port, struct net_device *lag)
6218{
6219 struct mv88e6xxx_chip *chip = ds->priv;
6220 int err_sync, err_pvt;
6221
6222 mv88e6xxx_reg_lock(chip);
6223 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
6224 err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port);
6225 mv88e6xxx_reg_unlock(chip);
6226 return err_sync ? : err_pvt;
6227}
6228
Florian Fainellia82f67a2017-01-08 14:52:08 -08006229static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02006230 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Tobias Waldekranz9a99bef2021-04-20 20:53:08 +02006231 .change_tag_protocol = mv88e6xxx_change_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006232 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02006233 .teardown = mv88e6xxx_teardown,
Vladimir Olteanfd292c12021-09-17 17:29:16 +03006234 .port_setup = mv88e6xxx_port_setup,
6235 .port_teardown = mv88e6xxx_port_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07006236 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00006237 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07006238 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00006239 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07006240 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
6241 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006242 .get_strings = mv88e6xxx_get_strings,
6243 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
6244 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02006245 .port_enable = mv88e6xxx_port_enable,
6246 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02006247 .port_max_mtu = mv88e6xxx_get_max_mtu,
6248 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04006249 .get_mac_eee = mv88e6xxx_get_mac_eee,
6250 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006251 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006252 .get_eeprom = mv88e6xxx_get_eeprom,
6253 .set_eeprom = mv88e6xxx_set_eeprom,
6254 .get_regs_len = mv88e6xxx_get_regs_len,
6255 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04006256 .get_rxnfc = mv88e6xxx_get_rxnfc,
6257 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04006258 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006259 .port_bridge_join = mv88e6xxx_port_bridge_join,
6260 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02006261 .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags,
6262 .port_bridge_flags = mv88e6xxx_port_bridge_flags,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006263 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04006264 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006265 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006266 .port_vlan_add = mv88e6xxx_port_vlan_add,
6267 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006268 .port_fdb_add = mv88e6xxx_port_fdb_add,
6269 .port_fdb_del = mv88e6xxx_port_fdb_del,
6270 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04006271 .port_mdb_add = mv88e6xxx_port_mdb_add,
6272 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01006273 .port_mirror_add = mv88e6xxx_port_mirror_add,
6274 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04006275 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
6276 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006277 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
6278 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
6279 .port_txtstamp = mv88e6xxx_port_txtstamp,
6280 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
6281 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02006282 .devlink_param_get = mv88e6xxx_devlink_param_get,
6283 .devlink_param_set = mv88e6xxx_devlink_param_set,
Andrew Lunn93157302020-09-18 21:11:09 +02006284 .devlink_info_get = mv88e6xxx_devlink_info_get,
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006285 .port_lag_change = mv88e6xxx_port_lag_change,
6286 .port_lag_join = mv88e6xxx_port_lag_join,
6287 .port_lag_leave = mv88e6xxx_port_lag_leave,
6288 .crosschip_lag_change = mv88e6xxx_crosschip_lag_change,
6289 .crosschip_lag_join = mv88e6xxx_crosschip_lag_join,
6290 .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave,
Vladimir Olteance5df682021-07-22 18:55:41 +03006291 .port_bridge_tx_fwd_offload = mv88e6xxx_bridge_tx_fwd_offload,
6292 .port_bridge_tx_fwd_unoffload = mv88e6xxx_bridge_tx_fwd_unoffload,
Vivien Didelotf81ec902016-05-09 13:22:58 -04006293};
6294
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08006295static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006296{
Vivien Didelotfad09c72016-06-21 12:28:20 -04006297 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006298 struct dsa_switch *ds;
6299
Vivien Didelot7e99e342019-10-21 16:51:30 -04006300 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006301 if (!ds)
6302 return -ENOMEM;
6303
Vivien Didelot7e99e342019-10-21 16:51:30 -04006304 ds->dev = dev;
6305 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04006306 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006307 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04006308 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04006309 ds->ageing_time_min = chip->info->age_time_coeff;
6310 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006311
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006312 /* Some chips support up to 32, but that requires enabling the
6313 * 5-bit port mode, which we do not support. 640k^W16 ought to
6314 * be enough for anyone.
6315 */
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01006316 ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006317
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006318 dev_set_drvdata(dev, ds);
6319
Vivien Didelot23c9ee42017-05-26 18:12:51 -04006320 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006321}
6322
Vivien Didelotfad09c72016-06-21 12:28:20 -04006323static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006324{
Vivien Didelotfad09c72016-06-21 12:28:20 -04006325 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006326}
6327
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006328static const void *pdata_device_get_match_data(struct device *dev)
6329{
6330 const struct of_device_id *matches = dev->driver->of_match_table;
6331 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
6332
6333 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
6334 matches++) {
6335 if (!strcmp(pdata->compatible, matches->compatible))
6336 return matches->data;
6337 }
6338 return NULL;
6339}
6340
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01006341/* There is no suspend to RAM support at DSA level yet, the switch configuration
6342 * would be lost after a power cycle so prevent it to be suspended.
6343 */
6344static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
6345{
6346 return -EOPNOTSUPP;
6347}
6348
6349static int __maybe_unused mv88e6xxx_resume(struct device *dev)
6350{
6351 return 0;
6352}
6353
6354static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
6355
Vivien Didelot57d32312016-06-20 13:13:58 -04006356static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006357{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006358 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04006359 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006360 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006361 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04006362 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006363 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02006364 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006365
Andrew Lunn7bb8c992018-05-31 00:15:42 +02006366 if (!np && !pdata)
6367 return -EINVAL;
6368
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006369 if (np)
6370 compat_info = of_device_get_match_data(dev);
6371
6372 if (pdata) {
6373 compat_info = pdata_device_get_match_data(dev);
6374
6375 if (!pdata->netdev)
6376 return -EINVAL;
6377
6378 for (port = 0; port < DSA_MAX_PORTS; port++) {
6379 if (!(pdata->enabled_ports & (1 << port)))
6380 continue;
6381 if (strcmp(pdata->cd.port_names[port], "cpu"))
6382 continue;
6383 pdata->cd.netdev[port] = &pdata->netdev->dev;
6384 break;
6385 }
6386 }
6387
Vivien Didelotcaac8542016-06-20 13:14:09 -04006388 if (!compat_info)
6389 return -EINVAL;
6390
Vivien Didelotfad09c72016-06-21 12:28:20 -04006391 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006392 if (!chip) {
6393 err = -ENOMEM;
6394 goto out;
6395 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006396
Vivien Didelotfad09c72016-06-21 12:28:20 -04006397 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04006398
Vivien Didelotfad09c72016-06-21 12:28:20 -04006399 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04006400 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006401 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006402
Andrew Lunnb4308f02016-11-21 23:26:55 +01006403 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006404 if (IS_ERR(chip->reset)) {
6405 err = PTR_ERR(chip->reset);
6406 goto out;
6407 }
Baruch Siach7b75e492019-06-27 21:17:39 +03006408 if (chip->reset)
6409 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01006410
Vivien Didelotfad09c72016-06-21 12:28:20 -04006411 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04006412 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006413 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006414
Tobias Waldekranz670bb802021-04-20 20:53:07 +02006415 if (chip->info->edsa_support == MV88E6XXX_EDSA_SUPPORTED)
6416 chip->tag_protocol = DSA_TAG_PROTO_EDSA;
6417 else
6418 chip->tag_protocol = DSA_TAG_PROTO_DSA;
6419
Vivien Didelote57e5e72016-08-15 17:19:00 -04006420 mv88e6xxx_phy_init(chip);
6421
Andrew Lunn00baabe2018-05-19 22:31:35 +02006422 if (chip->info->ops->get_eeprom) {
6423 if (np)
6424 of_property_read_u32(np, "eeprom-length",
6425 &chip->eeprom_len);
6426 else
6427 chip->eeprom_len = pdata->eeprom_len;
6428 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006429
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006430 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006431 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006432 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02006433 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02006434 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02006435
Andrew Lunna27415d2019-05-01 00:10:50 +02006436 if (np) {
6437 chip->irq = of_irq_get(np, 0);
6438 if (chip->irq == -EPROBE_DEFER) {
6439 err = chip->irq;
6440 goto out;
6441 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02006442 }
6443
Andrew Lunna27415d2019-05-01 00:10:50 +02006444 if (pdata)
6445 chip->irq = pdata->irq;
6446
Andrew Lunn294d7112018-02-22 22:58:32 +01006447 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01006448 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01006449 * controllers
6450 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006451 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006452 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02006453 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006454 else
6455 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006456 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006457
Andrew Lunn294d7112018-02-22 22:58:32 +01006458 if (err)
6459 goto out;
6460
6461 if (chip->info->g2_irqs > 0) {
6462 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006463 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01006464 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02006465 }
6466
Andrew Lunn294d7112018-02-22 22:58:32 +01006467 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
6468 if (err)
6469 goto out_g2_irq;
6470
6471 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
6472 if (err)
6473 goto out_g1_atu_prob_irq;
6474
Andrew Lunna3c53be52017-01-24 14:53:50 +01006475 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02006476 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01006477 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02006478
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08006479 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006480 if (err)
6481 goto out_mdio;
6482
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006483 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02006484
6485out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01006486 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01006487out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006488 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01006489out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006490 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006491out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006492 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02006493 mv88e6xxx_g2_irq_free(chip);
6494out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006495 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01006496 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006497 else
6498 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006499out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006500 if (pdata)
6501 dev_put(pdata->netdev);
6502
Andrew Lunndc30c352016-10-16 19:56:49 +02006503 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006504}
6505
6506static void mv88e6xxx_remove(struct mdio_device *mdiodev)
6507{
6508 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006509 struct mv88e6xxx_chip *chip;
6510
6511 if (!ds)
6512 return;
6513
6514 chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006515
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006516 if (chip->info->ptp_support) {
6517 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01006518 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006519 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01006520
Andrew Lunn930188c2016-08-22 16:01:03 +02006521 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04006522 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01006523 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006524
Andrew Lunn76f38f12018-03-17 20:21:09 +01006525 mv88e6xxx_g1_vtu_prob_irq_free(chip);
6526 mv88e6xxx_g1_atu_prob_irq_free(chip);
6527
6528 if (chip->info->g2_irqs > 0)
6529 mv88e6xxx_g2_irq_free(chip);
6530
Andrew Lunn76f38f12018-03-17 20:21:09 +01006531 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01006532 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01006533 else
6534 mv88e6xxx_irq_poll_free(chip);
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006535
6536 dev_set_drvdata(&mdiodev->dev, NULL);
6537}
6538
6539static void mv88e6xxx_shutdown(struct mdio_device *mdiodev)
6540{
6541 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
6542
6543 if (!ds)
6544 return;
6545
6546 dsa_switch_shutdown(ds);
6547
6548 dev_set_drvdata(&mdiodev->dev, NULL);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006549}
6550
6551static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04006552 {
6553 .compatible = "marvell,mv88e6085",
6554 .data = &mv88e6xxx_table[MV88E6085],
6555 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01006556 {
6557 .compatible = "marvell,mv88e6190",
6558 .data = &mv88e6xxx_table[MV88E6190],
6559 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00006560 {
6561 .compatible = "marvell,mv88e6250",
6562 .data = &mv88e6xxx_table[MV88E6250],
6563 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006564 { /* sentinel */ },
6565};
6566
6567MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
6568
6569static struct mdio_driver mv88e6xxx_driver = {
6570 .probe = mv88e6xxx_probe,
6571 .remove = mv88e6xxx_remove,
Vladimir Oltean0650bf52021-09-17 16:34:33 +03006572 .shutdown = mv88e6xxx_shutdown,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006573 .mdiodrv.driver = {
6574 .name = "mv88e6085",
6575 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01006576 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006577 },
6578};
6579
Andrew Lunn7324d502019-04-27 19:19:10 +02006580mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00006581
6582MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
6583MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
6584MODULE_LICENSE("GPL");