blob: 545eb9c6c3fc3a214b6e204ebdfe182cef4da16f [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>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070015#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020016#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070017#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020018#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000021#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000022#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020023#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000024#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040025#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020026#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020027#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020028#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000029#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010030#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Andrew Lunn9dd43aa2020-09-18 21:11:05 +020035#include "devlink.h"
Vivien Didelota935c052016-09-29 12:21:53 -040036#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040037#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010038#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020039#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010040#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010041#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020042#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040043#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000044
Vivien Didelotfad09c72016-06-21 12:28:20 -040045static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040046{
Vivien Didelotfad09c72016-06-21 12:28:20 -040047 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
48 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040049 dump_stack();
50 }
51}
52
Vivien Didelotec561272016-09-02 14:45:33 -040053int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040054{
55 int err;
56
Vivien Didelotfad09c72016-06-21 12:28:20 -040057 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040058
Vivien Didelotfad09c72016-06-21 12:28:20 -040059 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040060 if (err)
61 return err;
62
Vivien Didelotfad09c72016-06-21 12:28:20 -040063 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040064 addr, reg, *val);
65
66 return 0;
67}
68
Vivien Didelotec561272016-09-02 14:45:33 -040069int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040070{
71 int err;
72
Vivien Didelotfad09c72016-06-21 12:28:20 -040073 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040074
Vivien Didelotfad09c72016-06-21 12:28:20 -040075 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040076 if (err)
77 return err;
78
Vivien Didelotfad09c72016-06-21 12:28:20 -040079 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040080 addr, reg, val);
81
82 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000083}
84
Vivien Didelot683f2242019-08-09 18:47:54 -040085int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
86 u16 mask, u16 val)
87{
88 u16 data;
89 int err;
90 int i;
91
92 /* There's no bus specific operation to wait for a mask */
93 for (i = 0; i < 16; i++) {
94 err = mv88e6xxx_read(chip, addr, reg, &data);
95 if (err)
96 return err;
97
98 if ((data & mask) == val)
99 return 0;
100
101 usleep_range(1000, 2000);
102 }
103
104 dev_err(chip->dev, "Timeout while waiting for switch\n");
105 return -ETIMEDOUT;
106}
107
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400108int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
109 int bit, int val)
110{
111 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
112 val ? BIT(bit) : 0x0000);
113}
114
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200115struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100116{
117 struct mv88e6xxx_mdio_bus *mdio_bus;
118
119 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
120 list);
121 if (!mdio_bus)
122 return NULL;
123
124 return mdio_bus->bus;
125}
126
Andrew Lunndc30c352016-10-16 19:56:49 +0200127static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
128{
129 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
130 unsigned int n = d->hwirq;
131
132 chip->g1_irq.masked |= (1 << n);
133}
134
135static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
136{
137 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
138 unsigned int n = d->hwirq;
139
140 chip->g1_irq.masked &= ~(1 << n);
141}
142
Andrew Lunn294d7112018-02-22 22:58:32 +0100143static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200144{
Andrew Lunndc30c352016-10-16 19:56:49 +0200145 unsigned int nhandled = 0;
146 unsigned int sub_irq;
147 unsigned int n;
148 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500149 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200150 int err;
151
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000152 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400153 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000154 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200155
156 if (err)
157 goto out;
158
John David Anglin7c0db242019-02-11 13:40:21 -0500159 do {
160 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
161 if (reg & (1 << n)) {
162 sub_irq = irq_find_mapping(chip->g1_irq.domain,
163 n);
164 handle_nested_irq(sub_irq);
165 ++nhandled;
166 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200167 }
John David Anglin7c0db242019-02-11 13:40:21 -0500168
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000169 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500170 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
171 if (err)
172 goto unlock;
173 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
174unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000175 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500176 if (err)
177 goto out;
178 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
179 } while (reg & ctl1);
180
Andrew Lunndc30c352016-10-16 19:56:49 +0200181out:
182 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
183}
184
Andrew Lunn294d7112018-02-22 22:58:32 +0100185static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
186{
187 struct mv88e6xxx_chip *chip = dev_id;
188
189 return mv88e6xxx_g1_irq_thread_work(chip);
190}
191
Andrew Lunndc30c352016-10-16 19:56:49 +0200192static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
193{
194 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
195
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000196 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200197}
198
199static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
200{
201 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
202 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
203 u16 reg;
204 int err;
205
Vivien Didelotd77f4322017-06-15 12:14:03 -0400206 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200207 if (err)
208 goto out;
209
210 reg &= ~mask;
211 reg |= (~chip->g1_irq.masked & mask);
212
Vivien Didelotd77f4322017-06-15 12:14:03 -0400213 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200214 if (err)
215 goto out;
216
217out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000218 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200219}
220
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530221static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200222 .name = "mv88e6xxx-g1",
223 .irq_mask = mv88e6xxx_g1_irq_mask,
224 .irq_unmask = mv88e6xxx_g1_irq_unmask,
225 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
226 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
227};
228
229static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
230 unsigned int irq,
231 irq_hw_number_t hwirq)
232{
233 struct mv88e6xxx_chip *chip = d->host_data;
234
235 irq_set_chip_data(irq, d->host_data);
236 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
237 irq_set_noprobe(irq);
238
239 return 0;
240}
241
242static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
243 .map = mv88e6xxx_g1_irq_domain_map,
244 .xlate = irq_domain_xlate_twocell,
245};
246
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200247/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100248static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200249{
250 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100251 u16 mask;
252
Vivien Didelotd77f4322017-06-15 12:14:03 -0400253 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100254 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400255 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100256
Andreas Färber5edef2f2016-11-27 23:26:28 +0100257 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100258 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200259 irq_dispose_mapping(virq);
260 }
261
Andrew Lunna3db3d32016-11-20 20:14:14 +0100262 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200263}
264
Andrew Lunn294d7112018-02-22 22:58:32 +0100265static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
266{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200267 /*
268 * free_irq must be called without reg_lock taken because the irq
269 * handler takes this lock, too.
270 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100271 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200272
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000273 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200274 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000275 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100276}
277
278static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200279{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100280 int err, irq, virq;
281 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200282
283 chip->g1_irq.nirqs = chip->info->g1_irqs;
284 chip->g1_irq.domain = irq_domain_add_simple(
285 NULL, chip->g1_irq.nirqs, 0,
286 &mv88e6xxx_g1_irq_domain_ops, chip);
287 if (!chip->g1_irq.domain)
288 return -ENOMEM;
289
290 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
291 irq_create_mapping(chip->g1_irq.domain, irq);
292
293 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
294 chip->g1_irq.masked = ~0;
295
Vivien Didelotd77f4322017-06-15 12:14:03 -0400296 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200297 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100298 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200299
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100300 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200301
Vivien Didelotd77f4322017-06-15 12:14:03 -0400302 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200303 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100304 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200305
306 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400307 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200308 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100309 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200310
Andrew Lunndc30c352016-10-16 19:56:49 +0200311 return 0;
312
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100313out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100314 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400315 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100316
317out_mapping:
318 for (irq = 0; irq < 16; irq++) {
319 virq = irq_find_mapping(chip->g1_irq.domain, irq);
320 irq_dispose_mapping(virq);
321 }
322
323 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200324
325 return err;
326}
327
Andrew Lunn294d7112018-02-22 22:58:32 +0100328static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
329{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100330 static struct lock_class_key lock_key;
331 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100332 int err;
333
334 err = mv88e6xxx_g1_irq_setup_common(chip);
335 if (err)
336 return err;
337
Andrew Lunnf6d97582019-02-23 17:43:56 +0100338 /* These lock classes tells lockdep that global 1 irqs are in
339 * a different category than their parent GPIO, so it won't
340 * report false recursion.
341 */
342 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
343
Andrew Lunn30953832020-01-06 17:13:48 +0100344 snprintf(chip->irq_name, sizeof(chip->irq_name),
345 "mv88e6xxx-%s", dev_name(chip->dev));
346
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000347 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100348 err = request_threaded_irq(chip->irq, NULL,
349 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200350 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100351 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000352 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100353 if (err)
354 mv88e6xxx_g1_irq_free_common(chip);
355
356 return err;
357}
358
359static void mv88e6xxx_irq_poll(struct kthread_work *work)
360{
361 struct mv88e6xxx_chip *chip = container_of(work,
362 struct mv88e6xxx_chip,
363 irq_poll_work.work);
364 mv88e6xxx_g1_irq_thread_work(chip);
365
366 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
367 msecs_to_jiffies(100));
368}
369
370static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
371{
372 int err;
373
374 err = mv88e6xxx_g1_irq_setup_common(chip);
375 if (err)
376 return err;
377
378 kthread_init_delayed_work(&chip->irq_poll_work,
379 mv88e6xxx_irq_poll);
380
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800381 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100382 if (IS_ERR(chip->kworker))
383 return PTR_ERR(chip->kworker);
384
385 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
386 msecs_to_jiffies(100));
387
388 return 0;
389}
390
391static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
392{
393 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
394 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200395
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000396 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200397 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000398 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100399}
400
Russell King64d47d52020-03-14 10:15:38 +0000401static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
402 int port, phy_interface_t interface)
403{
404 int err;
405
406 if (chip->info->ops->port_set_rgmii_delay) {
407 err = chip->info->ops->port_set_rgmii_delay(chip, port,
408 interface);
409 if (err && err != -EOPNOTSUPP)
410 return err;
411 }
412
413 if (chip->info->ops->port_set_cmode) {
414 err = chip->info->ops->port_set_cmode(chip, port,
415 interface);
416 if (err && err != -EOPNOTSUPP)
417 return err;
418 }
419
420 return 0;
421}
422
Russell Kinga5a68582020-03-14 10:15:43 +0000423static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
424 int link, int speed, int duplex, int pause,
425 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100426{
427 int err;
428
429 if (!chip->info->ops->port_set_link)
430 return 0;
431
432 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200433 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100434 if (err)
435 return err;
436
Russell Kingf365c6f2020-03-14 10:15:53 +0000437 if (chip->info->ops->port_set_speed_duplex) {
438 err = chip->info->ops->port_set_speed_duplex(chip, port,
439 speed, duplex);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100440 if (err && err != -EOPNOTSUPP)
441 goto restore_link;
442 }
443
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100444 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
445 mode = chip->info->ops->port_max_speed_mode(port);
446
Andrew Lunn54186b92018-08-09 15:38:37 +0200447 if (chip->info->ops->port_set_pause) {
448 err = chip->info->ops->port_set_pause(chip, port, pause);
449 if (err)
450 goto restore_link;
451 }
452
Russell King64d47d52020-03-14 10:15:38 +0000453 err = mv88e6xxx_port_config_interface(chip, port, mode);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100454restore_link:
455 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400456 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100457
458 return err;
459}
460
Marek Vasutd700ec42018-09-12 00:15:24 +0200461static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
462{
463 struct mv88e6xxx_chip *chip = ds->priv;
464
465 return port < chip->info->num_internal_phys;
466}
467
Russell King5d5b2312020-03-14 10:16:03 +0000468static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)
469{
470 u16 reg;
471 int err;
472
473 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
474 if (err) {
475 dev_err(chip->dev,
476 "p%d: %s: failed to read port status\n",
477 port, __func__);
478 return err;
479 }
480
481 return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
482}
483
Russell Kinga5a68582020-03-14 10:15:43 +0000484static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
485 struct phylink_link_state *state)
486{
487 struct mv88e6xxx_chip *chip = ds->priv;
488 u8 lane;
489 int err;
490
491 mv88e6xxx_reg_lock(chip);
492 lane = mv88e6xxx_serdes_get_lane(chip, port);
493 if (lane && chip->info->ops->serdes_pcs_get_state)
494 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
495 state);
496 else
497 err = -EOPNOTSUPP;
498 mv88e6xxx_reg_unlock(chip);
499
500 return err;
501}
502
503static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
504 unsigned int mode,
505 phy_interface_t interface,
506 const unsigned long *advertise)
507{
508 const struct mv88e6xxx_ops *ops = chip->info->ops;
509 u8 lane;
510
511 if (ops->serdes_pcs_config) {
512 lane = mv88e6xxx_serdes_get_lane(chip, port);
513 if (lane)
514 return ops->serdes_pcs_config(chip, port, lane, mode,
515 interface, advertise);
516 }
517
518 return 0;
519}
520
521static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
522{
523 struct mv88e6xxx_chip *chip = ds->priv;
524 const struct mv88e6xxx_ops *ops;
525 int err = 0;
526 u8 lane;
527
528 ops = chip->info->ops;
529
530 if (ops->serdes_pcs_an_restart) {
531 mv88e6xxx_reg_lock(chip);
532 lane = mv88e6xxx_serdes_get_lane(chip, port);
533 if (lane)
534 err = ops->serdes_pcs_an_restart(chip, port, lane);
535 mv88e6xxx_reg_unlock(chip);
536
537 if (err)
538 dev_err(ds->dev, "p%d: failed to restart AN\n", port);
539 }
540}
541
542static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
543 unsigned int mode,
544 int speed, int duplex)
545{
546 const struct mv88e6xxx_ops *ops = chip->info->ops;
547 u8 lane;
548
549 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
550 lane = mv88e6xxx_serdes_get_lane(chip, port);
551 if (lane)
552 return ops->serdes_pcs_link_up(chip, port, lane,
553 speed, duplex);
554 }
555
556 return 0;
557}
558
Russell King6c422e32018-08-09 15:38:39 +0200559static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
560 unsigned long *mask,
561 struct phylink_link_state *state)
562{
563 if (!phy_interface_mode_is_8023z(state->interface)) {
564 /* 10M and 100M are only supported in non-802.3z mode */
565 phylink_set(mask, 10baseT_Half);
566 phylink_set(mask, 10baseT_Full);
567 phylink_set(mask, 100baseT_Half);
568 phylink_set(mask, 100baseT_Full);
569 }
570}
571
572static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
573 unsigned long *mask,
574 struct phylink_link_state *state)
575{
576 /* FIXME: if the port is in 1000Base-X mode, then it only supports
577 * 1000M FD speeds. In this case, CMODE will indicate 5.
578 */
579 phylink_set(mask, 1000baseT_Full);
580 phylink_set(mask, 1000baseX_Full);
581
582 mv88e6065_phylink_validate(chip, port, mask, state);
583}
584
Marek Behúne3af71a2019-02-25 12:39:55 +0100585static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
586 unsigned long *mask,
587 struct phylink_link_state *state)
588{
589 if (port >= 5)
590 phylink_set(mask, 2500baseX_Full);
591
592 /* No ethtool bits for 200Mbps */
593 phylink_set(mask, 1000baseT_Full);
594 phylink_set(mask, 1000baseX_Full);
595
596 mv88e6065_phylink_validate(chip, port, mask, state);
597}
598
Russell King6c422e32018-08-09 15:38:39 +0200599static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
600 unsigned long *mask,
601 struct phylink_link_state *state)
602{
603 /* No ethtool bits for 200Mbps */
604 phylink_set(mask, 1000baseT_Full);
605 phylink_set(mask, 1000baseX_Full);
606
607 mv88e6065_phylink_validate(chip, port, mask, state);
608}
609
610static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
611 unsigned long *mask,
612 struct phylink_link_state *state)
613{
Andrew Lunnec260162019-02-08 22:25:44 +0100614 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200615 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100616 phylink_set(mask, 2500baseT_Full);
617 }
Russell King6c422e32018-08-09 15:38:39 +0200618
619 /* No ethtool bits for 200Mbps */
620 phylink_set(mask, 1000baseT_Full);
621 phylink_set(mask, 1000baseX_Full);
622
623 mv88e6065_phylink_validate(chip, port, mask, state);
624}
625
626static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
627 unsigned long *mask,
628 struct phylink_link_state *state)
629{
630 if (port >= 9) {
631 phylink_set(mask, 10000baseT_Full);
632 phylink_set(mask, 10000baseKR_Full);
633 }
634
635 mv88e6390_phylink_validate(chip, port, mask, state);
636}
637
Russell Kingc9a23562018-05-10 13:17:35 -0700638static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
639 unsigned long *supported,
640 struct phylink_link_state *state)
641{
Russell King6c422e32018-08-09 15:38:39 +0200642 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
643 struct mv88e6xxx_chip *chip = ds->priv;
644
645 /* Allow all the expected bits */
646 phylink_set(mask, Autoneg);
647 phylink_set(mask, Pause);
648 phylink_set_port_modes(mask);
649
650 if (chip->info->ops->phylink_validate)
651 chip->info->ops->phylink_validate(chip, port, mask, state);
652
653 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
654 bitmap_and(state->advertising, state->advertising, mask,
655 __ETHTOOL_LINK_MODE_MASK_NBITS);
656
657 /* We can only operate at 2500BaseX or 1000BaseX. If requested
658 * to advertise both, only report advertising at 2500BaseX.
659 */
660 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700661}
662
Russell Kingc9a23562018-05-10 13:17:35 -0700663static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
664 unsigned int mode,
665 const struct phylink_link_state *state)
666{
667 struct mv88e6xxx_chip *chip = ds->priv;
Russell Kingfad58192020-07-19 12:00:35 +0100668 struct mv88e6xxx_port *p;
Russell King64d47d52020-03-14 10:15:38 +0000669 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700670
Russell Kingfad58192020-07-19 12:00:35 +0100671 p = &chip->ports[port];
672
Russell King64d47d52020-03-14 10:15:38 +0000673 /* FIXME: is this the correct test? If we're in fixed mode on an
674 * internal port, why should we process this any different from
675 * PHY mode? On the other hand, the port may be automedia between
676 * an internal PHY and the serdes...
677 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200678 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700679 return;
680
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000681 mv88e6xxx_reg_lock(chip);
Russell Kingfad58192020-07-19 12:00:35 +0100682 /* In inband mode, the link may come up at any time while the link
683 * is not forced down. Force the link down while we reconfigure the
684 * interface mode.
Russell King64d47d52020-03-14 10:15:38 +0000685 */
Russell Kingfad58192020-07-19 12:00:35 +0100686 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
687 chip->info->ops->port_set_link)
688 chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
689
Russell King64d47d52020-03-14 10:15:38 +0000690 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000691 if (err && err != -EOPNOTSUPP)
692 goto err_unlock;
693
694 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
695 state->advertising);
696 /* FIXME: we should restart negotiation if something changed - which
697 * is something we get if we convert to using phylinks PCS operations.
698 */
699 if (err > 0)
700 err = 0;
701
Russell Kingfad58192020-07-19 12:00:35 +0100702 /* Undo the forced down state above after completing configuration
703 * irrespective of its state on entry, which allows the link to come up.
704 */
705 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
706 chip->info->ops->port_set_link)
707 chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
708
709 p->interface = state->interface;
710
Russell Kinga5a68582020-03-14 10:15:43 +0000711err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000712 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700713
714 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000715 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700716}
717
Russell Kingc9a23562018-05-10 13:17:35 -0700718static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
719 unsigned int mode,
720 phy_interface_t interface)
721{
Russell King30c4a5b2020-02-26 10:23:51 +0000722 struct mv88e6xxx_chip *chip = ds->priv;
723 const struct mv88e6xxx_ops *ops;
724 int err = 0;
725
726 ops = chip->info->ops;
727
Russell King5d5b2312020-03-14 10:16:03 +0000728 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200729 if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
Chris Packham4efe76622020-11-24 17:34:37 +1300730 mode == MLO_AN_FIXED) && ops->port_sync_link)
731 err = ops->port_sync_link(chip, port, mode, false);
Russell King5d5b2312020-03-14 10:16:03 +0000732 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000733
Russell King5d5b2312020-03-14 10:16:03 +0000734 if (err)
735 dev_err(chip->dev,
736 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700737}
738
739static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
740 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000741 struct phy_device *phydev,
742 int speed, int duplex,
743 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700744{
Russell King30c4a5b2020-02-26 10:23:51 +0000745 struct mv88e6xxx_chip *chip = ds->priv;
746 const struct mv88e6xxx_ops *ops;
747 int err = 0;
748
749 ops = chip->info->ops;
750
Russell King5d5b2312020-03-14 10:16:03 +0000751 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200752 if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000753 /* FIXME: for an automedia port, should we force the link
754 * down here - what if the link comes up due to "other" media
755 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000756 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000757 * shared between internal PHY and Serdes.
758 */
Russell Kinga5a68582020-03-14 10:15:43 +0000759 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
760 duplex);
761 if (err)
762 goto error;
763
Russell Kingf365c6f2020-03-14 10:15:53 +0000764 if (ops->port_set_speed_duplex) {
765 err = ops->port_set_speed_duplex(chip, port,
766 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000767 if (err && err != -EOPNOTSUPP)
768 goto error;
769 }
770
Chris Packham4efe76622020-11-24 17:34:37 +1300771 if (ops->port_sync_link)
772 err = ops->port_sync_link(chip, port, mode, true);
Russell King30c4a5b2020-02-26 10:23:51 +0000773 }
Russell King5d5b2312020-03-14 10:16:03 +0000774error:
775 mv88e6xxx_reg_unlock(chip);
776
777 if (err && err != -EOPNOTSUPP)
778 dev_err(ds->dev,
779 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700780}
781
Andrew Lunna605a0f2016-11-21 23:26:58 +0100782static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000783{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100784 if (!chip->info->ops->stats_snapshot)
785 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000786
Andrew Lunna605a0f2016-11-21 23:26:58 +0100787 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000788}
789
Andrew Lunne413e7e2015-04-02 04:06:38 +0200790static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100791 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
792 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
793 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
794 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
795 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
796 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
797 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
798 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
799 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
800 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
801 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
802 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
803 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
804 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
805 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
806 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
807 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
808 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
809 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
810 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
811 { "single", 4, 0x14, STATS_TYPE_BANK0, },
812 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
813 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
814 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
815 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
816 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
817 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
818 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
819 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
820 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
821 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
822 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
823 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
824 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
825 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
826 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
827 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
828 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
829 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
830 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
831 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
832 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
833 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
834 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
835 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
836 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
837 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
838 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
839 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
840 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
841 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
842 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
843 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
844 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
845 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
846 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
847 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
848 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
849 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200850};
851
Vivien Didelotfad09c72016-06-21 12:28:20 -0400852static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100853 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100854 int port, u16 bank1_select,
855 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200856{
Andrew Lunn80c46272015-06-20 18:42:30 +0200857 u32 low;
858 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100859 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200860 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200861 u64 value;
862
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100863 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100864 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200865 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
866 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800867 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200868
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200869 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100870 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200871 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
872 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800873 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000874 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200875 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100876 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100877 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100878 reg = bank1_select;
Gustavo A. R. Silvadf561f662020-08-23 17:36:59 -0500879 fallthrough;
Andrew Lunndfafe442016-11-21 23:27:02 +0100880 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100881 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100882 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100883 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100884 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500885 break;
886 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800887 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200888 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100889 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200890 return value;
891}
892
Andrew Lunn436fe172018-03-01 02:02:29 +0100893static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
894 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100895{
896 struct mv88e6xxx_hw_stat *stat;
897 int i, j;
898
899 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
900 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100901 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100902 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
903 ETH_GSTRING_LEN);
904 j++;
905 }
906 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100907
908 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100909}
910
Andrew Lunn436fe172018-03-01 02:02:29 +0100911static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
912 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100913{
Andrew Lunn436fe172018-03-01 02:02:29 +0100914 return mv88e6xxx_stats_get_strings(chip, data,
915 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100916}
917
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000918static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
919 uint8_t *data)
920{
921 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
922}
923
Andrew Lunn436fe172018-03-01 02:02:29 +0100924static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
925 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100926{
Andrew Lunn436fe172018-03-01 02:02:29 +0100927 return mv88e6xxx_stats_get_strings(chip, data,
928 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100929}
930
Andrew Lunn65f60e42018-03-28 23:50:28 +0200931static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
932 "atu_member_violation",
933 "atu_miss_violation",
934 "atu_full_violation",
935 "vtu_member_violation",
936 "vtu_miss_violation",
937};
938
939static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
940{
941 unsigned int i;
942
943 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
944 strlcpy(data + i * ETH_GSTRING_LEN,
945 mv88e6xxx_atu_vtu_stats_strings[i],
946 ETH_GSTRING_LEN);
947}
948
Andrew Lunndfafe442016-11-21 23:27:02 +0100949static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700950 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100951{
Vivien Didelot04bed142016-08-31 18:06:13 -0400952 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100953 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100954
Florian Fainelli89f09042018-04-25 12:12:50 -0700955 if (stringset != ETH_SS_STATS)
956 return;
957
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000958 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100959
Andrew Lunndfafe442016-11-21 23:27:02 +0100960 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100961 count = chip->info->ops->stats_get_strings(chip, data);
962
963 if (chip->info->ops->serdes_get_strings) {
964 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200965 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100966 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100967
Andrew Lunn65f60e42018-03-28 23:50:28 +0200968 data += count * ETH_GSTRING_LEN;
969 mv88e6xxx_atu_vtu_get_strings(data);
970
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000971 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100972}
973
974static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
975 int types)
976{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100977 struct mv88e6xxx_hw_stat *stat;
978 int i, j;
979
980 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
981 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100982 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100983 j++;
984 }
985 return j;
986}
987
Andrew Lunndfafe442016-11-21 23:27:02 +0100988static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
989{
990 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
991 STATS_TYPE_PORT);
992}
993
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000994static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
995{
996 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
997}
998
Andrew Lunndfafe442016-11-21 23:27:02 +0100999static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1000{
1001 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1002 STATS_TYPE_BANK1);
1003}
1004
Florian Fainelli89f09042018-04-25 12:12:50 -07001005static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001006{
1007 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001008 int serdes_count = 0;
1009 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001010
Florian Fainelli89f09042018-04-25 12:12:50 -07001011 if (sset != ETH_SS_STATS)
1012 return 0;
1013
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001014 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001015 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 count = chip->info->ops->stats_get_sset_count(chip);
1017 if (count < 0)
1018 goto out;
1019
1020 if (chip->info->ops->serdes_get_sset_count)
1021 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1022 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001023 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001024 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001025 goto out;
1026 }
1027 count += serdes_count;
1028 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1029
Andrew Lunn436fe172018-03-01 02:02:29 +01001030out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001031 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001032
Andrew Lunn436fe172018-03-01 02:02:29 +01001033 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001034}
1035
Andrew Lunn436fe172018-03-01 02:02:29 +01001036static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1037 uint64_t *data, int types,
1038 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001039{
1040 struct mv88e6xxx_hw_stat *stat;
1041 int i, j;
1042
1043 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1044 stat = &mv88e6xxx_hw_stats[i];
1045 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001046 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001047 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1048 bank1_select,
1049 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001050 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001051
Andrew Lunn052f9472016-11-21 23:27:03 +01001052 j++;
1053 }
1054 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001055 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001056}
1057
Andrew Lunn436fe172018-03-01 02:02:29 +01001058static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1059 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001060{
1061 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001062 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001063 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001064}
1065
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001066static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1067 uint64_t *data)
1068{
1069 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1070 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1071}
1072
Andrew Lunn436fe172018-03-01 02:02:29 +01001073static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1074 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001075{
1076 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001077 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001078 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1079 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001080}
1081
Andrew Lunn436fe172018-03-01 02:02:29 +01001082static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1083 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001084{
1085 return mv88e6xxx_stats_get_stats(chip, port, data,
1086 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001087 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1088 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001089}
1090
Andrew Lunn65f60e42018-03-28 23:50:28 +02001091static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1092 uint64_t *data)
1093{
1094 *data++ = chip->ports[port].atu_member_violation;
1095 *data++ = chip->ports[port].atu_miss_violation;
1096 *data++ = chip->ports[port].atu_full_violation;
1097 *data++ = chip->ports[port].vtu_member_violation;
1098 *data++ = chip->ports[port].vtu_miss_violation;
1099}
1100
Andrew Lunn052f9472016-11-21 23:27:03 +01001101static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1102 uint64_t *data)
1103{
Andrew Lunn436fe172018-03-01 02:02:29 +01001104 int count = 0;
1105
Andrew Lunn052f9472016-11-21 23:27:03 +01001106 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001107 count = chip->info->ops->stats_get_stats(chip, port, data);
1108
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001109 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001110 if (chip->info->ops->serdes_get_stats) {
1111 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001112 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001113 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001114 data += count;
1115 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001116 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001117}
1118
Vivien Didelotf81ec902016-05-09 13:22:58 -04001119static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1120 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001121{
Vivien Didelot04bed142016-08-31 18:06:13 -04001122 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001123 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001124
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001125 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001126
Andrew Lunna605a0f2016-11-21 23:26:58 +01001127 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001128 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001129
1130 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001131 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001132
1133 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001134
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001135}
Ben Hutchings98e67302011-11-25 14:36:19 +00001136
Vivien Didelotf81ec902016-05-09 13:22:58 -04001137static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001139 struct mv88e6xxx_chip *chip = ds->priv;
1140 int len;
1141
1142 len = 32 * sizeof(u16);
1143 if (chip->info->ops->serdes_get_regs_len)
1144 len += chip->info->ops->serdes_get_regs_len(chip, port);
1145
1146 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001147}
1148
Vivien Didelotf81ec902016-05-09 13:22:58 -04001149static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1150 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001151{
Vivien Didelot04bed142016-08-31 18:06:13 -04001152 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001153 int err;
1154 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001155 u16 *p = _p;
1156 int i;
1157
Vivien Didelota5f39322018-12-17 16:05:21 -05001158 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001159
1160 memset(p, 0xff, 32 * sizeof(u16));
1161
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001162 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001163
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001164 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001165
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001166 err = mv88e6xxx_port_read(chip, port, i, &reg);
1167 if (!err)
1168 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001169 }
Vivien Didelot23062512016-05-09 13:22:45 -04001170
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001171 if (chip->info->ops->serdes_get_regs)
1172 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1173
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001174 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001175}
1176
Vivien Didelot08f50062017-08-01 16:32:41 -04001177static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1178 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001179{
Vivien Didelot5480db62017-08-01 16:32:40 -04001180 /* Nothing to do on the port's MAC */
1181 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001182}
1183
Vivien Didelot08f50062017-08-01 16:32:41 -04001184static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1185 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001186{
Vivien Didelot5480db62017-08-01 16:32:40 -04001187 /* Nothing to do on the port's MAC */
1188 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001189}
1190
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001191/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001192static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001193{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001194 struct dsa_switch *ds = chip->ds;
1195 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001196 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001197 struct dsa_port *dp;
1198 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001199 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001200
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001201 list_for_each_entry(dp, &dst->ports, list) {
1202 if (dp->ds->index == dev && dp->index == port) {
1203 found = true;
1204 break;
1205 }
1206 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001207
Vivien Didelote5887a22017-03-30 17:37:11 -04001208 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001209 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001210 return 0;
1211
1212 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001213 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001214 return mv88e6xxx_port_mask(chip);
1215
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001216 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001217 pvlan = 0;
1218
1219 /* Frames from user ports can egress any local DSA links and CPU ports,
1220 * as well as any local member of their bridge group.
1221 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001222 list_for_each_entry(dp, &dst->ports, list)
1223 if (dp->ds == ds &&
1224 (dp->type == DSA_PORT_TYPE_CPU ||
1225 dp->type == DSA_PORT_TYPE_DSA ||
1226 (br && dp->bridge_dev == br)))
1227 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001228
1229 return pvlan;
1230}
1231
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001232static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001233{
1234 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001235
1236 /* prevent frames from going back out of the port they came in on */
1237 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001238
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001239 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001240}
1241
Vivien Didelotf81ec902016-05-09 13:22:58 -04001242static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1243 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001244{
Vivien Didelot04bed142016-08-31 18:06:13 -04001245 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001246 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001247
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001248 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001249 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001250 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001251
1252 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001253 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001254}
1255
Vivien Didelot93e18d62018-05-11 17:16:35 -04001256static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1257{
1258 int err;
1259
1260 if (chip->info->ops->ieee_pri_map) {
1261 err = chip->info->ops->ieee_pri_map(chip);
1262 if (err)
1263 return err;
1264 }
1265
1266 if (chip->info->ops->ip_pri_map) {
1267 err = chip->info->ops->ip_pri_map(chip);
1268 if (err)
1269 return err;
1270 }
1271
1272 return 0;
1273}
1274
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001275static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1276{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001277 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001278 int target, port;
1279 int err;
1280
1281 if (!chip->info->global2_addr)
1282 return 0;
1283
1284 /* Initialize the routing port to the 32 possible target devices */
1285 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001286 port = dsa_routing_port(ds, target);
1287 if (port == ds->num_ports)
1288 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001289
1290 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1291 if (err)
1292 return err;
1293 }
1294
Vivien Didelot02317e62018-05-09 11:38:49 -04001295 if (chip->info->ops->set_cascade_port) {
1296 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1297 err = chip->info->ops->set_cascade_port(chip, port);
1298 if (err)
1299 return err;
1300 }
1301
Vivien Didelot23c98912018-05-09 11:38:50 -04001302 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1303 if (err)
1304 return err;
1305
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001306 return 0;
1307}
1308
Vivien Didelotb28f8722018-04-26 21:56:44 -04001309static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1310{
1311 /* Clear all trunk masks and mapping */
1312 if (chip->info->global2_addr)
1313 return mv88e6xxx_g2_trunk_clear(chip);
1314
1315 return 0;
1316}
1317
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001318static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1319{
1320 if (chip->info->ops->rmu_disable)
1321 return chip->info->ops->rmu_disable(chip);
1322
1323 return 0;
1324}
1325
Vivien Didelot9e907d72017-07-17 13:03:43 -04001326static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1327{
1328 if (chip->info->ops->pot_clear)
1329 return chip->info->ops->pot_clear(chip);
1330
1331 return 0;
1332}
1333
Vivien Didelot51c901a2017-07-17 13:03:41 -04001334static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1335{
1336 if (chip->info->ops->mgmt_rsvd2cpu)
1337 return chip->info->ops->mgmt_rsvd2cpu(chip);
1338
1339 return 0;
1340}
1341
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001342static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1343{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001344 int err;
1345
Vivien Didelotdaefc942017-03-11 16:12:54 -05001346 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1347 if (err)
1348 return err;
1349
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001350 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1351 if (err)
1352 return err;
1353
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001354 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1355}
1356
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001357static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1358{
1359 int port;
1360 int err;
1361
1362 if (!chip->info->ops->irl_init_all)
1363 return 0;
1364
1365 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1366 /* Disable ingress rate limiting by resetting all per port
1367 * ingress rate limit resources to their initial state.
1368 */
1369 err = chip->info->ops->irl_init_all(chip, port);
1370 if (err)
1371 return err;
1372 }
1373
1374 return 0;
1375}
1376
Vivien Didelot04a69a12017-10-13 14:18:05 -04001377static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1378{
1379 if (chip->info->ops->set_switch_mac) {
1380 u8 addr[ETH_ALEN];
1381
1382 eth_random_addr(addr);
1383
1384 return chip->info->ops->set_switch_mac(chip, addr);
1385 }
1386
1387 return 0;
1388}
1389
Vivien Didelot17a15942017-03-30 17:37:09 -04001390static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1391{
1392 u16 pvlan = 0;
1393
1394 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001395 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001396
1397 /* Skip the local source device, which uses in-chip port VLAN */
1398 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001399 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001400
1401 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1402}
1403
Vivien Didelot81228992017-03-30 17:37:08 -04001404static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1405{
Vivien Didelot17a15942017-03-30 17:37:09 -04001406 int dev, port;
1407 int err;
1408
Vivien Didelot81228992017-03-30 17:37:08 -04001409 if (!mv88e6xxx_has_pvt(chip))
1410 return 0;
1411
1412 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1413 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1414 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001415 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1416 if (err)
1417 return err;
1418
1419 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1420 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1421 err = mv88e6xxx_pvt_map(chip, dev, port);
1422 if (err)
1423 return err;
1424 }
1425 }
1426
1427 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001428}
1429
Vivien Didelot749efcb2016-09-22 16:49:24 -04001430static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1431{
1432 struct mv88e6xxx_chip *chip = ds->priv;
1433 int err;
1434
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001435 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001436 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001437 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001438
1439 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001440 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001441}
1442
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001443static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1444{
Tobias Waldekranze545f862020-11-10 19:57:20 +01001445 if (!mv88e6xxx_max_vid(chip))
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001446 return 0;
1447
1448 return mv88e6xxx_g1_vtu_flush(chip);
1449}
1450
Vivien Didelotf1394b782017-05-01 14:05:22 -04001451static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1452 struct mv88e6xxx_vtu_entry *entry)
1453{
1454 if (!chip->info->ops->vtu_getnext)
1455 return -EOPNOTSUPP;
1456
1457 return chip->info->ops->vtu_getnext(chip, entry);
1458}
1459
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001460static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1461 struct mv88e6xxx_vtu_entry *entry)
1462{
1463 if (!chip->info->ops->vtu_loadpurge)
1464 return -EOPNOTSUPP;
1465
1466 return chip->info->ops->vtu_loadpurge(chip, entry);
1467}
1468
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001469int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001470{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001471 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001472 int i, err;
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001473 u16 fid;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001474
1475 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1476
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001477 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001478 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001479 err = mv88e6xxx_port_get_fid(chip, i, &fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001480 if (err)
1481 return err;
1482
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001483 set_bit(fid, fid_bitmap);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001484 }
1485
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001486 /* Set every FID bit used by the VLAN entries */
Tobias Waldekranze545f862020-11-10 19:57:20 +01001487 vlan.vid = mv88e6xxx_max_vid(chip);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001488 vlan.valid = false;
1489
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001490 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001491 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001492 if (err)
1493 return err;
1494
1495 if (!vlan.valid)
1496 break;
1497
1498 set_bit(vlan.fid, fid_bitmap);
Tobias Waldekranze545f862020-11-10 19:57:20 +01001499 } while (vlan.vid < mv88e6xxx_max_vid(chip));
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001500
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001501 return 0;
1502}
1503
1504static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1505{
1506 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1507 int err;
1508
1509 err = mv88e6xxx_fid_map(chip, fid_bitmap);
1510 if (err)
1511 return err;
1512
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001513 /* The reset value 0x000 is used to indicate that multiple address
1514 * databases are not needed. Return the next positive available.
1515 */
1516 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001517 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001518 return -ENOSPC;
1519
1520 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001521 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001522}
1523
Vivien Didelotda9c3592016-02-12 12:09:40 -05001524static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1525 u16 vid_begin, u16 vid_end)
1526{
Vivien Didelot04bed142016-08-31 18:06:13 -04001527 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001528 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001529 int i, err;
1530
Andrew Lunndb06ae412017-09-25 23:32:20 +02001531 /* DSA and CPU ports have to be members of multiple vlans */
1532 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1533 return 0;
1534
Vivien Didelotda9c3592016-02-12 12:09:40 -05001535 if (!vid_begin)
1536 return -EOPNOTSUPP;
1537
Vivien Didelot425d2d32019-08-01 14:36:34 -04001538 vlan.vid = vid_begin - 1;
1539 vlan.valid = false;
1540
Vivien Didelotda9c3592016-02-12 12:09:40 -05001541 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001542 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001543 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001544 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001545
1546 if (!vlan.valid)
1547 break;
1548
1549 if (vlan.vid > vid_end)
1550 break;
1551
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001552 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001553 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1554 continue;
1555
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001556 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001557 continue;
1558
Vivien Didelotbd00e052017-05-01 14:05:11 -04001559 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001560 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001561 continue;
1562
Vivien Didelotc8652c82017-10-16 11:12:19 -04001563 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001564 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001565 break; /* same bridge, check next VLAN */
1566
Vivien Didelotc8652c82017-10-16 11:12:19 -04001567 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001568 continue;
1569
Andrew Lunn743fcc22017-11-09 22:29:54 +01001570 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1571 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001572 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001573 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001574 }
1575 } while (vlan.vid < vid_end);
1576
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001577 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001578}
1579
Vivien Didelotf81ec902016-05-09 13:22:58 -04001580static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
Vladimir Oltean2e554a72020-10-03 01:06:46 +03001581 bool vlan_filtering,
1582 struct switchdev_trans *trans)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001583{
Vivien Didelot04bed142016-08-31 18:06:13 -04001584 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001585 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1586 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001587 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001588
Vladimir Oltean2e554a72020-10-03 01:06:46 +03001589 if (switchdev_trans_ph_prepare(trans))
Tobias Waldekranze545f862020-11-10 19:57:20 +01001590 return mv88e6xxx_max_vid(chip) ? 0 : -EOPNOTSUPP;
Vivien Didelot54d77b52016-05-09 13:22:47 -04001591
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001592 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001593 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001594 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001595
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001596 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001597}
1598
Vivien Didelot57d32312016-06-20 13:13:58 -04001599static int
1600mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001601 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001602{
Vivien Didelot04bed142016-08-31 18:06:13 -04001603 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001604 int err;
1605
Tobias Waldekranze545f862020-11-10 19:57:20 +01001606 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001607 return -EOPNOTSUPP;
1608
Vivien Didelotda9c3592016-02-12 12:09:40 -05001609 /* If the requested port doesn't belong to the same bridge as the VLAN
1610 * members, do not support it (yet) and fallback to software VLAN.
1611 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001612 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001613 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1614 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001615 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001616
Vivien Didelot76e398a2015-11-01 12:33:55 -05001617 /* We don't need any dynamic resource from the kernel (yet),
1618 * so skip the prepare phase.
1619 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001620 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001621}
1622
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001623static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1624 const unsigned char *addr, u16 vid,
1625 u8 state)
1626{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001627 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001628 struct mv88e6xxx_vtu_entry vlan;
1629 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001630 int err;
1631
1632 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001633 if (vid == 0) {
1634 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1635 if (err)
1636 return err;
1637 } else {
1638 vlan.vid = vid - 1;
1639 vlan.valid = false;
1640
1641 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1642 if (err)
1643 return err;
1644
1645 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1646 if (vlan.vid != vid || !vlan.valid)
1647 return -EOPNOTSUPP;
1648
1649 fid = vlan.fid;
1650 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001651
Vivien Didelotd8291a92019-09-07 16:00:47 -04001652 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001653 ether_addr_copy(entry.mac, addr);
1654 eth_addr_dec(entry.mac);
1655
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001656 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001657 if (err)
1658 return err;
1659
1660 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001661 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001662 memset(&entry, 0, sizeof(entry));
1663 ether_addr_copy(entry.mac, addr);
1664 }
1665
1666 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001667 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001668 entry.portvec &= ~BIT(port);
1669 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001670 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001671 } else {
1672 entry.portvec |= BIT(port);
1673 entry.state = state;
1674 }
1675
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001676 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001677}
1678
Vivien Didelotda7dc872019-09-07 16:00:49 -04001679static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1680 const struct mv88e6xxx_policy *policy)
1681{
1682 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1683 enum mv88e6xxx_policy_action action = policy->action;
1684 const u8 *addr = policy->addr;
1685 u16 vid = policy->vid;
1686 u8 state;
1687 int err;
1688 int id;
1689
1690 if (!chip->info->ops->port_set_policy)
1691 return -EOPNOTSUPP;
1692
1693 switch (mapping) {
1694 case MV88E6XXX_POLICY_MAPPING_DA:
1695 case MV88E6XXX_POLICY_MAPPING_SA:
1696 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1697 state = 0; /* Dissociate the port and address */
1698 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1699 is_multicast_ether_addr(addr))
1700 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1701 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1702 is_unicast_ether_addr(addr))
1703 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1704 else
1705 return -EOPNOTSUPP;
1706
1707 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1708 state);
1709 if (err)
1710 return err;
1711 break;
1712 default:
1713 return -EOPNOTSUPP;
1714 }
1715
1716 /* Skip the port's policy clearing if the mapping is still in use */
1717 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1718 idr_for_each_entry(&chip->policies, policy, id)
1719 if (policy->port == port &&
1720 policy->mapping == mapping &&
1721 policy->action != action)
1722 return 0;
1723
1724 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1725}
1726
1727static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1728 struct ethtool_rx_flow_spec *fs)
1729{
1730 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1731 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1732 enum mv88e6xxx_policy_mapping mapping;
1733 enum mv88e6xxx_policy_action action;
1734 struct mv88e6xxx_policy *policy;
1735 u16 vid = 0;
1736 u8 *addr;
1737 int err;
1738 int id;
1739
1740 if (fs->location != RX_CLS_LOC_ANY)
1741 return -EINVAL;
1742
1743 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1744 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1745 else
1746 return -EOPNOTSUPP;
1747
1748 switch (fs->flow_type & ~FLOW_EXT) {
1749 case ETHER_FLOW:
1750 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1751 is_zero_ether_addr(mac_mask->h_source)) {
1752 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1753 addr = mac_entry->h_dest;
1754 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1755 !is_zero_ether_addr(mac_mask->h_source)) {
1756 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1757 addr = mac_entry->h_source;
1758 } else {
1759 /* Cannot support DA and SA mapping in the same rule */
1760 return -EOPNOTSUPP;
1761 }
1762 break;
1763 default:
1764 return -EOPNOTSUPP;
1765 }
1766
1767 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001768 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001769 return -EOPNOTSUPP;
1770 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1771 }
1772
1773 idr_for_each_entry(&chip->policies, policy, id) {
1774 if (policy->port == port && policy->mapping == mapping &&
1775 policy->action == action && policy->vid == vid &&
1776 ether_addr_equal(policy->addr, addr))
1777 return -EEXIST;
1778 }
1779
1780 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1781 if (!policy)
1782 return -ENOMEM;
1783
1784 fs->location = 0;
1785 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1786 GFP_KERNEL);
1787 if (err) {
1788 devm_kfree(chip->dev, policy);
1789 return err;
1790 }
1791
1792 memcpy(&policy->fs, fs, sizeof(*fs));
1793 ether_addr_copy(policy->addr, addr);
1794 policy->mapping = mapping;
1795 policy->action = action;
1796 policy->port = port;
1797 policy->vid = vid;
1798
1799 err = mv88e6xxx_policy_apply(chip, port, policy);
1800 if (err) {
1801 idr_remove(&chip->policies, fs->location);
1802 devm_kfree(chip->dev, policy);
1803 return err;
1804 }
1805
1806 return 0;
1807}
1808
1809static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1810 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1811{
1812 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1813 struct mv88e6xxx_chip *chip = ds->priv;
1814 struct mv88e6xxx_policy *policy;
1815 int err;
1816 int id;
1817
1818 mv88e6xxx_reg_lock(chip);
1819
1820 switch (rxnfc->cmd) {
1821 case ETHTOOL_GRXCLSRLCNT:
1822 rxnfc->data = 0;
1823 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1824 rxnfc->rule_cnt = 0;
1825 idr_for_each_entry(&chip->policies, policy, id)
1826 if (policy->port == port)
1827 rxnfc->rule_cnt++;
1828 err = 0;
1829 break;
1830 case ETHTOOL_GRXCLSRULE:
1831 err = -ENOENT;
1832 policy = idr_find(&chip->policies, fs->location);
1833 if (policy) {
1834 memcpy(fs, &policy->fs, sizeof(*fs));
1835 err = 0;
1836 }
1837 break;
1838 case ETHTOOL_GRXCLSRLALL:
1839 rxnfc->data = 0;
1840 rxnfc->rule_cnt = 0;
1841 idr_for_each_entry(&chip->policies, policy, id)
1842 if (policy->port == port)
1843 rule_locs[rxnfc->rule_cnt++] = id;
1844 err = 0;
1845 break;
1846 default:
1847 err = -EOPNOTSUPP;
1848 break;
1849 }
1850
1851 mv88e6xxx_reg_unlock(chip);
1852
1853 return err;
1854}
1855
1856static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1857 struct ethtool_rxnfc *rxnfc)
1858{
1859 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1860 struct mv88e6xxx_chip *chip = ds->priv;
1861 struct mv88e6xxx_policy *policy;
1862 int err;
1863
1864 mv88e6xxx_reg_lock(chip);
1865
1866 switch (rxnfc->cmd) {
1867 case ETHTOOL_SRXCLSRLINS:
1868 err = mv88e6xxx_policy_insert(chip, port, fs);
1869 break;
1870 case ETHTOOL_SRXCLSRLDEL:
1871 err = -ENOENT;
1872 policy = idr_remove(&chip->policies, fs->location);
1873 if (policy) {
1874 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1875 err = mv88e6xxx_policy_apply(chip, port, policy);
1876 devm_kfree(chip->dev, policy);
1877 }
1878 break;
1879 default:
1880 err = -EOPNOTSUPP;
1881 break;
1882 }
1883
1884 mv88e6xxx_reg_unlock(chip);
1885
1886 return err;
1887}
1888
Andrew Lunn87fa8862017-11-09 22:29:56 +01001889static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1890 u16 vid)
1891{
1892 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1893 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1894
1895 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1896}
1897
1898static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1899{
1900 int port;
1901 int err;
1902
1903 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1904 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1905 if (err)
1906 return err;
1907 }
1908
1909 return 0;
1910}
1911
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001912static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001913 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001914{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001915 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001916 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001917 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001918
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001919 if (!vid)
1920 return -EOPNOTSUPP;
1921
1922 vlan.vid = vid - 1;
1923 vlan.valid = false;
1924
1925 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001926 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001927 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001928
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001929 if (vlan.vid != vid || !vlan.valid) {
1930 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001931
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001932 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1933 if (err)
1934 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001935
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001936 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1937 if (i == port)
1938 vlan.member[i] = member;
1939 else
1940 vlan.member[i] = non_member;
1941
1942 vlan.vid = vid;
1943 vlan.valid = true;
1944
1945 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1946 if (err)
1947 return err;
1948
1949 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1950 if (err)
1951 return err;
1952 } else if (vlan.member[port] != member) {
1953 vlan.member[port] = member;
1954
1955 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1956 if (err)
1957 return err;
Russell King933b4422020-02-26 17:14:26 +00001958 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001959 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1960 port, vid);
1961 }
1962
1963 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001964}
1965
Vivien Didelotf81ec902016-05-09 13:22:58 -04001966static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001967 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001968{
Vivien Didelot04bed142016-08-31 18:06:13 -04001969 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001970 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1971 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001972 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001973 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001974 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001975
Tobias Waldekranze545f862020-11-10 19:57:20 +01001976 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001977 return;
1978
Vivien Didelotc91498e2017-06-07 18:12:13 -04001979 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001980 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001981 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001982 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001983 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001984 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001985
Russell King933b4422020-02-26 17:14:26 +00001986 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1987 * and then the CPU port. Do not warn for duplicates for the CPU port.
1988 */
1989 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1990
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001991 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001992
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001993 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001994 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001995 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1996 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001997
Vivien Didelot77064f32016-11-04 03:23:30 +01001998 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001999 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
2000 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04002001
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002002 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002003}
2004
Vivien Didelot521098922019-08-01 14:36:36 -04002005static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2006 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002007{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002008 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002009 int i, err;
2010
Vivien Didelot521098922019-08-01 14:36:36 -04002011 if (!vid)
2012 return -EOPNOTSUPP;
2013
2014 vlan.vid = vid - 1;
2015 vlan.valid = false;
2016
2017 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002018 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002019 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002020
Vivien Didelot521098922019-08-01 14:36:36 -04002021 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2022 * tell switchdev that this VLAN is likely handled in software.
2023 */
2024 if (vlan.vid != vid || !vlan.valid ||
2025 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002026 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002027
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002028 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002029
2030 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002031 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002032 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002033 if (vlan.member[i] !=
2034 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002035 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002036 break;
2037 }
2038 }
2039
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002040 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002041 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002042 return err;
2043
Vivien Didelote606ca32017-03-11 16:12:55 -05002044 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002045}
2046
Vivien Didelotf81ec902016-05-09 13:22:58 -04002047static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2048 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002049{
Vivien Didelot04bed142016-08-31 18:06:13 -04002050 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002051 u16 pvid, vid;
2052 int err = 0;
2053
Tobias Waldekranze545f862020-11-10 19:57:20 +01002054 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04002055 return -EOPNOTSUPP;
2056
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002057 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002058
Vivien Didelot77064f32016-11-04 03:23:30 +01002059 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002060 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002061 goto unlock;
2062
Vivien Didelot76e398a2015-11-01 12:33:55 -05002063 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04002064 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002065 if (err)
2066 goto unlock;
2067
2068 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002069 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002070 if (err)
2071 goto unlock;
2072 }
2073 }
2074
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002075unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002076 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002077
2078 return err;
2079}
2080
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002081static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2082 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002083{
Vivien Didelot04bed142016-08-31 18:06:13 -04002084 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002085 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002086
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002087 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002088 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2089 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002090 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002091
2092 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002093}
2094
Vivien Didelotf81ec902016-05-09 13:22:58 -04002095static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002096 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002097{
Vivien Didelot04bed142016-08-31 18:06:13 -04002098 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002099 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002100
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002101 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002102 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002103 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002104
Vivien Didelot83dabd12016-08-31 11:50:04 -04002105 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002106}
2107
Vivien Didelot83dabd12016-08-31 11:50:04 -04002108static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2109 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002110 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002111{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002112 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002113 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002114 int err;
2115
Vivien Didelotd8291a92019-09-07 16:00:47 -04002116 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002117 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002118
2119 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002120 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002121 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002122 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002123
Vivien Didelotd8291a92019-09-07 16:00:47 -04002124 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002125 break;
2126
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002127 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002128 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002129
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002130 if (!is_unicast_ether_addr(addr.mac))
2131 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002132
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002133 is_static = (addr.state ==
2134 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2135 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002136 if (err)
2137 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002138 } while (!is_broadcast_ether_addr(addr.mac));
2139
2140 return err;
2141}
2142
Vivien Didelot83dabd12016-08-31 11:50:04 -04002143static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002144 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002145{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002146 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002147 u16 fid;
2148 int err;
2149
2150 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002151 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002152 if (err)
2153 return err;
2154
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002155 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002156 if (err)
2157 return err;
2158
2159 /* Dump VLANs' Filtering Information Databases */
Tobias Waldekranze545f862020-11-10 19:57:20 +01002160 vlan.vid = mv88e6xxx_max_vid(chip);
Vivien Didelot425d2d32019-08-01 14:36:34 -04002161 vlan.valid = false;
2162
Vivien Didelot83dabd12016-08-31 11:50:04 -04002163 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002164 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002165 if (err)
2166 return err;
2167
2168 if (!vlan.valid)
2169 break;
2170
2171 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002172 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002173 if (err)
2174 return err;
Tobias Waldekranze545f862020-11-10 19:57:20 +01002175 } while (vlan.vid < mv88e6xxx_max_vid(chip));
Vivien Didelot83dabd12016-08-31 11:50:04 -04002176
2177 return err;
2178}
2179
Vivien Didelotf81ec902016-05-09 13:22:58 -04002180static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002181 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002182{
Vivien Didelot04bed142016-08-31 18:06:13 -04002183 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002184 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002185
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002186 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002187 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002188 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002189
2190 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002191}
2192
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002193static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2194 struct net_device *br)
2195{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002196 struct dsa_switch *ds = chip->ds;
2197 struct dsa_switch_tree *dst = ds->dst;
2198 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002199 int err;
2200
Vivien Didelotef2025e2019-10-21 16:51:27 -04002201 list_for_each_entry(dp, &dst->ports, list) {
2202 if (dp->bridge_dev == br) {
2203 if (dp->ds == ds) {
2204 /* This is a local bridge group member,
2205 * remap its Port VLAN Map.
2206 */
2207 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2208 if (err)
2209 return err;
2210 } else {
2211 /* This is an external bridge group member,
2212 * remap its cross-chip Port VLAN Table entry.
2213 */
2214 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2215 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002216 if (err)
2217 return err;
2218 }
2219 }
2220 }
2221
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002222 return 0;
2223}
2224
Vivien Didelotf81ec902016-05-09 13:22:58 -04002225static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002226 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002227{
Vivien Didelot04bed142016-08-31 18:06:13 -04002228 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002229 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002230
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002231 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002232 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002233 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002234
Vivien Didelot466dfa02016-02-26 13:16:05 -05002235 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002236}
2237
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002238static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2239 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002240{
Vivien Didelot04bed142016-08-31 18:06:13 -04002241 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002242
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002243 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002244 if (mv88e6xxx_bridge_map(chip, br) ||
2245 mv88e6xxx_port_vlan_map(chip, port))
2246 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002247 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002248}
2249
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002250static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2251 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002252 int port, struct net_device *br)
2253{
2254 struct mv88e6xxx_chip *chip = ds->priv;
2255 int err;
2256
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002257 if (tree_index != ds->dst->index)
2258 return 0;
2259
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002260 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002261 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002262 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002263
2264 return err;
2265}
2266
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002267static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2268 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002269 int port, struct net_device *br)
2270{
2271 struct mv88e6xxx_chip *chip = ds->priv;
2272
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002273 if (tree_index != ds->dst->index)
2274 return;
2275
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002276 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002277 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002278 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002279 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002280}
2281
Vivien Didelot17e708b2016-12-05 17:30:27 -05002282static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2283{
2284 if (chip->info->ops->reset)
2285 return chip->info->ops->reset(chip);
2286
2287 return 0;
2288}
2289
Vivien Didelot309eca62016-12-05 17:30:26 -05002290static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2291{
2292 struct gpio_desc *gpiod = chip->reset;
2293
2294 /* If there is a GPIO connected to the reset pin, toggle it */
2295 if (gpiod) {
2296 gpiod_set_value_cansleep(gpiod, 1);
2297 usleep_range(10000, 20000);
2298 gpiod_set_value_cansleep(gpiod, 0);
2299 usleep_range(10000, 20000);
Andrew Lunna3dcb3e2020-11-16 08:43:01 -08002300
2301 mv88e6xxx_g1_wait_eeprom_done(chip);
Vivien Didelot309eca62016-12-05 17:30:26 -05002302 }
2303}
2304
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002305static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2306{
2307 int i, err;
2308
2309 /* Set all ports to the Disabled state */
2310 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002311 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002312 if (err)
2313 return err;
2314 }
2315
2316 /* Wait for transmit queues to drain,
2317 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2318 */
2319 usleep_range(2000, 4000);
2320
2321 return 0;
2322}
2323
Vivien Didelotfad09c72016-06-21 12:28:20 -04002324static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002325{
Vivien Didelota935c052016-09-29 12:21:53 -04002326 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002327
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002328 err = mv88e6xxx_disable_ports(chip);
2329 if (err)
2330 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002331
Vivien Didelot309eca62016-12-05 17:30:26 -05002332 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002333
Vivien Didelot17e708b2016-12-05 17:30:27 -05002334 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002335}
2336
Vivien Didelot43145572017-03-11 16:12:59 -05002337static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002338 enum mv88e6xxx_frame_mode frame,
2339 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002340{
2341 int err;
2342
Vivien Didelot43145572017-03-11 16:12:59 -05002343 if (!chip->info->ops->port_set_frame_mode)
2344 return -EOPNOTSUPP;
2345
2346 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002347 if (err)
2348 return err;
2349
Vivien Didelot43145572017-03-11 16:12:59 -05002350 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2351 if (err)
2352 return err;
2353
2354 if (chip->info->ops->port_set_ether_type)
2355 return chip->info->ops->port_set_ether_type(chip, port, etype);
2356
2357 return 0;
2358}
2359
2360static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2361{
2362 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002363 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002364 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002365}
2366
2367static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2368{
2369 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002370 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002371 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002372}
2373
2374static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2375{
2376 return mv88e6xxx_set_port_mode(chip, port,
2377 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002378 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2379 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002380}
2381
2382static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2383{
2384 if (dsa_is_dsa_port(chip->ds, port))
2385 return mv88e6xxx_set_port_mode_dsa(chip, port);
2386
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002387 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002388 return mv88e6xxx_set_port_mode_normal(chip, port);
2389
2390 /* Setup CPU port mode depending on its supported tag format */
2391 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2392 return mv88e6xxx_set_port_mode_dsa(chip, port);
2393
2394 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2395 return mv88e6xxx_set_port_mode_edsa(chip, port);
2396
2397 return -EINVAL;
2398}
2399
Vivien Didelotea698f42017-03-11 16:12:50 -05002400static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2401{
2402 bool message = dsa_is_dsa_port(chip->ds, port);
2403
2404 return mv88e6xxx_port_set_message_port(chip, port, message);
2405}
2406
Vivien Didelot601aeed2017-03-11 16:13:00 -05002407static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2408{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002409 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002410 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002411
David S. Miller407308f2019-06-15 13:35:29 -07002412 /* Upstream ports flood frames with unknown unicast or multicast DA */
2413 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2414 if (chip->info->ops->port_set_egress_floods)
2415 return chip->info->ops->port_set_egress_floods(chip, port,
2416 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002417
David S. Miller407308f2019-06-15 13:35:29 -07002418 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002419}
2420
Vivien Didelot45de77f2019-08-31 16:18:36 -04002421static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2422{
2423 struct mv88e6xxx_port *mvp = dev_id;
2424 struct mv88e6xxx_chip *chip = mvp->chip;
2425 irqreturn_t ret = IRQ_NONE;
2426 int port = mvp->port;
2427 u8 lane;
2428
2429 mv88e6xxx_reg_lock(chip);
2430 lane = mv88e6xxx_serdes_get_lane(chip, port);
2431 if (lane)
2432 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2433 mv88e6xxx_reg_unlock(chip);
2434
2435 return ret;
2436}
2437
2438static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2439 u8 lane)
2440{
2441 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2442 unsigned int irq;
2443 int err;
2444
2445 /* Nothing to request if this SERDES port has no IRQ */
2446 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2447 if (!irq)
2448 return 0;
2449
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002450 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2451 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2452
Vivien Didelot45de77f2019-08-31 16:18:36 -04002453 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2454 mv88e6xxx_reg_unlock(chip);
2455 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002456 IRQF_ONESHOT, dev_id->serdes_irq_name,
2457 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002458 mv88e6xxx_reg_lock(chip);
2459 if (err)
2460 return err;
2461
2462 dev_id->serdes_irq = irq;
2463
2464 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2465}
2466
2467static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2468 u8 lane)
2469{
2470 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2471 unsigned int irq = dev_id->serdes_irq;
2472 int err;
2473
2474 /* Nothing to free if no IRQ has been requested */
2475 if (!irq)
2476 return 0;
2477
2478 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2479
2480 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2481 mv88e6xxx_reg_unlock(chip);
2482 free_irq(irq, dev_id);
2483 mv88e6xxx_reg_lock(chip);
2484
2485 dev_id->serdes_irq = 0;
2486
2487 return err;
2488}
2489
Andrew Lunn6d917822017-05-26 01:03:21 +02002490static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2491 bool on)
2492{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002493 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002494 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002495
Vivien Didelotdc272f62019-08-31 16:18:33 -04002496 lane = mv88e6xxx_serdes_get_lane(chip, port);
2497 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002498 return 0;
2499
2500 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002501 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002502 if (err)
2503 return err;
2504
Vivien Didelot45de77f2019-08-31 16:18:36 -04002505 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002506 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002507 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2508 if (err)
2509 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002510
Vivien Didelotdc272f62019-08-31 16:18:33 -04002511 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002512 }
2513
2514 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002515}
2516
Vivien Didelotfa371c82017-12-05 15:34:10 -05002517static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2518{
2519 struct dsa_switch *ds = chip->ds;
2520 int upstream_port;
2521 int err;
2522
Vivien Didelot07073c72017-12-05 15:34:13 -05002523 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002524 if (chip->info->ops->port_set_upstream_port) {
2525 err = chip->info->ops->port_set_upstream_port(chip, port,
2526 upstream_port);
2527 if (err)
2528 return err;
2529 }
2530
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002531 if (port == upstream_port) {
2532 if (chip->info->ops->set_cpu_port) {
2533 err = chip->info->ops->set_cpu_port(chip,
2534 upstream_port);
2535 if (err)
2536 return err;
2537 }
2538
2539 if (chip->info->ops->set_egress_port) {
2540 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002541 MV88E6XXX_EGRESS_DIR_INGRESS,
2542 upstream_port);
2543 if (err)
2544 return err;
2545
2546 err = chip->info->ops->set_egress_port(chip,
2547 MV88E6XXX_EGRESS_DIR_EGRESS,
2548 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002549 if (err)
2550 return err;
2551 }
2552 }
2553
Vivien Didelotfa371c82017-12-05 15:34:10 -05002554 return 0;
2555}
2556
Vivien Didelotfad09c72016-06-21 12:28:20 -04002557static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002558{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002559 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002560 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002561 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002562
Andrew Lunn7b898462018-08-09 15:38:47 +02002563 chip->ports[port].chip = chip;
2564 chip->ports[port].port = port;
2565
Vivien Didelotd78343d2016-11-04 03:23:36 +01002566 /* MAC Forcing register: don't force link, speed, duplex or flow control
2567 * state to any particular values on physical ports, but force the CPU
2568 * port and all DSA ports to their maximum bandwidth and full duplex.
2569 */
2570 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2571 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2572 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002573 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002574 PHY_INTERFACE_MODE_NA);
2575 else
2576 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2577 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002578 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002579 PHY_INTERFACE_MODE_NA);
2580 if (err)
2581 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002582
2583 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2584 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2585 * tunneling, determine priority by looking at 802.1p and IP
2586 * priority fields (IP prio has precedence), and set STP state
2587 * to Forwarding.
2588 *
2589 * If this is the CPU link, use DSA or EDSA tagging depending
2590 * on which tagging mode was configured.
2591 *
2592 * If this is a link to another switch, use DSA tagging mode.
2593 *
2594 * If this is the upstream port for this switch, enable
2595 * forwarding of unknown unicasts and multicasts.
2596 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002597 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2598 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2599 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2600 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002601 if (err)
2602 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002603
Vivien Didelot601aeed2017-03-11 16:13:00 -05002604 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002605 if (err)
2606 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002607
Vivien Didelot601aeed2017-03-11 16:13:00 -05002608 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002609 if (err)
2610 return err;
2611
Vivien Didelot8efdda42015-08-13 12:52:23 -04002612 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002613 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002614 * untagged frames on this port, do a destination address lookup on all
2615 * received packets as usual, disable ARP mirroring and don't send a
2616 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002617 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002618 err = mv88e6xxx_port_set_map_da(chip, port);
2619 if (err)
2620 return err;
2621
Vivien Didelotfa371c82017-12-05 15:34:10 -05002622 err = mv88e6xxx_setup_upstream_port(chip, port);
2623 if (err)
2624 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002625
Andrew Lunna23b2962017-02-04 20:15:28 +01002626 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002627 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002628 if (err)
2629 return err;
2630
Vivien Didelotcd782652017-06-08 18:34:13 -04002631 if (chip->info->ops->port_set_jumbo_size) {
2632 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002633 if (err)
2634 return err;
2635 }
2636
Andrew Lunn54d792f2015-05-06 01:09:47 +02002637 /* Port Association Vector: when learning source addresses
2638 * of packets, add the address to the address database using
2639 * a port bitmap that has only the bit for this port set and
2640 * the other bits clear.
2641 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002642 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002643 /* Disable learning for CPU port */
2644 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002645 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002646
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002647 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2648 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002649 if (err)
2650 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002651
2652 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002653 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2654 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002655 if (err)
2656 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002657
Vivien Didelot08984322017-06-08 18:34:12 -04002658 if (chip->info->ops->port_pause_limit) {
2659 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002660 if (err)
2661 return err;
2662 }
2663
Vivien Didelotc8c94892017-03-11 16:13:01 -05002664 if (chip->info->ops->port_disable_learn_limit) {
2665 err = chip->info->ops->port_disable_learn_limit(chip, port);
2666 if (err)
2667 return err;
2668 }
2669
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002670 if (chip->info->ops->port_disable_pri_override) {
2671 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002672 if (err)
2673 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002674 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002675
Andrew Lunnef0a7312016-12-03 04:35:16 +01002676 if (chip->info->ops->port_tag_remap) {
2677 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002678 if (err)
2679 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002680 }
2681
Andrew Lunnef70b112016-12-03 04:45:18 +01002682 if (chip->info->ops->port_egress_rate_limiting) {
2683 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002684 if (err)
2685 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002686 }
2687
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002688 if (chip->info->ops->port_setup_message_port) {
2689 err = chip->info->ops->port_setup_message_port(chip, port);
2690 if (err)
2691 return err;
2692 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002693
Vivien Didelot207afda2016-04-14 14:42:09 -04002694 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002695 * database, and allow bidirectional communication between the
2696 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002697 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002698 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002699 if (err)
2700 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002701
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002702 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002703 if (err)
2704 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002705
2706 /* Default VLAN ID and priority: don't set a default VLAN
2707 * ID, and set the default packet priority to zero.
2708 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002709 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002710}
2711
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002712static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
2713{
2714 struct mv88e6xxx_chip *chip = ds->priv;
2715
2716 if (chip->info->ops->port_set_jumbo_size)
2717 return 10240;
Chris Packham1baf0fa2020-07-24 11:21:22 +12002718 else if (chip->info->ops->set_max_frame_size)
2719 return 1632;
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002720 return 1522;
2721}
2722
2723static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
2724{
2725 struct mv88e6xxx_chip *chip = ds->priv;
2726 int ret = 0;
2727
2728 mv88e6xxx_reg_lock(chip);
2729 if (chip->info->ops->port_set_jumbo_size)
2730 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Chris Packham1baf0fa2020-07-24 11:21:22 +12002731 else if (chip->info->ops->set_max_frame_size)
2732 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002733 else
2734 if (new_mtu > 1522)
2735 ret = -EINVAL;
2736 mv88e6xxx_reg_unlock(chip);
2737
2738 return ret;
2739}
2740
Andrew Lunn04aca992017-05-26 01:03:24 +02002741static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2742 struct phy_device *phydev)
2743{
2744 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002745 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002746
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002747 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002748 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002749 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002750
2751 return err;
2752}
2753
Andrew Lunn75104db2019-02-24 20:44:43 +01002754static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002755{
2756 struct mv88e6xxx_chip *chip = ds->priv;
2757
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002758 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002759 if (mv88e6xxx_serdes_power(chip, port, false))
2760 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002761 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002762}
2763
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002764static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2765 unsigned int ageing_time)
2766{
Vivien Didelot04bed142016-08-31 18:06:13 -04002767 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002768 int err;
2769
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002770 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002771 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002772 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002773
2774 return err;
2775}
2776
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002777static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002778{
2779 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002780
Andrew Lunnde2273872016-11-21 23:27:01 +01002781 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002782 if (chip->info->ops->stats_set_histogram) {
2783 err = chip->info->ops->stats_set_histogram(chip);
2784 if (err)
2785 return err;
2786 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002787
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002788 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002789}
2790
Andrew Lunnea890982019-01-09 00:24:03 +01002791/* Check if the errata has already been applied. */
2792static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2793{
2794 int port;
2795 int err;
2796 u16 val;
2797
2798 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002799 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002800 if (err) {
2801 dev_err(chip->dev,
2802 "Error reading hidden register: %d\n", err);
2803 return false;
2804 }
2805 if (val != 0x01c0)
2806 return false;
2807 }
2808
2809 return true;
2810}
2811
2812/* The 6390 copper ports have an errata which require poking magic
2813 * values into undocumented hidden registers and then performing a
2814 * software reset.
2815 */
2816static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2817{
2818 int port;
2819 int err;
2820
2821 if (mv88e6390_setup_errata_applied(chip))
2822 return 0;
2823
2824 /* Set the ports into blocking mode */
2825 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2826 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2827 if (err)
2828 return err;
2829 }
2830
2831 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002832 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002833 if (err)
2834 return err;
2835 }
2836
2837 return mv88e6xxx_software_reset(chip);
2838}
2839
Andrew Lunn23e8b472019-10-25 01:03:52 +02002840static void mv88e6xxx_teardown(struct dsa_switch *ds)
2841{
2842 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002843 dsa_devlink_resources_unregister(ds);
Andrew Lunnbfb25542020-09-18 21:11:07 +02002844 mv88e6xxx_teardown_devlink_regions(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002845}
2846
Vivien Didelotf81ec902016-05-09 13:22:58 -04002847static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002848{
Vivien Didelot04bed142016-08-31 18:06:13 -04002849 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002850 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002851 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002852 int i;
2853
Vivien Didelotfad09c72016-06-21 12:28:20 -04002854 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002855 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Russell King1fb74192020-10-29 16:09:03 +00002856 ds->configure_vlan_while_not_filtering = true;
Vivien Didelot552238b2016-05-09 13:22:49 -04002857
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002858 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002859
Andrew Lunnea890982019-01-09 00:24:03 +01002860 if (chip->info->ops->setup_errata) {
2861 err = chip->info->ops->setup_errata(chip);
2862 if (err)
2863 goto unlock;
2864 }
2865
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002866 /* Cache the cmode of each port. */
2867 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2868 if (chip->info->ops->port_get_cmode) {
2869 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2870 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002871 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002872
2873 chip->ports[i].cmode = cmode;
2874 }
2875 }
2876
Vivien Didelot97299342016-07-18 20:45:30 -04002877 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002878 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002879 if (dsa_is_unused_port(ds, i))
2880 continue;
2881
Hubert Feursteinc8574862019-07-31 10:23:48 +02002882 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002883 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002884 dev_err(chip->dev, "port %d is invalid\n", i);
2885 err = -EINVAL;
2886 goto unlock;
2887 }
2888
Vivien Didelot97299342016-07-18 20:45:30 -04002889 err = mv88e6xxx_setup_port(chip, i);
2890 if (err)
2891 goto unlock;
2892 }
2893
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002894 err = mv88e6xxx_irl_setup(chip);
2895 if (err)
2896 goto unlock;
2897
Vivien Didelot04a69a12017-10-13 14:18:05 -04002898 err = mv88e6xxx_mac_setup(chip);
2899 if (err)
2900 goto unlock;
2901
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002902 err = mv88e6xxx_phy_setup(chip);
2903 if (err)
2904 goto unlock;
2905
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002906 err = mv88e6xxx_vtu_setup(chip);
2907 if (err)
2908 goto unlock;
2909
Vivien Didelot81228992017-03-30 17:37:08 -04002910 err = mv88e6xxx_pvt_setup(chip);
2911 if (err)
2912 goto unlock;
2913
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002914 err = mv88e6xxx_atu_setup(chip);
2915 if (err)
2916 goto unlock;
2917
Andrew Lunn87fa8862017-11-09 22:29:56 +01002918 err = mv88e6xxx_broadcast_setup(chip, 0);
2919 if (err)
2920 goto unlock;
2921
Vivien Didelot9e907d72017-07-17 13:03:43 -04002922 err = mv88e6xxx_pot_setup(chip);
2923 if (err)
2924 goto unlock;
2925
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002926 err = mv88e6xxx_rmu_setup(chip);
2927 if (err)
2928 goto unlock;
2929
Vivien Didelot51c901a2017-07-17 13:03:41 -04002930 err = mv88e6xxx_rsvd2cpu_setup(chip);
2931 if (err)
2932 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002933
Vivien Didelotb28f8722018-04-26 21:56:44 -04002934 err = mv88e6xxx_trunk_setup(chip);
2935 if (err)
2936 goto unlock;
2937
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002938 err = mv88e6xxx_devmap_setup(chip);
2939 if (err)
2940 goto unlock;
2941
Vivien Didelot93e18d62018-05-11 17:16:35 -04002942 err = mv88e6xxx_pri_setup(chip);
2943 if (err)
2944 goto unlock;
2945
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002946 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002947 if (chip->info->ptp_support) {
2948 err = mv88e6xxx_ptp_setup(chip);
2949 if (err)
2950 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002951
2952 err = mv88e6xxx_hwtstamp_setup(chip);
2953 if (err)
2954 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002955 }
2956
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002957 err = mv88e6xxx_stats_setup(chip);
2958 if (err)
2959 goto unlock;
2960
Vivien Didelot6b17e862015-08-13 12:52:18 -04002961unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002962 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002963
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002964 if (err)
2965 return err;
2966
2967 /* Have to be called without holding the register lock, since
2968 * they take the devlink lock, and we later take the locks in
2969 * the reverse order when getting/setting parameters or
2970 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02002971 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002972 err = mv88e6xxx_setup_devlink_resources(ds);
2973 if (err)
2974 return err;
2975
2976 err = mv88e6xxx_setup_devlink_params(ds);
2977 if (err)
Andrew Lunnbfb25542020-09-18 21:11:07 +02002978 goto out_resources;
2979
2980 err = mv88e6xxx_setup_devlink_regions(ds);
2981 if (err)
2982 goto out_params;
2983
2984 return 0;
2985
2986out_params:
2987 mv88e6xxx_teardown_devlink_params(ds);
2988out_resources:
2989 dsa_devlink_resources_unregister(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002990
2991 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002992}
2993
Vivien Didelote57e5e72016-08-15 17:19:00 -04002994static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002995{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002996 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2997 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002998 u16 val;
2999 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003000
Andrew Lunnee26a222017-01-24 14:53:48 +01003001 if (!chip->info->ops->phy_read)
3002 return -EOPNOTSUPP;
3003
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003004 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003005 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003006 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003007
Andrew Lunnda9f3302017-02-01 03:40:05 +01003008 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003009 /* Some internal PHYs don't have a model number. */
3010 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3011 /* Then there is the 6165 family. It gets is
3012 * PHYs correct. But it can also have two
3013 * SERDES interfaces in the PHY address
3014 * space. And these don't have a model
3015 * number. But they are not PHYs, so we don't
3016 * want to give them something a PHY driver
3017 * will recognise.
3018 *
3019 * Use the mv88e6390 family model number
3020 * instead, for anything which really could be
3021 * a PHY,
3022 */
3023 if (!(val & 0x3f0))
3024 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003025 }
3026
Vivien Didelote57e5e72016-08-15 17:19:00 -04003027 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003028}
3029
Vivien Didelote57e5e72016-08-15 17:19:00 -04003030static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003031{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003032 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3033 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003034 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003035
Andrew Lunnee26a222017-01-24 14:53:48 +01003036 if (!chip->info->ops->phy_write)
3037 return -EOPNOTSUPP;
3038
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003039 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003040 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003041 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003042
3043 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003044}
3045
Vivien Didelotfad09c72016-06-21 12:28:20 -04003046static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003047 struct device_node *np,
3048 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003049{
3050 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003051 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003052 struct mii_bus *bus;
3053 int err;
3054
Andrew Lunn2510bab2018-02-22 01:51:49 +01003055 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003056 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003057 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003058 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003059
3060 if (err)
3061 return err;
3062 }
3063
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003064 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003065 if (!bus)
3066 return -ENOMEM;
3067
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003068 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003069 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003070 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003071 INIT_LIST_HEAD(&mdio_bus->list);
3072 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003073
Andrew Lunnb516d452016-06-04 21:17:06 +02003074 if (np) {
3075 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003076 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003077 } else {
3078 bus->name = "mv88e6xxx SMI";
3079 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3080 }
3081
3082 bus->read = mv88e6xxx_mdio_read;
3083 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003084 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003085
Andrew Lunn6f882842018-03-17 20:32:05 +01003086 if (!external) {
3087 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3088 if (err)
3089 return err;
3090 }
3091
Florian Fainelli00e798c2018-05-15 16:56:19 -07003092 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003093 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003094 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003095 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003096 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003097 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003098
3099 if (external)
3100 list_add_tail(&mdio_bus->list, &chip->mdios);
3101 else
3102 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003103
3104 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003105}
3106
Andrew Lunn3126aee2017-12-07 01:05:57 +01003107static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3108
3109{
3110 struct mv88e6xxx_mdio_bus *mdio_bus;
3111 struct mii_bus *bus;
3112
3113 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3114 bus = mdio_bus->bus;
3115
Andrew Lunn6f882842018-03-17 20:32:05 +01003116 if (!mdio_bus->external)
3117 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3118
Andrew Lunn3126aee2017-12-07 01:05:57 +01003119 mdiobus_unregister(bus);
3120 }
3121}
3122
Andrew Lunna3c53be52017-01-24 14:53:50 +01003123static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3124 struct device_node *np)
3125{
Andrew Lunna3c53be52017-01-24 14:53:50 +01003126 struct device_node *child;
3127 int err;
3128
3129 /* Always register one mdio bus for the internal/default mdio
3130 * bus. This maybe represented in the device tree, but is
3131 * optional.
3132 */
3133 child = of_get_child_by_name(np, "mdio");
3134 err = mv88e6xxx_mdio_register(chip, child, false);
3135 if (err)
3136 return err;
3137
3138 /* Walk the device tree, and see if there are any other nodes
3139 * which say they are compatible with the external mdio
3140 * bus.
3141 */
3142 for_each_available_child_of_node(np, child) {
Andrew Lunnceb96fa2020-09-01 04:32:57 +02003143 if (of_device_is_compatible(
3144 child, "marvell,mv88e6xxx-mdio-external")) {
Andrew Lunna3c53be52017-01-24 14:53:50 +01003145 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003146 if (err) {
3147 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303148 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003149 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003150 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003151 }
3152 }
3153
3154 return 0;
3155}
3156
Vivien Didelot855b1932016-07-20 18:18:35 -04003157static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3158{
Vivien Didelot04bed142016-08-31 18:06:13 -04003159 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003160
3161 return chip->eeprom_len;
3162}
3163
Vivien Didelot855b1932016-07-20 18:18:35 -04003164static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3165 struct ethtool_eeprom *eeprom, u8 *data)
3166{
Vivien Didelot04bed142016-08-31 18:06:13 -04003167 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003168 int err;
3169
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003170 if (!chip->info->ops->get_eeprom)
3171 return -EOPNOTSUPP;
3172
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003173 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003174 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003175 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003176
3177 if (err)
3178 return err;
3179
3180 eeprom->magic = 0xc3ec4951;
3181
3182 return 0;
3183}
3184
Vivien Didelot855b1932016-07-20 18:18:35 -04003185static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3186 struct ethtool_eeprom *eeprom, u8 *data)
3187{
Vivien Didelot04bed142016-08-31 18:06:13 -04003188 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003189 int err;
3190
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003191 if (!chip->info->ops->set_eeprom)
3192 return -EOPNOTSUPP;
3193
Vivien Didelot855b1932016-07-20 18:18:35 -04003194 if (eeprom->magic != 0xc3ec4951)
3195 return -EINVAL;
3196
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003197 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003198 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003199 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003200
3201 return err;
3202}
3203
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003204static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003205 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003206 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3207 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003208 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003209 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003210 .phy_read = mv88e6185_phy_ppu_read,
3211 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003212 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003213 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003214 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003215 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003216 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003217 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003218 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003219 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003220 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003221 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003222 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003223 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003224 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003225 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003226 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003227 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3228 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003229 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003230 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3231 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003232 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003233 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003234 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003235 .ppu_enable = mv88e6185_g1_ppu_enable,
3236 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003237 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003238 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003239 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003240 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003241 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003242 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003243};
3244
3245static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003246 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003247 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3248 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003249 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003250 .phy_read = mv88e6185_phy_ppu_read,
3251 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003252 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003253 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003254 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003255 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003256 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003257 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003258 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003259 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003260 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003261 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003262 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3263 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003264 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003265 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003266 .serdes_power = mv88e6185_serdes_power,
3267 .serdes_get_lane = mv88e6185_serdes_get_lane,
3268 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003269 .ppu_enable = mv88e6185_g1_ppu_enable,
3270 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003271 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003272 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003273 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003274 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003275 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003276};
3277
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003278static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003279 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003280 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3281 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003282 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003283 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3284 .phy_read = mv88e6xxx_g2_smi_phy_read,
3285 .phy_write = mv88e6xxx_g2_smi_phy_write,
3286 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003287 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003288 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003289 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003290 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003291 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003292 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003293 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003294 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003295 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003296 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003297 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003298 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003299 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003300 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003301 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3302 .stats_get_strings = mv88e6095_stats_get_strings,
3303 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003304 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3305 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003306 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003307 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003308 .serdes_power = mv88e6185_serdes_power,
3309 .serdes_get_lane = mv88e6185_serdes_get_lane,
3310 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003311 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003312 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003313 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003314 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003315 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003316 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003317 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003318};
3319
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003320static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003321 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003322 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3323 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003324 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003325 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003326 .phy_read = mv88e6xxx_g2_smi_phy_read,
3327 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003328 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003329 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003330 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003331 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003332 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003333 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003334 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003335 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003336 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003337 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003338 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003339 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3340 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003341 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003342 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3343 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003344 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003345 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003346 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003347 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003348 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3349 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003350 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003351 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003352 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003353 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003354};
3355
3356static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003357 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003358 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3359 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003360 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003361 .phy_read = mv88e6185_phy_ppu_read,
3362 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003363 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003364 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003365 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003366 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003367 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003368 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003369 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003370 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003371 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003372 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003373 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003374 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003375 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003376 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003377 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003378 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003379 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3380 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003381 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003382 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3383 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003384 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003385 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003386 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003387 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003388 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003389 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003390 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003391 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003392 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003393};
3394
Vivien Didelot990e27b2017-03-28 13:50:32 -04003395static const struct mv88e6xxx_ops mv88e6141_ops = {
3396 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003397 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3398 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003399 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003400 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3401 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3402 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3403 .phy_read = mv88e6xxx_g2_smi_phy_read,
3404 .phy_write = mv88e6xxx_g2_smi_phy_write,
3405 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003406 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003407 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003408 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003409 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003410 .port_tag_remap = mv88e6095_port_tag_remap,
3411 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3412 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3413 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003414 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003415 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003416 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003417 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3418 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003419 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003420 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003421 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003422 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003423 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003424 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3425 .stats_get_strings = mv88e6320_stats_get_strings,
3426 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003427 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3428 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003429 .watchdog_ops = &mv88e6390_watchdog_ops,
3430 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003431 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003432 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003433 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003434 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003435 .serdes_power = mv88e6390_serdes_power,
3436 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003437 /* Check status register pause & lpa register */
3438 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3439 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3440 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3441 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003442 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003443 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003444 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003445 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003446 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003447};
3448
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003449static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003450 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003451 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3452 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003453 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003454 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003455 .phy_read = mv88e6xxx_g2_smi_phy_read,
3456 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003457 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003458 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003459 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003460 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003461 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003462 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003463 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003464 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003465 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003466 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003467 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003468 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003469 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003470 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003471 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003472 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003473 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3474 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003475 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003476 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3477 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003478 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003479 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003480 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003481 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003482 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3483 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003484 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003485 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003486 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003487 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003488 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003489};
3490
3491static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003492 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003493 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3494 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003495 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003496 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003497 .phy_read = mv88e6165_phy_read,
3498 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003499 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003500 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003501 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003502 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003503 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003504 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003505 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003506 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003507 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003508 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3509 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003510 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003511 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3512 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003513 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003514 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003515 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003516 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003517 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3518 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003519 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003520 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003521 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003522 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003523 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003524};
3525
3526static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003527 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003528 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3529 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003530 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003531 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003532 .phy_read = mv88e6xxx_g2_smi_phy_read,
3533 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003534 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003535 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003536 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003537 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003538 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003539 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003540 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003541 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003542 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003543 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003544 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003545 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003546 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003547 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003548 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003549 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003550 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003551 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3552 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003553 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003554 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3555 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003556 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003557 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003558 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003559 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003560 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3561 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003562 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003563 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003564 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003565};
3566
3567static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003568 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003569 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3570 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003571 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003572 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3573 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003574 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003575 .phy_read = mv88e6xxx_g2_smi_phy_read,
3576 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003577 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003578 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003579 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003580 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003581 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003582 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003583 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003584 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003585 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003586 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003587 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003588 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003589 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003590 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003591 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003592 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003593 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003594 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003595 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3596 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003597 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003598 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3599 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003600 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003601 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003602 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003603 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003604 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003605 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3606 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003607 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003608 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003609 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003610 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3611 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3612 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3613 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003614 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003615 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3616 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003617 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003618 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003619};
3620
3621static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003622 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003623 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3624 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003625 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003626 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003627 .phy_read = mv88e6xxx_g2_smi_phy_read,
3628 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003629 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003630 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003631 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003632 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003633 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003634 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003635 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003636 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003637 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003638 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003639 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003640 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003641 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003642 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003643 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003644 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003645 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003646 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3647 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003648 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003649 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3650 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003651 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003652 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003653 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003654 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003655 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3656 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003657 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003658 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003659 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003660};
3661
3662static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003663 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003664 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3665 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003666 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003667 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3668 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003669 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003670 .phy_read = mv88e6xxx_g2_smi_phy_read,
3671 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003672 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003673 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003674 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003675 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003676 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003677 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003678 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003679 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003680 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003681 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003682 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003683 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003684 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003685 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003686 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003687 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003688 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003689 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003690 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3691 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003692 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003693 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3694 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003695 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003696 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003697 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003698 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003699 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003700 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3701 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003702 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003703 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003704 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003705 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3706 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3707 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3708 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003709 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003710 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003711 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003712 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003713 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3714 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003715 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003716 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003717};
3718
3719static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003720 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003721 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3722 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003723 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003724 .phy_read = mv88e6185_phy_ppu_read,
3725 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003726 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003727 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003728 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003729 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003730 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003731 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003732 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003733 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003734 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003735 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003736 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003737 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003738 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3739 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003740 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003741 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3742 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003743 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003744 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003745 .serdes_power = mv88e6185_serdes_power,
3746 .serdes_get_lane = mv88e6185_serdes_get_lane,
3747 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelot02317e62018-05-09 11:38:49 -04003748 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003749 .ppu_enable = mv88e6185_g1_ppu_enable,
3750 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003751 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003752 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003753 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003754 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003755 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003756};
3757
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003758static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003759 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003760 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003761 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003762 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3763 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003764 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3765 .phy_read = mv88e6xxx_g2_smi_phy_read,
3766 .phy_write = mv88e6xxx_g2_smi_phy_write,
3767 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003768 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003769 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003770 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003771 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003772 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003773 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003774 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003775 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003776 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003777 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003778 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003779 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003780 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003781 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003782 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003783 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003784 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003785 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003786 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3787 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003788 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003789 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3790 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003791 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003792 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003793 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003794 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003795 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003796 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3797 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003798 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3799 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003800 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003801 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003802 /* Check status register pause & lpa register */
3803 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3804 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3805 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3806 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003807 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003808 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003809 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003810 .serdes_get_strings = mv88e6390_serdes_get_strings,
3811 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003812 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3813 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003814 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003815 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003816};
3817
3818static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003819 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003820 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003821 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003822 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3823 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003824 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3825 .phy_read = mv88e6xxx_g2_smi_phy_read,
3826 .phy_write = mv88e6xxx_g2_smi_phy_write,
3827 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003828 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003829 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003830 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003831 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003832 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003833 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003834 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003835 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003836 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003837 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003838 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003839 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003840 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003841 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003842 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003843 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003844 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003845 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003846 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3847 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003848 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003849 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3850 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003851 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003852 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003853 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003854 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003855 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003856 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3857 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003858 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3859 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003860 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003861 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003862 /* Check status register pause & lpa register */
3863 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3864 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3865 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3866 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003867 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003868 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003869 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003870 .serdes_get_strings = mv88e6390_serdes_get_strings,
3871 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003872 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3873 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003874 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003875 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003876};
3877
3878static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003879 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003880 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003881 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003882 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3883 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003884 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3885 .phy_read = mv88e6xxx_g2_smi_phy_read,
3886 .phy_write = mv88e6xxx_g2_smi_phy_write,
3887 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003888 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003889 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003890 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003891 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003892 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003893 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003894 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003895 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003896 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003897 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003898 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003899 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003900 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003901 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003902 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003903 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003904 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3905 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003906 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003907 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3908 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003909 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003910 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003911 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003912 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003913 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003914 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3915 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003916 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3917 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003918 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003919 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003920 /* Check status register pause & lpa register */
3921 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3922 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3923 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3924 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003925 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003926 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003927 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003928 .serdes_get_strings = mv88e6390_serdes_get_strings,
3929 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003930 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3931 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003932 .avb_ops = &mv88e6390_avb_ops,
3933 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003934 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003935};
3936
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003937static const struct mv88e6xxx_ops mv88e6240_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,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003954 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003955 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003956 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003957 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003958 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003959 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003960 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003961 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003962 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003963 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003964 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003965 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3966 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003967 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003968 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3969 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003970 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003971 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003972 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003973 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003974 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003975 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3976 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003977 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003978 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003979 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003980 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3981 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3982 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3983 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003984 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003985 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003986 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003987 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003988 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3989 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003990 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003991 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003992 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003993 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003994};
3995
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003996static const struct mv88e6xxx_ops mv88e6250_ops = {
3997 /* MV88E6XXX_FAMILY_6250 */
3998 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3999 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4000 .irl_init_all = mv88e6352_g2_irl_init_all,
4001 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4002 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4003 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4004 .phy_read = mv88e6xxx_g2_smi_phy_read,
4005 .phy_write = mv88e6xxx_g2_smi_phy_write,
4006 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004007 .port_sync_link = mv88e6xxx_port_sync_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004008 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004009 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004010 .port_tag_remap = mv88e6095_port_tag_remap,
4011 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4012 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4013 .port_set_ether_type = mv88e6351_port_set_ether_type,
4014 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4015 .port_pause_limit = mv88e6097_port_pause_limit,
4016 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004017 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4018 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4019 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4020 .stats_get_strings = mv88e6250_stats_get_strings,
4021 .stats_get_stats = mv88e6250_stats_get_stats,
4022 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4023 .set_egress_port = mv88e6095_g1_set_egress_port,
4024 .watchdog_ops = &mv88e6250_watchdog_ops,
4025 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4026 .pot_clear = mv88e6xxx_g2_pot_clear,
4027 .reset = mv88e6250_g1_reset,
4028 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4029 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004030 .avb_ops = &mv88e6352_avb_ops,
4031 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004032 .phylink_validate = mv88e6065_phylink_validate,
4033};
4034
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004035static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004036 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004037 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004038 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004039 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4040 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004041 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4042 .phy_read = mv88e6xxx_g2_smi_phy_read,
4043 .phy_write = mv88e6xxx_g2_smi_phy_write,
4044 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004045 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004046 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004047 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004048 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004049 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004050 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004051 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004052 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004053 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004054 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004055 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004056 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004057 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004058 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004059 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004060 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004061 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004062 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4063 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004064 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004065 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4066 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004067 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004068 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004069 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004070 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004071 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004072 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4073 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004074 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4075 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004076 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004077 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004078 /* Check status register pause & lpa register */
4079 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4080 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4081 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4082 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004083 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004084 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004085 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004086 .serdes_get_strings = mv88e6390_serdes_get_strings,
4087 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004088 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4089 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004090 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004091 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004092 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004093 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004094};
4095
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004096static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004097 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004098 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4099 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004100 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004101 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4102 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004103 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004104 .phy_read = mv88e6xxx_g2_smi_phy_read,
4105 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004106 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004107 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004108 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004109 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004110 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004111 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004112 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004113 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004114 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004115 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004116 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004117 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004118 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004119 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004120 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004121 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004122 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4123 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004124 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004125 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4126 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004127 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004128 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004129 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004130 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004131 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004132 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004133 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004134 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004135 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004136 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004137};
4138
4139static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004140 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004141 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4142 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004143 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004144 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4145 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004146 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004147 .phy_read = mv88e6xxx_g2_smi_phy_read,
4148 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004149 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004150 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004151 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004152 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004153 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004154 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004155 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004156 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004157 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004158 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004159 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004160 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004161 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004162 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004163 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004164 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004165 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4166 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004167 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004168 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4169 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004170 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004171 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004172 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004173 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004174 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004175 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004176 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004177 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004178};
4179
Vivien Didelot16e329a2017-03-28 13:50:33 -04004180static const struct mv88e6xxx_ops mv88e6341_ops = {
4181 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004182 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4183 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004184 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004185 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4186 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4187 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4188 .phy_read = mv88e6xxx_g2_smi_phy_read,
4189 .phy_write = mv88e6xxx_g2_smi_phy_write,
4190 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004191 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004192 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004193 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004194 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004195 .port_tag_remap = mv88e6095_port_tag_remap,
4196 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4197 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4198 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004199 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004200 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004201 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004202 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4203 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004204 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004205 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004206 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004207 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004208 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004209 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4210 .stats_get_strings = mv88e6320_stats_get_strings,
4211 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004212 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4213 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004214 .watchdog_ops = &mv88e6390_watchdog_ops,
4215 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004216 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004217 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004218 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004219 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004220 .serdes_power = mv88e6390_serdes_power,
4221 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004222 /* Check status register pause & lpa register */
4223 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4224 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4225 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4226 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004227 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004228 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004229 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004230 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004231 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004232 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004233 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004234};
4235
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004236static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004237 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004238 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4239 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004240 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004241 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004242 .phy_read = mv88e6xxx_g2_smi_phy_read,
4243 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004244 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004245 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004246 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004247 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004248 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004249 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004250 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004251 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004252 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004253 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004254 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004255 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004256 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004257 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004258 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004259 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004260 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004261 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4262 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004263 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004264 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4265 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004266 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004267 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004268 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004269 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004270 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4271 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004272 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004273 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004274 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004275};
4276
4277static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004278 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004279 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4280 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004281 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004282 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004283 .phy_read = mv88e6xxx_g2_smi_phy_read,
4284 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004285 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004286 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004287 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004288 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004289 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004290 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004291 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004292 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004293 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004294 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004295 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004296 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004297 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004298 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004299 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004300 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004301 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004302 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4303 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004304 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004305 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4306 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004307 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004308 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004309 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004310 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004311 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4312 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004313 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004314 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004315 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004316 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004317 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004318};
4319
4320static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004321 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004322 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4323 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004324 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004325 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4326 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004327 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004328 .phy_read = mv88e6xxx_g2_smi_phy_read,
4329 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004330 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004331 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004332 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004333 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004334 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004335 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004336 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004337 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004338 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004339 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004340 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004341 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004342 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004343 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004344 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004345 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004346 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004347 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004348 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4349 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004350 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004351 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4352 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004353 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004354 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004355 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004356 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004357 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004358 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4359 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004360 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004361 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004362 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004363 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4364 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4365 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4366 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004367 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004368 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004369 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004370 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004371 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004372 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004373 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004374 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4375 .serdes_get_strings = mv88e6352_serdes_get_strings,
4376 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004377 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4378 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004379 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004380};
4381
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004382static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004383 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004384 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004385 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004386 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4387 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004388 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4389 .phy_read = mv88e6xxx_g2_smi_phy_read,
4390 .phy_write = mv88e6xxx_g2_smi_phy_write,
4391 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004392 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004393 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004394 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004395 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004396 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004397 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004398 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004399 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004400 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004401 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004402 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004403 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004404 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004405 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004406 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004407 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004408 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004409 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004410 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004411 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4412 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004413 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004414 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4415 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004416 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004417 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004418 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004419 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004420 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004421 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4422 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004423 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4424 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004425 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004426 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004427 /* Check status register pause & lpa register */
4428 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4429 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4430 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4431 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004432 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004433 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004434 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004435 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004436 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004437 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004438 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4439 .serdes_get_strings = mv88e6390_serdes_get_strings,
4440 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004441 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4442 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004443 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004444};
4445
4446static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004447 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004448 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004449 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004450 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4451 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004452 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4453 .phy_read = mv88e6xxx_g2_smi_phy_read,
4454 .phy_write = mv88e6xxx_g2_smi_phy_write,
4455 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004456 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004457 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004458 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004459 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004460 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004461 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004462 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004463 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004464 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004465 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004466 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004467 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004468 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004469 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004470 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004471 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004472 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004473 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004474 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004475 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4476 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004477 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004478 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4479 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004480 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004481 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004482 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004483 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004484 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004485 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4486 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004487 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4488 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004489 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004490 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004491 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4492 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4493 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4494 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004495 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004496 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004497 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004498 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4499 .serdes_get_strings = mv88e6390_serdes_get_strings,
4500 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004501 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4502 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004503 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004504 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004505 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004506 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004507};
4508
Vivien Didelotf81ec902016-05-09 13:22:58 -04004509static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4510 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004511 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004512 .family = MV88E6XXX_FAMILY_6097,
4513 .name = "Marvell 88E6085",
4514 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004515 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004516 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004517 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004518 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004519 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004520 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004521 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004522 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004523 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004524 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004525 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004526 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004527 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004528 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004529 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004530 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004531 },
4532
4533 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004534 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004535 .family = MV88E6XXX_FAMILY_6095,
4536 .name = "Marvell 88E6095/88E6095F",
4537 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004538 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004539 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004540 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004541 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004542 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004543 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004544 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004545 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004546 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004547 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004548 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004549 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004550 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004551 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004552 },
4553
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004554 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004555 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004556 .family = MV88E6XXX_FAMILY_6097,
4557 .name = "Marvell 88E6097/88E6097F",
4558 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004559 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004560 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004561 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004562 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004563 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004564 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004565 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004566 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004567 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004568 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004569 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004570 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004571 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004572 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004573 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004574 .ops = &mv88e6097_ops,
4575 },
4576
Vivien Didelotf81ec902016-05-09 13:22:58 -04004577 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004578 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004579 .family = MV88E6XXX_FAMILY_6165,
4580 .name = "Marvell 88E6123",
4581 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004582 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004583 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004584 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004585 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004586 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004587 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004588 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004589 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004590 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004591 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004592 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004593 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004594 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004595 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004596 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004597 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004598 },
4599
4600 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004601 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004602 .family = MV88E6XXX_FAMILY_6185,
4603 .name = "Marvell 88E6131",
4604 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004605 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004606 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004607 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004608 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004609 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004610 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004611 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004612 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004613 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004614 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004615 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004616 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004617 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004618 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004619 },
4620
Vivien Didelot990e27b2017-03-28 13:50:32 -04004621 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004622 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004623 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004624 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004625 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004626 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004627 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004628 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004629 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004630 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004631 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004632 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004633 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004634 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004635 .age_time_coeff = 3750,
4636 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004637 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004638 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004639 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004640 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004641 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004642 .ops = &mv88e6141_ops,
4643 },
4644
Vivien Didelotf81ec902016-05-09 13:22:58 -04004645 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004646 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004647 .family = MV88E6XXX_FAMILY_6165,
4648 .name = "Marvell 88E6161",
4649 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004650 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004651 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004652 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004653 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004654 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004655 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004656 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004657 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004658 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004659 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004660 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004661 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004662 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004663 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004664 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004665 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004666 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004667 },
4668
4669 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004670 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004671 .family = MV88E6XXX_FAMILY_6165,
4672 .name = "Marvell 88E6165",
4673 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004674 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004675 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004676 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004677 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004678 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004679 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004680 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004681 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004682 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004683 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004684 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004685 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004686 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004687 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004688 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004689 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004690 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004691 },
4692
4693 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004694 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004695 .family = MV88E6XXX_FAMILY_6351,
4696 .name = "Marvell 88E6171",
4697 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004698 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004699 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004700 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004701 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004702 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004703 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004704 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004705 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004706 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004707 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004708 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004709 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004710 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004711 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004712 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004713 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004714 },
4715
4716 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004717 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004718 .family = MV88E6XXX_FAMILY_6352,
4719 .name = "Marvell 88E6172",
4720 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004721 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004722 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004723 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004724 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004725 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004726 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004727 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004728 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004729 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004730 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004731 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004732 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004733 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004734 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004735 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004736 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004737 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004738 },
4739
4740 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004741 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004742 .family = MV88E6XXX_FAMILY_6351,
4743 .name = "Marvell 88E6175",
4744 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004745 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004746 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004747 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004748 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004749 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004750 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004751 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004752 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004753 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004754 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004755 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004756 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004757 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004758 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004759 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004760 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004761 },
4762
4763 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004764 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004765 .family = MV88E6XXX_FAMILY_6352,
4766 .name = "Marvell 88E6176",
4767 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004768 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004769 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004770 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004771 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004772 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004773 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004774 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004775 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004776 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004777 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004778 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004779 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004780 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004781 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004782 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004783 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004784 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004785 },
4786
4787 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004788 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004789 .family = MV88E6XXX_FAMILY_6185,
4790 .name = "Marvell 88E6185",
4791 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004792 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004793 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004794 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004795 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004796 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004797 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004798 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004799 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004800 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004801 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004802 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004803 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004804 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004805 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004806 },
4807
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004808 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004809 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004810 .family = MV88E6XXX_FAMILY_6390,
4811 .name = "Marvell 88E6190",
4812 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004813 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004814 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004815 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004816 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004817 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004818 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004819 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004820 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004821 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004822 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004823 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004824 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004825 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004826 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004827 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004828 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004829 .ops = &mv88e6190_ops,
4830 },
4831
4832 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004833 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004834 .family = MV88E6XXX_FAMILY_6390,
4835 .name = "Marvell 88E6190X",
4836 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004837 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004838 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004839 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004840 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004841 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004842 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004843 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004844 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004845 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004846 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004847 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004848 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004849 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004850 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004851 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004852 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004853 .ops = &mv88e6190x_ops,
4854 },
4855
4856 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004857 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004858 .family = MV88E6XXX_FAMILY_6390,
4859 .name = "Marvell 88E6191",
4860 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004861 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004862 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004863 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004864 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004865 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004866 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004867 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004868 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004869 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004870 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004871 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004872 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004873 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004874 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004875 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004876 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004877 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004878 },
4879
Hubert Feurstein49022642019-07-31 10:23:46 +02004880 [MV88E6220] = {
4881 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4882 .family = MV88E6XXX_FAMILY_6250,
4883 .name = "Marvell 88E6220",
4884 .num_databases = 64,
4885
4886 /* Ports 2-4 are not routed to pins
4887 * => usable ports 0, 1, 5, 6
4888 */
4889 .num_ports = 7,
4890 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004891 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004892 .max_vid = 4095,
4893 .port_base_addr = 0x08,
4894 .phy_base_addr = 0x00,
4895 .global1_addr = 0x0f,
4896 .global2_addr = 0x07,
4897 .age_time_coeff = 15000,
4898 .g1_irqs = 9,
4899 .g2_irqs = 10,
4900 .atu_move_port_mask = 0xf,
4901 .dual_chip = true,
4902 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004903 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004904 .ops = &mv88e6250_ops,
4905 },
4906
Vivien Didelotf81ec902016-05-09 13:22:58 -04004907 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004908 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004909 .family = MV88E6XXX_FAMILY_6352,
4910 .name = "Marvell 88E6240",
4911 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004912 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004913 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004914 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004915 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004916 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004917 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004918 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004919 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004920 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004921 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004922 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004923 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004924 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004925 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004926 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004927 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004928 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004929 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004930 },
4931
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004932 [MV88E6250] = {
4933 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4934 .family = MV88E6XXX_FAMILY_6250,
4935 .name = "Marvell 88E6250",
4936 .num_databases = 64,
4937 .num_ports = 7,
4938 .num_internal_phys = 5,
4939 .max_vid = 4095,
4940 .port_base_addr = 0x08,
4941 .phy_base_addr = 0x00,
4942 .global1_addr = 0x0f,
4943 .global2_addr = 0x07,
4944 .age_time_coeff = 15000,
4945 .g1_irqs = 9,
4946 .g2_irqs = 10,
4947 .atu_move_port_mask = 0xf,
4948 .dual_chip = true,
4949 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004950 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004951 .ops = &mv88e6250_ops,
4952 },
4953
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004954 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004955 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004956 .family = MV88E6XXX_FAMILY_6390,
4957 .name = "Marvell 88E6290",
4958 .num_databases = 4096,
4959 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004960 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004961 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004962 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004963 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004964 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004965 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004966 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004967 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004968 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004969 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004970 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004971 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004972 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004973 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004974 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004975 .ops = &mv88e6290_ops,
4976 },
4977
Vivien Didelotf81ec902016-05-09 13:22:58 -04004978 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004979 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004980 .family = MV88E6XXX_FAMILY_6320,
4981 .name = "Marvell 88E6320",
4982 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004983 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004984 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004985 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004986 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004987 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004988 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004989 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004990 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004991 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004992 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004993 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004994 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004995 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004996 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004997 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004998 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004999 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005000 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005001 },
5002
5003 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005004 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005005 .family = MV88E6XXX_FAMILY_6320,
5006 .name = "Marvell 88E6321",
5007 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005008 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005009 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005010 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005011 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005012 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005013 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005014 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005015 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005016 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005017 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005018 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005019 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005020 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005021 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005022 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005023 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005024 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005025 },
5026
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005027 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005028 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005029 .family = MV88E6XXX_FAMILY_6341,
5030 .name = "Marvell 88E6341",
5031 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005032 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005033 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005034 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005035 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005036 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005037 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005038 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005039 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005040 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005041 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005042 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005043 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005044 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005045 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005046 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005047 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005048 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005049 .ops = &mv88e6341_ops,
5050 },
5051
Vivien Didelotf81ec902016-05-09 13:22:58 -04005052 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005053 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005054 .family = MV88E6XXX_FAMILY_6351,
5055 .name = "Marvell 88E6350",
5056 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005057 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005058 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005059 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005060 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005061 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005062 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005063 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005064 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005065 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005066 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005067 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005068 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005069 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005070 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005071 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005072 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005073 },
5074
5075 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005076 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005077 .family = MV88E6XXX_FAMILY_6351,
5078 .name = "Marvell 88E6351",
5079 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005080 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005081 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005082 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005083 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005084 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005085 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005086 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005087 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005088 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005089 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005090 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005091 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005092 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005093 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005094 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005095 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005096 },
5097
5098 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005099 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005100 .family = MV88E6XXX_FAMILY_6352,
5101 .name = "Marvell 88E6352",
5102 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005103 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005104 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005105 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005106 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005107 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005108 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005109 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005110 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005111 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005112 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005113 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005114 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005115 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005116 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005117 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005118 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005119 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005120 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005121 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005122 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005123 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005124 .family = MV88E6XXX_FAMILY_6390,
5125 .name = "Marvell 88E6390",
5126 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005127 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005128 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005129 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005130 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005131 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005132 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005133 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005134 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005135 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005136 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005137 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005138 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005139 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005140 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005141 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005142 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005143 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005144 .ops = &mv88e6390_ops,
5145 },
5146 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005147 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005148 .family = MV88E6XXX_FAMILY_6390,
5149 .name = "Marvell 88E6390X",
5150 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005151 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005152 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005153 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005154 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005155 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005156 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005157 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005158 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005159 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005160 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005161 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005162 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005163 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005164 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005165 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005166 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005167 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005168 .ops = &mv88e6390x_ops,
5169 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005170};
5171
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005172static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005173{
Vivien Didelota439c062016-04-17 13:23:58 -04005174 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005175
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005176 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5177 if (mv88e6xxx_table[i].prod_num == prod_num)
5178 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005179
Vivien Didelotb9b37712015-10-30 19:39:48 -04005180 return NULL;
5181}
5182
Vivien Didelotfad09c72016-06-21 12:28:20 -04005183static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005184{
5185 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005186 unsigned int prod_num, rev;
5187 u16 id;
5188 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005189
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005190 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005191 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005192 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005193 if (err)
5194 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005195
Vivien Didelot107fcc12017-06-12 12:37:36 -04005196 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5197 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005198
5199 info = mv88e6xxx_lookup_info(prod_num);
5200 if (!info)
5201 return -ENODEV;
5202
Vivien Didelotcaac8542016-06-20 13:14:09 -04005203 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005204 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005205
Vivien Didelotca070c12016-09-02 14:45:34 -04005206 err = mv88e6xxx_g2_require(chip);
5207 if (err)
5208 return err;
5209
Vivien Didelotfad09c72016-06-21 12:28:20 -04005210 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5211 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005212
5213 return 0;
5214}
5215
Vivien Didelotfad09c72016-06-21 12:28:20 -04005216static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005217{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005218 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005219
Vivien Didelotfad09c72016-06-21 12:28:20 -04005220 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5221 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005222 return NULL;
5223
Vivien Didelotfad09c72016-06-21 12:28:20 -04005224 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005225
Vivien Didelotfad09c72016-06-21 12:28:20 -04005226 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005227 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005228 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005229
Vivien Didelotfad09c72016-06-21 12:28:20 -04005230 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005231}
5232
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005233static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005234 int port,
5235 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005236{
Vivien Didelot04bed142016-08-31 18:06:13 -04005237 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005238
Andrew Lunn443d5a12016-12-03 04:35:18 +01005239 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005240}
5241
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005242static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005243 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005244{
5245 /* We don't need any dynamic resource from the kernel (yet),
5246 * so skip the prepare phase.
5247 */
5248
5249 return 0;
5250}
5251
5252static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005253 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005254{
Vivien Didelot04bed142016-08-31 18:06:13 -04005255 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005256
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005257 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005258 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005259 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005260 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5261 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005262 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005263}
5264
5265static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5266 const struct switchdev_obj_port_mdb *mdb)
5267{
Vivien Didelot04bed142016-08-31 18:06:13 -04005268 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005269 int err;
5270
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005271 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005272 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005273 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005274
5275 return err;
5276}
5277
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005278static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5279 struct dsa_mall_mirror_tc_entry *mirror,
5280 bool ingress)
5281{
5282 enum mv88e6xxx_egress_direction direction = ingress ?
5283 MV88E6XXX_EGRESS_DIR_INGRESS :
5284 MV88E6XXX_EGRESS_DIR_EGRESS;
5285 struct mv88e6xxx_chip *chip = ds->priv;
5286 bool other_mirrors = false;
5287 int i;
5288 int err;
5289
5290 if (!chip->info->ops->set_egress_port)
5291 return -EOPNOTSUPP;
5292
5293 mutex_lock(&chip->reg_lock);
5294 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5295 mirror->to_local_port) {
5296 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5297 other_mirrors |= ingress ?
5298 chip->ports[i].mirror_ingress :
5299 chip->ports[i].mirror_egress;
5300
5301 /* Can't change egress port when other mirror is active */
5302 if (other_mirrors) {
5303 err = -EBUSY;
5304 goto out;
5305 }
5306
5307 err = chip->info->ops->set_egress_port(chip,
5308 direction,
5309 mirror->to_local_port);
5310 if (err)
5311 goto out;
5312 }
5313
5314 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5315out:
5316 mutex_unlock(&chip->reg_lock);
5317
5318 return err;
5319}
5320
5321static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5322 struct dsa_mall_mirror_tc_entry *mirror)
5323{
5324 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5325 MV88E6XXX_EGRESS_DIR_INGRESS :
5326 MV88E6XXX_EGRESS_DIR_EGRESS;
5327 struct mv88e6xxx_chip *chip = ds->priv;
5328 bool other_mirrors = false;
5329 int i;
5330
5331 mutex_lock(&chip->reg_lock);
5332 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5333 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5334
5335 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5336 other_mirrors |= mirror->ingress ?
5337 chip->ports[i].mirror_ingress :
5338 chip->ports[i].mirror_egress;
5339
5340 /* Reset egress port when no other mirror is active */
5341 if (!other_mirrors) {
5342 if (chip->info->ops->set_egress_port(chip,
5343 direction,
5344 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005345 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005346 dev_err(ds->dev, "failed to set egress port\n");
5347 }
5348
5349 mutex_unlock(&chip->reg_lock);
5350}
5351
Russell King4f859012019-02-20 15:35:05 -08005352static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5353 bool unicast, bool multicast)
5354{
5355 struct mv88e6xxx_chip *chip = ds->priv;
5356 int err = -EOPNOTSUPP;
5357
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005358 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005359 if (chip->info->ops->port_set_egress_floods)
5360 err = chip->info->ops->port_set_egress_floods(chip, port,
5361 unicast,
5362 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005363 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005364
5365 return err;
5366}
5367
Florian Fainellia82f67a2017-01-08 14:52:08 -08005368static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005369 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005370 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005371 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005372 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005373 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005374 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005375 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005376 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5377 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005378 .get_strings = mv88e6xxx_get_strings,
5379 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5380 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005381 .port_enable = mv88e6xxx_port_enable,
5382 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02005383 .port_max_mtu = mv88e6xxx_get_max_mtu,
5384 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04005385 .get_mac_eee = mv88e6xxx_get_mac_eee,
5386 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005387 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005388 .get_eeprom = mv88e6xxx_get_eeprom,
5389 .set_eeprom = mv88e6xxx_set_eeprom,
5390 .get_regs_len = mv88e6xxx_get_regs_len,
5391 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005392 .get_rxnfc = mv88e6xxx_get_rxnfc,
5393 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005394 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005395 .port_bridge_join = mv88e6xxx_port_bridge_join,
5396 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005397 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005398 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005399 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005400 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5401 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5402 .port_vlan_add = mv88e6xxx_port_vlan_add,
5403 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005404 .port_fdb_add = mv88e6xxx_port_fdb_add,
5405 .port_fdb_del = mv88e6xxx_port_fdb_del,
5406 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005407 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5408 .port_mdb_add = mv88e6xxx_port_mdb_add,
5409 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005410 .port_mirror_add = mv88e6xxx_port_mirror_add,
5411 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005412 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5413 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005414 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5415 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5416 .port_txtstamp = mv88e6xxx_port_txtstamp,
5417 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5418 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005419 .devlink_param_get = mv88e6xxx_devlink_param_get,
5420 .devlink_param_set = mv88e6xxx_devlink_param_set,
Andrew Lunn93157302020-09-18 21:11:09 +02005421 .devlink_info_get = mv88e6xxx_devlink_info_get,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005422};
5423
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005424static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005425{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005426 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005427 struct dsa_switch *ds;
5428
Vivien Didelot7e99e342019-10-21 16:51:30 -04005429 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005430 if (!ds)
5431 return -ENOMEM;
5432
Vivien Didelot7e99e342019-10-21 16:51:30 -04005433 ds->dev = dev;
5434 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005435 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005436 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005437 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005438 ds->ageing_time_min = chip->info->age_time_coeff;
5439 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005440
5441 dev_set_drvdata(dev, ds);
5442
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005443 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005444}
5445
Vivien Didelotfad09c72016-06-21 12:28:20 -04005446static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005447{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005448 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005449}
5450
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005451static const void *pdata_device_get_match_data(struct device *dev)
5452{
5453 const struct of_device_id *matches = dev->driver->of_match_table;
5454 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5455
5456 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5457 matches++) {
5458 if (!strcmp(pdata->compatible, matches->compatible))
5459 return matches->data;
5460 }
5461 return NULL;
5462}
5463
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005464/* There is no suspend to RAM support at DSA level yet, the switch configuration
5465 * would be lost after a power cycle so prevent it to be suspended.
5466 */
5467static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5468{
5469 return -EOPNOTSUPP;
5470}
5471
5472static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5473{
5474 return 0;
5475}
5476
5477static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5478
Vivien Didelot57d32312016-06-20 13:13:58 -04005479static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005480{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005481 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005482 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005483 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005484 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005485 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005486 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005487 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005488
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005489 if (!np && !pdata)
5490 return -EINVAL;
5491
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005492 if (np)
5493 compat_info = of_device_get_match_data(dev);
5494
5495 if (pdata) {
5496 compat_info = pdata_device_get_match_data(dev);
5497
5498 if (!pdata->netdev)
5499 return -EINVAL;
5500
5501 for (port = 0; port < DSA_MAX_PORTS; port++) {
5502 if (!(pdata->enabled_ports & (1 << port)))
5503 continue;
5504 if (strcmp(pdata->cd.port_names[port], "cpu"))
5505 continue;
5506 pdata->cd.netdev[port] = &pdata->netdev->dev;
5507 break;
5508 }
5509 }
5510
Vivien Didelotcaac8542016-06-20 13:14:09 -04005511 if (!compat_info)
5512 return -EINVAL;
5513
Vivien Didelotfad09c72016-06-21 12:28:20 -04005514 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005515 if (!chip) {
5516 err = -ENOMEM;
5517 goto out;
5518 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005519
Vivien Didelotfad09c72016-06-21 12:28:20 -04005520 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005521
Vivien Didelotfad09c72016-06-21 12:28:20 -04005522 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005523 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005524 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005525
Andrew Lunnb4308f02016-11-21 23:26:55 +01005526 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005527 if (IS_ERR(chip->reset)) {
5528 err = PTR_ERR(chip->reset);
5529 goto out;
5530 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005531 if (chip->reset)
5532 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005533
Vivien Didelotfad09c72016-06-21 12:28:20 -04005534 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005535 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005536 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005537
Vivien Didelote57e5e72016-08-15 17:19:00 -04005538 mv88e6xxx_phy_init(chip);
5539
Andrew Lunn00baabe2018-05-19 22:31:35 +02005540 if (chip->info->ops->get_eeprom) {
5541 if (np)
5542 of_property_read_u32(np, "eeprom-length",
5543 &chip->eeprom_len);
5544 else
5545 chip->eeprom_len = pdata->eeprom_len;
5546 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005547
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005548 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005549 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005550 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005551 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005552 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005553
Andrew Lunna27415d2019-05-01 00:10:50 +02005554 if (np) {
5555 chip->irq = of_irq_get(np, 0);
5556 if (chip->irq == -EPROBE_DEFER) {
5557 err = chip->irq;
5558 goto out;
5559 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005560 }
5561
Andrew Lunna27415d2019-05-01 00:10:50 +02005562 if (pdata)
5563 chip->irq = pdata->irq;
5564
Andrew Lunn294d7112018-02-22 22:58:32 +01005565 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005566 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005567 * controllers
5568 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005569 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005570 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005571 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005572 else
5573 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005574 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005575
Andrew Lunn294d7112018-02-22 22:58:32 +01005576 if (err)
5577 goto out;
5578
5579 if (chip->info->g2_irqs > 0) {
5580 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005581 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005582 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005583 }
5584
Andrew Lunn294d7112018-02-22 22:58:32 +01005585 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5586 if (err)
5587 goto out_g2_irq;
5588
5589 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5590 if (err)
5591 goto out_g1_atu_prob_irq;
5592
Andrew Lunna3c53be52017-01-24 14:53:50 +01005593 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005594 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005595 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005596
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005597 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005598 if (err)
5599 goto out_mdio;
5600
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005601 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005602
5603out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005604 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005605out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005606 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005607out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005608 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005609out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005610 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005611 mv88e6xxx_g2_irq_free(chip);
5612out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005613 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005614 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005615 else
5616 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005617out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005618 if (pdata)
5619 dev_put(pdata->netdev);
5620
Andrew Lunndc30c352016-10-16 19:56:49 +02005621 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005622}
5623
5624static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5625{
5626 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005627 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005628
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005629 if (chip->info->ptp_support) {
5630 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005631 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005632 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005633
Andrew Lunn930188c2016-08-22 16:01:03 +02005634 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005635 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005636 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005637
Andrew Lunn76f38f12018-03-17 20:21:09 +01005638 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5639 mv88e6xxx_g1_atu_prob_irq_free(chip);
5640
5641 if (chip->info->g2_irqs > 0)
5642 mv88e6xxx_g2_irq_free(chip);
5643
Andrew Lunn76f38f12018-03-17 20:21:09 +01005644 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005645 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005646 else
5647 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005648}
5649
5650static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005651 {
5652 .compatible = "marvell,mv88e6085",
5653 .data = &mv88e6xxx_table[MV88E6085],
5654 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005655 {
5656 .compatible = "marvell,mv88e6190",
5657 .data = &mv88e6xxx_table[MV88E6190],
5658 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005659 {
5660 .compatible = "marvell,mv88e6250",
5661 .data = &mv88e6xxx_table[MV88E6250],
5662 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005663 { /* sentinel */ },
5664};
5665
5666MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5667
5668static struct mdio_driver mv88e6xxx_driver = {
5669 .probe = mv88e6xxx_probe,
5670 .remove = mv88e6xxx_remove,
5671 .mdiodrv.driver = {
5672 .name = "mv88e6085",
5673 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005674 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005675 },
5676};
5677
Andrew Lunn7324d502019-04-27 19:19:10 +02005678mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005679
5680MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5681MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5682MODULE_LICENSE("GPL");