blob: ed38b4431d7400b407b557dd3c452ca2186bfa38 [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;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100488 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000489 int err;
490
491 mv88e6xxx_reg_lock(chip);
492 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100493 if (lane >= 0 && chip->info->ops->serdes_pcs_get_state)
Russell Kinga5a68582020-03-14 10:15:43 +0000494 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;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100509 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000510
511 if (ops->serdes_pcs_config) {
512 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100513 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000514 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;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100526 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000527
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);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100533 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000534 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;
Pavana Sharma193c5b22021-03-17 14:46:40 +0100547 int lane;
Russell Kinga5a68582020-03-14 10:15:43 +0000548
549 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
550 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +0100551 if (lane >= 0)
Russell Kinga5a68582020-03-14 10:15:43 +0000552 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
Pavana Sharmade776d02021-03-17 14:46:42 +0100638static void mv88e6393x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
639 unsigned long *mask,
640 struct phylink_link_state *state)
641{
642 if (port == 0 || port == 9 || port == 10) {
643 phylink_set(mask, 10000baseT_Full);
644 phylink_set(mask, 10000baseKR_Full);
645 phylink_set(mask, 10000baseCR_Full);
646 phylink_set(mask, 10000baseSR_Full);
647 phylink_set(mask, 10000baseLR_Full);
648 phylink_set(mask, 10000baseLRM_Full);
649 phylink_set(mask, 10000baseER_Full);
650 phylink_set(mask, 5000baseT_Full);
651 phylink_set(mask, 2500baseX_Full);
652 phylink_set(mask, 2500baseT_Full);
653 }
654
655 phylink_set(mask, 1000baseT_Full);
656 phylink_set(mask, 1000baseX_Full);
657
658 mv88e6065_phylink_validate(chip, port, mask, state);
659}
660
Russell Kingc9a23562018-05-10 13:17:35 -0700661static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
662 unsigned long *supported,
663 struct phylink_link_state *state)
664{
Russell King6c422e32018-08-09 15:38:39 +0200665 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
666 struct mv88e6xxx_chip *chip = ds->priv;
667
668 /* Allow all the expected bits */
669 phylink_set(mask, Autoneg);
670 phylink_set(mask, Pause);
671 phylink_set_port_modes(mask);
672
673 if (chip->info->ops->phylink_validate)
674 chip->info->ops->phylink_validate(chip, port, mask, state);
675
676 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
677 bitmap_and(state->advertising, state->advertising, mask,
678 __ETHTOOL_LINK_MODE_MASK_NBITS);
679
680 /* We can only operate at 2500BaseX or 1000BaseX. If requested
681 * to advertise both, only report advertising at 2500BaseX.
682 */
683 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700684}
685
Russell Kingc9a23562018-05-10 13:17:35 -0700686static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
687 unsigned int mode,
688 const struct phylink_link_state *state)
689{
690 struct mv88e6xxx_chip *chip = ds->priv;
Russell Kingfad58192020-07-19 12:00:35 +0100691 struct mv88e6xxx_port *p;
Russell King64d47d52020-03-14 10:15:38 +0000692 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700693
Russell Kingfad58192020-07-19 12:00:35 +0100694 p = &chip->ports[port];
695
Russell King64d47d52020-03-14 10:15:38 +0000696 /* FIXME: is this the correct test? If we're in fixed mode on an
697 * internal port, why should we process this any different from
698 * PHY mode? On the other hand, the port may be automedia between
699 * an internal PHY and the serdes...
700 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200701 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700702 return;
703
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000704 mv88e6xxx_reg_lock(chip);
Russell Kingfad58192020-07-19 12:00:35 +0100705 /* In inband mode, the link may come up at any time while the link
706 * is not forced down. Force the link down while we reconfigure the
707 * interface mode.
Russell King64d47d52020-03-14 10:15:38 +0000708 */
Russell Kingfad58192020-07-19 12:00:35 +0100709 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
710 chip->info->ops->port_set_link)
711 chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
712
Russell King64d47d52020-03-14 10:15:38 +0000713 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000714 if (err && err != -EOPNOTSUPP)
715 goto err_unlock;
716
717 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
718 state->advertising);
719 /* FIXME: we should restart negotiation if something changed - which
720 * is something we get if we convert to using phylinks PCS operations.
721 */
722 if (err > 0)
723 err = 0;
724
Russell Kingfad58192020-07-19 12:00:35 +0100725 /* Undo the forced down state above after completing configuration
726 * irrespective of its state on entry, which allows the link to come up.
727 */
728 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
729 chip->info->ops->port_set_link)
730 chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
731
732 p->interface = state->interface;
733
Russell Kinga5a68582020-03-14 10:15:43 +0000734err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000735 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700736
737 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000738 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700739}
740
Russell Kingc9a23562018-05-10 13:17:35 -0700741static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
742 unsigned int mode,
743 phy_interface_t interface)
744{
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) ||
Chris Packham4efe76622020-11-24 17:34:37 +1300753 mode == MLO_AN_FIXED) && ops->port_sync_link)
754 err = ops->port_sync_link(chip, port, mode, false);
Russell King5d5b2312020-03-14 10:16:03 +0000755 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000756
Russell King5d5b2312020-03-14 10:16:03 +0000757 if (err)
758 dev_err(chip->dev,
759 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700760}
761
762static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
763 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000764 struct phy_device *phydev,
765 int speed, int duplex,
766 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700767{
Russell King30c4a5b2020-02-26 10:23:51 +0000768 struct mv88e6xxx_chip *chip = ds->priv;
769 const struct mv88e6xxx_ops *ops;
770 int err = 0;
771
772 ops = chip->info->ops;
773
Russell King5d5b2312020-03-14 10:16:03 +0000774 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200775 if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000776 /* FIXME: for an automedia port, should we force the link
777 * down here - what if the link comes up due to "other" media
778 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000779 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000780 * shared between internal PHY and Serdes.
781 */
Russell Kinga5a68582020-03-14 10:15:43 +0000782 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
783 duplex);
784 if (err)
785 goto error;
786
Russell Kingf365c6f2020-03-14 10:15:53 +0000787 if (ops->port_set_speed_duplex) {
788 err = ops->port_set_speed_duplex(chip, port,
789 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000790 if (err && err != -EOPNOTSUPP)
791 goto error;
792 }
793
Chris Packham4efe76622020-11-24 17:34:37 +1300794 if (ops->port_sync_link)
795 err = ops->port_sync_link(chip, port, mode, true);
Russell King30c4a5b2020-02-26 10:23:51 +0000796 }
Russell King5d5b2312020-03-14 10:16:03 +0000797error:
798 mv88e6xxx_reg_unlock(chip);
799
800 if (err && err != -EOPNOTSUPP)
801 dev_err(ds->dev,
802 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700803}
804
Andrew Lunna605a0f2016-11-21 23:26:58 +0100805static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000806{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100807 if (!chip->info->ops->stats_snapshot)
808 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000809
Andrew Lunna605a0f2016-11-21 23:26:58 +0100810 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000811}
812
Andrew Lunne413e7e2015-04-02 04:06:38 +0200813static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100814 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
815 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
816 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
817 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
818 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
819 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
820 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
821 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
822 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
823 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
824 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
825 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
826 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
827 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
828 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
829 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
830 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
831 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
832 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
833 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
834 { "single", 4, 0x14, STATS_TYPE_BANK0, },
835 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
836 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
837 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
838 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
839 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
840 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
841 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
842 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
843 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
844 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
845 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
846 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
847 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
848 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
849 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
850 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
851 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
852 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
853 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
854 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
855 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
856 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
857 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
858 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
859 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
860 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
861 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
862 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
863 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
864 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
865 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
866 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
867 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
868 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
869 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
870 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
871 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
872 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200873};
874
Vivien Didelotfad09c72016-06-21 12:28:20 -0400875static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100876 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100877 int port, u16 bank1_select,
878 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200879{
Andrew Lunn80c46272015-06-20 18:42:30 +0200880 u32 low;
881 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100882 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200883 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200884 u64 value;
885
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100886 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100887 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200888 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
889 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800890 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200891
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200892 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100893 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200894 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
895 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800896 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000897 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200898 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100899 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100900 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100901 reg = bank1_select;
Gustavo A. R. Silvadf561f662020-08-23 17:36:59 -0500902 fallthrough;
Andrew Lunndfafe442016-11-21 23:27:02 +0100903 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100904 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100905 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100906 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100907 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500908 break;
909 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800910 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200911 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100912 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200913 return value;
914}
915
Andrew Lunn436fe172018-03-01 02:02:29 +0100916static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
917 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100918{
919 struct mv88e6xxx_hw_stat *stat;
920 int i, j;
921
922 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
923 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100924 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100925 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
926 ETH_GSTRING_LEN);
927 j++;
928 }
929 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100930
931 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100932}
933
Andrew Lunn436fe172018-03-01 02:02:29 +0100934static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
935 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100936{
Andrew Lunn436fe172018-03-01 02:02:29 +0100937 return mv88e6xxx_stats_get_strings(chip, data,
938 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100939}
940
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000941static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
942 uint8_t *data)
943{
944 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
945}
946
Andrew Lunn436fe172018-03-01 02:02:29 +0100947static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
948 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100949{
Andrew Lunn436fe172018-03-01 02:02:29 +0100950 return mv88e6xxx_stats_get_strings(chip, data,
951 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100952}
953
Andrew Lunn65f60e42018-03-28 23:50:28 +0200954static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
955 "atu_member_violation",
956 "atu_miss_violation",
957 "atu_full_violation",
958 "vtu_member_violation",
959 "vtu_miss_violation",
960};
961
962static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
963{
964 unsigned int i;
965
966 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
967 strlcpy(data + i * ETH_GSTRING_LEN,
968 mv88e6xxx_atu_vtu_stats_strings[i],
969 ETH_GSTRING_LEN);
970}
971
Andrew Lunndfafe442016-11-21 23:27:02 +0100972static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700973 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100974{
Vivien Didelot04bed142016-08-31 18:06:13 -0400975 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100976 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100977
Florian Fainelli89f09042018-04-25 12:12:50 -0700978 if (stringset != ETH_SS_STATS)
979 return;
980
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000981 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100982
Andrew Lunndfafe442016-11-21 23:27:02 +0100983 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100984 count = chip->info->ops->stats_get_strings(chip, data);
985
986 if (chip->info->ops->serdes_get_strings) {
987 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200988 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100989 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100990
Andrew Lunn65f60e42018-03-28 23:50:28 +0200991 data += count * ETH_GSTRING_LEN;
992 mv88e6xxx_atu_vtu_get_strings(data);
993
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000994 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100995}
996
997static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
998 int types)
999{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001000 struct mv88e6xxx_hw_stat *stat;
1001 int i, j;
1002
1003 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1004 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +01001005 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +01001006 j++;
1007 }
1008 return j;
1009}
1010
Andrew Lunndfafe442016-11-21 23:27:02 +01001011static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1012{
1013 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1014 STATS_TYPE_PORT);
1015}
1016
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001017static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1018{
1019 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
1020}
1021
Andrew Lunndfafe442016-11-21 23:27:02 +01001022static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1023{
1024 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1025 STATS_TYPE_BANK1);
1026}
1027
Florian Fainelli89f09042018-04-25 12:12:50 -07001028static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001029{
1030 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001031 int serdes_count = 0;
1032 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001033
Florian Fainelli89f09042018-04-25 12:12:50 -07001034 if (sset != ETH_SS_STATS)
1035 return 0;
1036
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001037 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001038 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001039 count = chip->info->ops->stats_get_sset_count(chip);
1040 if (count < 0)
1041 goto out;
1042
1043 if (chip->info->ops->serdes_get_sset_count)
1044 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1045 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001046 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001047 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001048 goto out;
1049 }
1050 count += serdes_count;
1051 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1052
Andrew Lunn436fe172018-03-01 02:02:29 +01001053out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001054 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001055
Andrew Lunn436fe172018-03-01 02:02:29 +01001056 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001057}
1058
Andrew Lunn436fe172018-03-01 02:02:29 +01001059static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1060 uint64_t *data, int types,
1061 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001062{
1063 struct mv88e6xxx_hw_stat *stat;
1064 int i, j;
1065
1066 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1067 stat = &mv88e6xxx_hw_stats[i];
1068 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001069 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001070 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1071 bank1_select,
1072 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001073 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001074
Andrew Lunn052f9472016-11-21 23:27:03 +01001075 j++;
1076 }
1077 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001078 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001079}
1080
Andrew Lunn436fe172018-03-01 02:02:29 +01001081static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1082 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001083{
1084 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001085 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001086 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001087}
1088
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001089static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1090 uint64_t *data)
1091{
1092 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1093 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1094}
1095
Andrew Lunn436fe172018-03-01 02:02:29 +01001096static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1097 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001098{
1099 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001100 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001101 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1102 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001103}
1104
Andrew Lunn436fe172018-03-01 02:02:29 +01001105static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1106 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001107{
1108 return mv88e6xxx_stats_get_stats(chip, port, data,
1109 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001110 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1111 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001112}
1113
Andrew Lunn65f60e42018-03-28 23:50:28 +02001114static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1115 uint64_t *data)
1116{
1117 *data++ = chip->ports[port].atu_member_violation;
1118 *data++ = chip->ports[port].atu_miss_violation;
1119 *data++ = chip->ports[port].atu_full_violation;
1120 *data++ = chip->ports[port].vtu_member_violation;
1121 *data++ = chip->ports[port].vtu_miss_violation;
1122}
1123
Andrew Lunn052f9472016-11-21 23:27:03 +01001124static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1125 uint64_t *data)
1126{
Andrew Lunn436fe172018-03-01 02:02:29 +01001127 int count = 0;
1128
Andrew Lunn052f9472016-11-21 23:27:03 +01001129 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001130 count = chip->info->ops->stats_get_stats(chip, port, data);
1131
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001132 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001133 if (chip->info->ops->serdes_get_stats) {
1134 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001135 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001136 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001137 data += count;
1138 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001139 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001140}
1141
Vivien Didelotf81ec902016-05-09 13:22:58 -04001142static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1143 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001144{
Vivien Didelot04bed142016-08-31 18:06:13 -04001145 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001146 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001147
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001148 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001149
Andrew Lunna605a0f2016-11-21 23:26:58 +01001150 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001151 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001152
1153 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001154 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001155
1156 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001157
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001158}
Ben Hutchings98e67302011-11-25 14:36:19 +00001159
Vivien Didelotf81ec902016-05-09 13:22:58 -04001160static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001161{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001162 struct mv88e6xxx_chip *chip = ds->priv;
1163 int len;
1164
1165 len = 32 * sizeof(u16);
1166 if (chip->info->ops->serdes_get_regs_len)
1167 len += chip->info->ops->serdes_get_regs_len(chip, port);
1168
1169 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001170}
1171
Vivien Didelotf81ec902016-05-09 13:22:58 -04001172static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1173 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001174{
Vivien Didelot04bed142016-08-31 18:06:13 -04001175 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001176 int err;
1177 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001178 u16 *p = _p;
1179 int i;
1180
Vivien Didelota5f39322018-12-17 16:05:21 -05001181 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001182
1183 memset(p, 0xff, 32 * sizeof(u16));
1184
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001185 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001186
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001187 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001188
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001189 err = mv88e6xxx_port_read(chip, port, i, &reg);
1190 if (!err)
1191 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001192 }
Vivien Didelot23062512016-05-09 13:22:45 -04001193
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001194 if (chip->info->ops->serdes_get_regs)
1195 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1196
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001197 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001198}
1199
Vivien Didelot08f50062017-08-01 16:32:41 -04001200static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1201 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001202{
Vivien Didelot5480db62017-08-01 16:32:40 -04001203 /* Nothing to do on the port's MAC */
1204 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001205}
1206
Vivien Didelot08f50062017-08-01 16:32:41 -04001207static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1208 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001209{
Vivien Didelot5480db62017-08-01 16:32:40 -04001210 /* Nothing to do on the port's MAC */
1211 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001212}
1213
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001214/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001215static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001216{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001217 struct dsa_switch *ds = chip->ds;
1218 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001219 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001220 struct dsa_port *dp;
1221 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001222 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001223
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001224 list_for_each_entry(dp, &dst->ports, list) {
1225 if (dp->ds->index == dev && dp->index == port) {
1226 found = true;
1227 break;
1228 }
1229 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001230
Vivien Didelote5887a22017-03-30 17:37:11 -04001231 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001232 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001233 return 0;
1234
1235 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001236 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001237 return mv88e6xxx_port_mask(chip);
1238
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001239 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001240 pvlan = 0;
1241
1242 /* Frames from user ports can egress any local DSA links and CPU ports,
1243 * as well as any local member of their bridge group.
1244 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001245 list_for_each_entry(dp, &dst->ports, list)
1246 if (dp->ds == ds &&
1247 (dp->type == DSA_PORT_TYPE_CPU ||
1248 dp->type == DSA_PORT_TYPE_DSA ||
1249 (br && dp->bridge_dev == br)))
1250 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001251
1252 return pvlan;
1253}
1254
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001255static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001256{
1257 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001258
1259 /* prevent frames from going back out of the port they came in on */
1260 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001261
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001262 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001263}
1264
Vivien Didelotf81ec902016-05-09 13:22:58 -04001265static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1266 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001267{
Vivien Didelot04bed142016-08-31 18:06:13 -04001268 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001269 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001270
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001271 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001272 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001273 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001274
1275 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001276 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001277}
1278
Vivien Didelot93e18d62018-05-11 17:16:35 -04001279static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1280{
1281 int err;
1282
1283 if (chip->info->ops->ieee_pri_map) {
1284 err = chip->info->ops->ieee_pri_map(chip);
1285 if (err)
1286 return err;
1287 }
1288
1289 if (chip->info->ops->ip_pri_map) {
1290 err = chip->info->ops->ip_pri_map(chip);
1291 if (err)
1292 return err;
1293 }
1294
1295 return 0;
1296}
1297
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001298static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1299{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001300 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001301 int target, port;
1302 int err;
1303
1304 if (!chip->info->global2_addr)
1305 return 0;
1306
1307 /* Initialize the routing port to the 32 possible target devices */
1308 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001309 port = dsa_routing_port(ds, target);
1310 if (port == ds->num_ports)
1311 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001312
1313 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1314 if (err)
1315 return err;
1316 }
1317
Vivien Didelot02317e62018-05-09 11:38:49 -04001318 if (chip->info->ops->set_cascade_port) {
1319 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1320 err = chip->info->ops->set_cascade_port(chip, port);
1321 if (err)
1322 return err;
1323 }
1324
Vivien Didelot23c98912018-05-09 11:38:50 -04001325 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1326 if (err)
1327 return err;
1328
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001329 return 0;
1330}
1331
Vivien Didelotb28f8722018-04-26 21:56:44 -04001332static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1333{
1334 /* Clear all trunk masks and mapping */
1335 if (chip->info->global2_addr)
1336 return mv88e6xxx_g2_trunk_clear(chip);
1337
1338 return 0;
1339}
1340
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001341static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1342{
1343 if (chip->info->ops->rmu_disable)
1344 return chip->info->ops->rmu_disable(chip);
1345
1346 return 0;
1347}
1348
Vivien Didelot9e907d72017-07-17 13:03:43 -04001349static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1350{
1351 if (chip->info->ops->pot_clear)
1352 return chip->info->ops->pot_clear(chip);
1353
1354 return 0;
1355}
1356
Vivien Didelot51c901a2017-07-17 13:03:41 -04001357static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1358{
1359 if (chip->info->ops->mgmt_rsvd2cpu)
1360 return chip->info->ops->mgmt_rsvd2cpu(chip);
1361
1362 return 0;
1363}
1364
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001365static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1366{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001367 int err;
1368
Vivien Didelotdaefc942017-03-11 16:12:54 -05001369 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1370 if (err)
1371 return err;
1372
Rasmus Villemoes49506a92020-12-10 12:06:44 +01001373 /* The chips that have a "learn2all" bit in Global1, ATU
1374 * Control are precisely those whose port registers have a
1375 * Message Port bit in Port Control 1 and hence implement
1376 * ->port_setup_message_port.
1377 */
1378 if (chip->info->ops->port_setup_message_port) {
1379 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1380 if (err)
1381 return err;
1382 }
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001383
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001384 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1385}
1386
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001387static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1388{
1389 int port;
1390 int err;
1391
1392 if (!chip->info->ops->irl_init_all)
1393 return 0;
1394
1395 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1396 /* Disable ingress rate limiting by resetting all per port
1397 * ingress rate limit resources to their initial state.
1398 */
1399 err = chip->info->ops->irl_init_all(chip, port);
1400 if (err)
1401 return err;
1402 }
1403
1404 return 0;
1405}
1406
Vivien Didelot04a69a12017-10-13 14:18:05 -04001407static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1408{
1409 if (chip->info->ops->set_switch_mac) {
1410 u8 addr[ETH_ALEN];
1411
1412 eth_random_addr(addr);
1413
1414 return chip->info->ops->set_switch_mac(chip, addr);
1415 }
1416
1417 return 0;
1418}
1419
Vivien Didelot17a15942017-03-30 17:37:09 -04001420static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1421{
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001422 struct dsa_switch_tree *dst = chip->ds->dst;
1423 struct dsa_switch *ds;
1424 struct dsa_port *dp;
Vivien Didelot17a15942017-03-30 17:37:09 -04001425 u16 pvlan = 0;
1426
1427 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001428 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001429
1430 /* Skip the local source device, which uses in-chip port VLAN */
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001431 if (dev != chip->ds->index) {
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001432 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001433
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01001434 ds = dsa_switch_find(dst->index, dev);
1435 dp = ds ? dsa_to_port(ds, port) : NULL;
1436 if (dp && dp->lag_dev) {
1437 /* As the PVT is used to limit flooding of
1438 * FORWARD frames, which use the LAG ID as the
1439 * source port, we must translate dev/port to
1440 * the special "LAG device" in the PVT, using
1441 * the LAG ID as the port number.
1442 */
1443 dev = MV88E6XXX_G2_PVT_ADRR_DEV_TRUNK;
1444 port = dsa_lag_id(dst, dp->lag_dev);
1445 }
1446 }
1447
Vivien Didelot17a15942017-03-30 17:37:09 -04001448 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1449}
1450
Vivien Didelot81228992017-03-30 17:37:08 -04001451static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1452{
Vivien Didelot17a15942017-03-30 17:37:09 -04001453 int dev, port;
1454 int err;
1455
Vivien Didelot81228992017-03-30 17:37:08 -04001456 if (!mv88e6xxx_has_pvt(chip))
1457 return 0;
1458
1459 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1460 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1461 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001462 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1463 if (err)
1464 return err;
1465
1466 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1467 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1468 err = mv88e6xxx_pvt_map(chip, dev, port);
1469 if (err)
1470 return err;
1471 }
1472 }
1473
1474 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001475}
1476
Vivien Didelot749efcb2016-09-22 16:49:24 -04001477static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1478{
1479 struct mv88e6xxx_chip *chip = ds->priv;
1480 int err;
1481
Tobias Waldekranzffcec3f2021-03-18 20:25:34 +01001482 if (dsa_to_port(ds, port)->lag_dev)
1483 /* Hardware is incapable of fast-aging a LAG through a
1484 * regular ATU move operation. Until we have something
1485 * more fancy in place this is a no-op.
1486 */
1487 return;
1488
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001489 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001490 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001491 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001492
1493 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001494 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001495}
1496
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001497static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1498{
Tobias Waldekranze545f862020-11-10 19:57:20 +01001499 if (!mv88e6xxx_max_vid(chip))
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001500 return 0;
1501
1502 return mv88e6xxx_g1_vtu_flush(chip);
1503}
1504
Vivien Didelotf1394b782017-05-01 14:05:22 -04001505static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1506 struct mv88e6xxx_vtu_entry *entry)
1507{
1508 if (!chip->info->ops->vtu_getnext)
1509 return -EOPNOTSUPP;
1510
1511 return chip->info->ops->vtu_getnext(chip, entry);
1512}
1513
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001514static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1515 struct mv88e6xxx_vtu_entry *entry)
1516{
1517 if (!chip->info->ops->vtu_loadpurge)
1518 return -EOPNOTSUPP;
1519
1520 return chip->info->ops->vtu_loadpurge(chip, entry);
1521}
1522
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001523int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001524{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001525 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001526 int i, err;
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001527 u16 fid;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001528
1529 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1530
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001531 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001532 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001533 err = mv88e6xxx_port_get_fid(chip, i, &fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001534 if (err)
1535 return err;
1536
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001537 set_bit(fid, fid_bitmap);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001538 }
1539
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001540 /* Set every FID bit used by the VLAN entries */
Tobias Waldekranze545f862020-11-10 19:57:20 +01001541 vlan.vid = mv88e6xxx_max_vid(chip);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001542 vlan.valid = false;
1543
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001544 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001545 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001546 if (err)
1547 return err;
1548
1549 if (!vlan.valid)
1550 break;
1551
1552 set_bit(vlan.fid, fid_bitmap);
Tobias Waldekranze545f862020-11-10 19:57:20 +01001553 } while (vlan.vid < mv88e6xxx_max_vid(chip));
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001554
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001555 return 0;
1556}
1557
1558static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1559{
1560 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1561 int err;
1562
1563 err = mv88e6xxx_fid_map(chip, fid_bitmap);
1564 if (err)
1565 return err;
1566
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001567 /* The reset value 0x000 is used to indicate that multiple address
1568 * databases are not needed. Return the next positive available.
1569 */
1570 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001571 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001572 return -ENOSPC;
1573
1574 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001575 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001576}
1577
Vivien Didelotda9c3592016-02-12 12:09:40 -05001578static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001579 u16 vid)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001580{
Vivien Didelot04bed142016-08-31 18:06:13 -04001581 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001582 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001583 int i, err;
1584
Vladimir Oltean3e85f582021-01-09 02:01:47 +02001585 if (!vid)
1586 return -EOPNOTSUPP;
1587
Andrew Lunndb06ae412017-09-25 23:32:20 +02001588 /* DSA and CPU ports have to be members of multiple vlans */
1589 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1590 return 0;
1591
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001592 vlan.vid = vid - 1;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001593 vlan.valid = false;
1594
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001595 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1596 if (err)
1597 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001598
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001599 if (!vlan.valid)
1600 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001601
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001602 if (vlan.vid != vid)
1603 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001604
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001605 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
1606 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1607 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001608
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001609 if (!dsa_to_port(ds, i)->slave)
1610 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001611
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001612 if (vlan.member[i] ==
1613 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
1614 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001615
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001616 if (dsa_to_port(ds, i)->bridge_dev ==
1617 dsa_to_port(ds, port)->bridge_dev)
1618 break; /* same bridge, check next VLAN */
Vivien Didelotda9c3592016-02-12 12:09:40 -05001619
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001620 if (!dsa_to_port(ds, i)->bridge_dev)
1621 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001622
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001623 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1624 port, vlan.vid, i,
1625 netdev_name(dsa_to_port(ds, i)->bridge_dev));
1626 return -EOPNOTSUPP;
1627 }
Vivien Didelotda9c3592016-02-12 12:09:40 -05001628
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001629 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001630}
1631
Vivien Didelotf81ec902016-05-09 13:22:58 -04001632static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
Vladimir Oltean89153ed2021-02-13 22:43:19 +02001633 bool vlan_filtering,
1634 struct netlink_ext_ack *extack)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001635{
Vivien Didelot04bed142016-08-31 18:06:13 -04001636 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001637 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1638 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001639 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001640
Vladimir Olteanbae33f22021-01-09 02:01:50 +02001641 if (!mv88e6xxx_max_vid(chip))
1642 return -EOPNOTSUPP;
Vivien Didelot54d77b52016-05-09 13:22:47 -04001643
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001644 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001645 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001646 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001647
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001648 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001649}
1650
Vivien Didelot57d32312016-06-20 13:13:58 -04001651static int
1652mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001653 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001654{
Vivien Didelot04bed142016-08-31 18:06:13 -04001655 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001656 int err;
1657
Tobias Waldekranze545f862020-11-10 19:57:20 +01001658 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001659 return -EOPNOTSUPP;
1660
Vivien Didelotda9c3592016-02-12 12:09:40 -05001661 /* If the requested port doesn't belong to the same bridge as the VLAN
1662 * members, do not support it (yet) and fallback to software VLAN.
1663 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001664 mv88e6xxx_reg_lock(chip);
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001665 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001666 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001667
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001668 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001669}
1670
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001671static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1672 const unsigned char *addr, u16 vid,
1673 u8 state)
1674{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001675 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001676 struct mv88e6xxx_vtu_entry vlan;
1677 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001678 int err;
1679
1680 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001681 if (vid == 0) {
1682 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1683 if (err)
1684 return err;
1685 } else {
1686 vlan.vid = vid - 1;
1687 vlan.valid = false;
1688
1689 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1690 if (err)
1691 return err;
1692
1693 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1694 if (vlan.vid != vid || !vlan.valid)
1695 return -EOPNOTSUPP;
1696
1697 fid = vlan.fid;
1698 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001699
Vivien Didelotd8291a92019-09-07 16:00:47 -04001700 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001701 ether_addr_copy(entry.mac, addr);
1702 eth_addr_dec(entry.mac);
1703
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001704 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001705 if (err)
1706 return err;
1707
1708 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001709 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001710 memset(&entry, 0, sizeof(entry));
1711 ether_addr_copy(entry.mac, addr);
1712 }
1713
1714 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001715 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001716 entry.portvec &= ~BIT(port);
1717 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001718 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001719 } else {
DENG Qingfangf72f2fb2021-01-30 21:43:34 +08001720 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
1721 entry.portvec = BIT(port);
1722 else
1723 entry.portvec |= BIT(port);
1724
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001725 entry.state = state;
1726 }
1727
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001728 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001729}
1730
Vivien Didelotda7dc872019-09-07 16:00:49 -04001731static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1732 const struct mv88e6xxx_policy *policy)
1733{
1734 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1735 enum mv88e6xxx_policy_action action = policy->action;
1736 const u8 *addr = policy->addr;
1737 u16 vid = policy->vid;
1738 u8 state;
1739 int err;
1740 int id;
1741
1742 if (!chip->info->ops->port_set_policy)
1743 return -EOPNOTSUPP;
1744
1745 switch (mapping) {
1746 case MV88E6XXX_POLICY_MAPPING_DA:
1747 case MV88E6XXX_POLICY_MAPPING_SA:
1748 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1749 state = 0; /* Dissociate the port and address */
1750 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1751 is_multicast_ether_addr(addr))
1752 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1753 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1754 is_unicast_ether_addr(addr))
1755 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1756 else
1757 return -EOPNOTSUPP;
1758
1759 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1760 state);
1761 if (err)
1762 return err;
1763 break;
1764 default:
1765 return -EOPNOTSUPP;
1766 }
1767
1768 /* Skip the port's policy clearing if the mapping is still in use */
1769 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1770 idr_for_each_entry(&chip->policies, policy, id)
1771 if (policy->port == port &&
1772 policy->mapping == mapping &&
1773 policy->action != action)
1774 return 0;
1775
1776 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1777}
1778
1779static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1780 struct ethtool_rx_flow_spec *fs)
1781{
1782 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1783 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1784 enum mv88e6xxx_policy_mapping mapping;
1785 enum mv88e6xxx_policy_action action;
1786 struct mv88e6xxx_policy *policy;
1787 u16 vid = 0;
1788 u8 *addr;
1789 int err;
1790 int id;
1791
1792 if (fs->location != RX_CLS_LOC_ANY)
1793 return -EINVAL;
1794
1795 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1796 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1797 else
1798 return -EOPNOTSUPP;
1799
1800 switch (fs->flow_type & ~FLOW_EXT) {
1801 case ETHER_FLOW:
1802 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1803 is_zero_ether_addr(mac_mask->h_source)) {
1804 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1805 addr = mac_entry->h_dest;
1806 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1807 !is_zero_ether_addr(mac_mask->h_source)) {
1808 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1809 addr = mac_entry->h_source;
1810 } else {
1811 /* Cannot support DA and SA mapping in the same rule */
1812 return -EOPNOTSUPP;
1813 }
1814 break;
1815 default:
1816 return -EOPNOTSUPP;
1817 }
1818
1819 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001820 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001821 return -EOPNOTSUPP;
1822 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1823 }
1824
1825 idr_for_each_entry(&chip->policies, policy, id) {
1826 if (policy->port == port && policy->mapping == mapping &&
1827 policy->action == action && policy->vid == vid &&
1828 ether_addr_equal(policy->addr, addr))
1829 return -EEXIST;
1830 }
1831
1832 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1833 if (!policy)
1834 return -ENOMEM;
1835
1836 fs->location = 0;
1837 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1838 GFP_KERNEL);
1839 if (err) {
1840 devm_kfree(chip->dev, policy);
1841 return err;
1842 }
1843
1844 memcpy(&policy->fs, fs, sizeof(*fs));
1845 ether_addr_copy(policy->addr, addr);
1846 policy->mapping = mapping;
1847 policy->action = action;
1848 policy->port = port;
1849 policy->vid = vid;
1850
1851 err = mv88e6xxx_policy_apply(chip, port, policy);
1852 if (err) {
1853 idr_remove(&chip->policies, fs->location);
1854 devm_kfree(chip->dev, policy);
1855 return err;
1856 }
1857
1858 return 0;
1859}
1860
1861static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1862 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1863{
1864 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1865 struct mv88e6xxx_chip *chip = ds->priv;
1866 struct mv88e6xxx_policy *policy;
1867 int err;
1868 int id;
1869
1870 mv88e6xxx_reg_lock(chip);
1871
1872 switch (rxnfc->cmd) {
1873 case ETHTOOL_GRXCLSRLCNT:
1874 rxnfc->data = 0;
1875 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1876 rxnfc->rule_cnt = 0;
1877 idr_for_each_entry(&chip->policies, policy, id)
1878 if (policy->port == port)
1879 rxnfc->rule_cnt++;
1880 err = 0;
1881 break;
1882 case ETHTOOL_GRXCLSRULE:
1883 err = -ENOENT;
1884 policy = idr_find(&chip->policies, fs->location);
1885 if (policy) {
1886 memcpy(fs, &policy->fs, sizeof(*fs));
1887 err = 0;
1888 }
1889 break;
1890 case ETHTOOL_GRXCLSRLALL:
1891 rxnfc->data = 0;
1892 rxnfc->rule_cnt = 0;
1893 idr_for_each_entry(&chip->policies, policy, id)
1894 if (policy->port == port)
1895 rule_locs[rxnfc->rule_cnt++] = id;
1896 err = 0;
1897 break;
1898 default:
1899 err = -EOPNOTSUPP;
1900 break;
1901 }
1902
1903 mv88e6xxx_reg_unlock(chip);
1904
1905 return err;
1906}
1907
1908static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1909 struct ethtool_rxnfc *rxnfc)
1910{
1911 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1912 struct mv88e6xxx_chip *chip = ds->priv;
1913 struct mv88e6xxx_policy *policy;
1914 int err;
1915
1916 mv88e6xxx_reg_lock(chip);
1917
1918 switch (rxnfc->cmd) {
1919 case ETHTOOL_SRXCLSRLINS:
1920 err = mv88e6xxx_policy_insert(chip, port, fs);
1921 break;
1922 case ETHTOOL_SRXCLSRLDEL:
1923 err = -ENOENT;
1924 policy = idr_remove(&chip->policies, fs->location);
1925 if (policy) {
1926 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1927 err = mv88e6xxx_policy_apply(chip, port, policy);
1928 devm_kfree(chip->dev, policy);
1929 }
1930 break;
1931 default:
1932 err = -EOPNOTSUPP;
1933 break;
1934 }
1935
1936 mv88e6xxx_reg_unlock(chip);
1937
1938 return err;
1939}
1940
Andrew Lunn87fa8862017-11-09 22:29:56 +01001941static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1942 u16 vid)
1943{
1944 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1945 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1946
1947 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1948}
1949
1950static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1951{
1952 int port;
1953 int err;
1954
1955 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1956 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1957 if (err)
1958 return err;
1959 }
1960
1961 return 0;
1962}
1963
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001964static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001965 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001966{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001967 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001968 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001969 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001970
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001971 vlan.vid = vid - 1;
1972 vlan.valid = false;
1973
1974 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001975 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001976 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001977
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001978 if (vlan.vid != vid || !vlan.valid) {
1979 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001980
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001981 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1982 if (err)
1983 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001984
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001985 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1986 if (i == port)
1987 vlan.member[i] = member;
1988 else
1989 vlan.member[i] = non_member;
1990
1991 vlan.vid = vid;
1992 vlan.valid = true;
1993
1994 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1995 if (err)
1996 return err;
1997
1998 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1999 if (err)
2000 return err;
2001 } else if (vlan.member[port] != member) {
2002 vlan.member[port] = member;
2003
2004 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
2005 if (err)
2006 return err;
Russell King933b4422020-02-26 17:14:26 +00002007 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04002008 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
2009 port, vid);
2010 }
2011
2012 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002013}
2014
Vladimir Oltean1958d582021-01-09 02:01:53 +02002015static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vladimir Oltean31046a52021-02-13 22:43:18 +02002016 const struct switchdev_obj_port_vlan *vlan,
2017 struct netlink_ext_ack *extack)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002018{
Vivien Didelot04bed142016-08-31 18:06:13 -04002019 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002020 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
2021 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00002022 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002023 u8 member;
Vladimir Oltean1958d582021-01-09 02:01:53 +02002024 int err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002025
Vladimir Oltean1958d582021-01-09 02:01:53 +02002026 err = mv88e6xxx_port_vlan_prepare(ds, port, vlan);
2027 if (err)
2028 return err;
Vivien Didelot54d77b52016-05-09 13:22:47 -04002029
Vivien Didelotc91498e2017-06-07 18:12:13 -04002030 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002031 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002032 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002033 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002034 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002035 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04002036
Russell King933b4422020-02-26 17:14:26 +00002037 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
2038 * and then the CPU port. Do not warn for duplicates for the CPU port.
2039 */
2040 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
2041
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002042 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002043
Vladimir Oltean1958d582021-01-09 02:01:53 +02002044 err = mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn);
2045 if (err) {
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002046 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
2047 vlan->vid, untagged ? 'u' : 't');
Vladimir Oltean1958d582021-01-09 02:01:53 +02002048 goto out;
2049 }
Vivien Didelot76e398a2015-11-01 12:33:55 -05002050
Vladimir Oltean1958d582021-01-09 02:01:53 +02002051 if (pvid) {
2052 err = mv88e6xxx_port_set_pvid(chip, port, vlan->vid);
2053 if (err) {
2054 dev_err(ds->dev, "p%d: failed to set PVID %d\n",
2055 port, vlan->vid);
2056 goto out;
2057 }
2058 }
2059out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002060 mv88e6xxx_reg_unlock(chip);
Vladimir Oltean1958d582021-01-09 02:01:53 +02002061
2062 return err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002063}
2064
Vivien Didelot521098922019-08-01 14:36:36 -04002065static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2066 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002067{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002068 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002069 int i, err;
2070
Vivien Didelot521098922019-08-01 14:36:36 -04002071 if (!vid)
2072 return -EOPNOTSUPP;
2073
2074 vlan.vid = vid - 1;
2075 vlan.valid = false;
2076
2077 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002078 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002079 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002080
Vivien Didelot521098922019-08-01 14:36:36 -04002081 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2082 * tell switchdev that this VLAN is likely handled in software.
2083 */
2084 if (vlan.vid != vid || !vlan.valid ||
2085 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002086 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002087
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002088 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002089
2090 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002091 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002092 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002093 if (vlan.member[i] !=
2094 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002095 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002096 break;
2097 }
2098 }
2099
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002100 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002101 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002102 return err;
2103
Vivien Didelote606ca32017-03-11 16:12:55 -05002104 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002105}
2106
Vivien Didelotf81ec902016-05-09 13:22:58 -04002107static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2108 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002109{
Vivien Didelot04bed142016-08-31 18:06:13 -04002110 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002111 int err = 0;
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002112 u16 pvid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002113
Tobias Waldekranze545f862020-11-10 19:57:20 +01002114 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04002115 return -EOPNOTSUPP;
2116
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002117 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002118
Vivien Didelot77064f32016-11-04 03:23:30 +01002119 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002120 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002121 goto unlock;
2122
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002123 err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid);
2124 if (err)
2125 goto unlock;
2126
2127 if (vlan->vid == pvid) {
2128 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002129 if (err)
2130 goto unlock;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002131 }
2132
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002133unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002134 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002135
2136 return err;
2137}
2138
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002139static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2140 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002141{
Vivien Didelot04bed142016-08-31 18:06:13 -04002142 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002143 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002144
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002145 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002146 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2147 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002148 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002149
2150 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002151}
2152
Vivien Didelotf81ec902016-05-09 13:22:58 -04002153static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002154 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002155{
Vivien Didelot04bed142016-08-31 18:06:13 -04002156 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002157 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002158
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002159 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002160 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002161 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002162
Vivien Didelot83dabd12016-08-31 11:50:04 -04002163 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002164}
2165
Vivien Didelot83dabd12016-08-31 11:50:04 -04002166static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2167 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002168 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002169{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002170 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002171 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002172 int err;
2173
Vivien Didelotd8291a92019-09-07 16:00:47 -04002174 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002175 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002176
2177 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002178 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002179 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002180 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002181
Vivien Didelotd8291a92019-09-07 16:00:47 -04002182 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002183 break;
2184
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002185 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002186 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002187
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002188 if (!is_unicast_ether_addr(addr.mac))
2189 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002190
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002191 is_static = (addr.state ==
2192 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2193 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002194 if (err)
2195 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002196 } while (!is_broadcast_ether_addr(addr.mac));
2197
2198 return err;
2199}
2200
Vivien Didelot83dabd12016-08-31 11:50:04 -04002201static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002202 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002203{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002204 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002205 u16 fid;
2206 int err;
2207
2208 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002209 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002210 if (err)
2211 return err;
2212
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002213 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002214 if (err)
2215 return err;
2216
2217 /* Dump VLANs' Filtering Information Databases */
Tobias Waldekranze545f862020-11-10 19:57:20 +01002218 vlan.vid = mv88e6xxx_max_vid(chip);
Vivien Didelot425d2d32019-08-01 14:36:34 -04002219 vlan.valid = false;
2220
Vivien Didelot83dabd12016-08-31 11:50:04 -04002221 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002222 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002223 if (err)
2224 return err;
2225
2226 if (!vlan.valid)
2227 break;
2228
2229 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002230 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002231 if (err)
2232 return err;
Tobias Waldekranze545f862020-11-10 19:57:20 +01002233 } while (vlan.vid < mv88e6xxx_max_vid(chip));
Vivien Didelot83dabd12016-08-31 11:50:04 -04002234
2235 return err;
2236}
2237
Vivien Didelotf81ec902016-05-09 13:22:58 -04002238static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002239 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002240{
Vivien Didelot04bed142016-08-31 18:06:13 -04002241 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002242 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002243
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002244 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002245 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002246 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002247
2248 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002249}
2250
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002251static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2252 struct net_device *br)
2253{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002254 struct dsa_switch *ds = chip->ds;
2255 struct dsa_switch_tree *dst = ds->dst;
2256 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002257 int err;
2258
Vivien Didelotef2025e2019-10-21 16:51:27 -04002259 list_for_each_entry(dp, &dst->ports, list) {
2260 if (dp->bridge_dev == br) {
2261 if (dp->ds == ds) {
2262 /* This is a local bridge group member,
2263 * remap its Port VLAN Map.
2264 */
2265 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2266 if (err)
2267 return err;
2268 } else {
2269 /* This is an external bridge group member,
2270 * remap its cross-chip Port VLAN Table entry.
2271 */
2272 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2273 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002274 if (err)
2275 return err;
2276 }
2277 }
2278 }
2279
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002280 return 0;
2281}
2282
Vivien Didelotf81ec902016-05-09 13:22:58 -04002283static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002284 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002285{
Vivien Didelot04bed142016-08-31 18:06:13 -04002286 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002287 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002288
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002289 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002290 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002291 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002292
Vivien Didelot466dfa02016-02-26 13:16:05 -05002293 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002294}
2295
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002296static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2297 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002298{
Vivien Didelot04bed142016-08-31 18:06:13 -04002299 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002300
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002301 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002302 if (mv88e6xxx_bridge_map(chip, br) ||
2303 mv88e6xxx_port_vlan_map(chip, port))
2304 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002305 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002306}
2307
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002308static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2309 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002310 int port, struct net_device *br)
2311{
2312 struct mv88e6xxx_chip *chip = ds->priv;
2313 int err;
2314
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002315 if (tree_index != ds->dst->index)
2316 return 0;
2317
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002318 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002319 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002320 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002321
2322 return err;
2323}
2324
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002325static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2326 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002327 int port, struct net_device *br)
2328{
2329 struct mv88e6xxx_chip *chip = ds->priv;
2330
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002331 if (tree_index != ds->dst->index)
2332 return;
2333
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002334 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002335 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002336 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002337 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002338}
2339
Vivien Didelot17e708b2016-12-05 17:30:27 -05002340static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2341{
2342 if (chip->info->ops->reset)
2343 return chip->info->ops->reset(chip);
2344
2345 return 0;
2346}
2347
Vivien Didelot309eca62016-12-05 17:30:26 -05002348static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2349{
2350 struct gpio_desc *gpiod = chip->reset;
2351
2352 /* If there is a GPIO connected to the reset pin, toggle it */
2353 if (gpiod) {
2354 gpiod_set_value_cansleep(gpiod, 1);
2355 usleep_range(10000, 20000);
2356 gpiod_set_value_cansleep(gpiod, 0);
2357 usleep_range(10000, 20000);
Andrew Lunna3dcb3e2020-11-16 08:43:01 -08002358
2359 mv88e6xxx_g1_wait_eeprom_done(chip);
Vivien Didelot309eca62016-12-05 17:30:26 -05002360 }
2361}
2362
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002363static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2364{
2365 int i, err;
2366
2367 /* Set all ports to the Disabled state */
2368 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002369 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002370 if (err)
2371 return err;
2372 }
2373
2374 /* Wait for transmit queues to drain,
2375 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2376 */
2377 usleep_range(2000, 4000);
2378
2379 return 0;
2380}
2381
Vivien Didelotfad09c72016-06-21 12:28:20 -04002382static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002383{
Vivien Didelota935c052016-09-29 12:21:53 -04002384 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002385
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002386 err = mv88e6xxx_disable_ports(chip);
2387 if (err)
2388 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002389
Vivien Didelot309eca62016-12-05 17:30:26 -05002390 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002391
Vivien Didelot17e708b2016-12-05 17:30:27 -05002392 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002393}
2394
Vivien Didelot43145572017-03-11 16:12:59 -05002395static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002396 enum mv88e6xxx_frame_mode frame,
2397 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002398{
2399 int err;
2400
Vivien Didelot43145572017-03-11 16:12:59 -05002401 if (!chip->info->ops->port_set_frame_mode)
2402 return -EOPNOTSUPP;
2403
2404 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002405 if (err)
2406 return err;
2407
Vivien Didelot43145572017-03-11 16:12:59 -05002408 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2409 if (err)
2410 return err;
2411
2412 if (chip->info->ops->port_set_ether_type)
2413 return chip->info->ops->port_set_ether_type(chip, port, etype);
2414
2415 return 0;
2416}
2417
2418static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2419{
2420 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002421 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002422 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002423}
2424
2425static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2426{
2427 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002428 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002429 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002430}
2431
2432static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2433{
2434 return mv88e6xxx_set_port_mode(chip, port,
2435 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002436 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2437 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002438}
2439
2440static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2441{
2442 if (dsa_is_dsa_port(chip->ds, port))
2443 return mv88e6xxx_set_port_mode_dsa(chip, port);
2444
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002445 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002446 return mv88e6xxx_set_port_mode_normal(chip, port);
2447
2448 /* Setup CPU port mode depending on its supported tag format */
2449 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2450 return mv88e6xxx_set_port_mode_dsa(chip, port);
2451
2452 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2453 return mv88e6xxx_set_port_mode_edsa(chip, port);
2454
2455 return -EINVAL;
2456}
2457
Vivien Didelotea698f42017-03-11 16:12:50 -05002458static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2459{
2460 bool message = dsa_is_dsa_port(chip->ds, port);
2461
2462 return mv88e6xxx_port_set_message_port(chip, port, message);
2463}
2464
Vivien Didelot601aeed2017-03-11 16:13:00 -05002465static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2466{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002467 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002468 bool flood;
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002469 int err;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002470
David S. Miller407308f2019-06-15 13:35:29 -07002471 /* Upstream ports flood frames with unknown unicast or multicast DA */
2472 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02002473 if (chip->info->ops->port_set_ucast_flood) {
2474 err = chip->info->ops->port_set_ucast_flood(chip, port, flood);
2475 if (err)
2476 return err;
2477 }
2478 if (chip->info->ops->port_set_mcast_flood) {
2479 err = chip->info->ops->port_set_mcast_flood(chip, port, flood);
2480 if (err)
2481 return err;
2482 }
Vivien Didelot601aeed2017-03-11 16:13:00 -05002483
David S. Miller407308f2019-06-15 13:35:29 -07002484 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002485}
2486
Vivien Didelot45de77f2019-08-31 16:18:36 -04002487static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2488{
2489 struct mv88e6xxx_port *mvp = dev_id;
2490 struct mv88e6xxx_chip *chip = mvp->chip;
2491 irqreturn_t ret = IRQ_NONE;
2492 int port = mvp->port;
Pavana Sharma193c5b22021-03-17 14:46:40 +01002493 int lane;
Vivien Didelot45de77f2019-08-31 16:18:36 -04002494
2495 mv88e6xxx_reg_lock(chip);
2496 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +01002497 if (lane >= 0)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002498 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2499 mv88e6xxx_reg_unlock(chip);
2500
2501 return ret;
2502}
2503
2504static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
Pavana Sharma193c5b22021-03-17 14:46:40 +01002505 int lane)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002506{
2507 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2508 unsigned int irq;
2509 int err;
2510
2511 /* Nothing to request if this SERDES port has no IRQ */
2512 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2513 if (!irq)
2514 return 0;
2515
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002516 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2517 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2518
Vivien Didelot45de77f2019-08-31 16:18:36 -04002519 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2520 mv88e6xxx_reg_unlock(chip);
2521 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002522 IRQF_ONESHOT, dev_id->serdes_irq_name,
2523 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002524 mv88e6xxx_reg_lock(chip);
2525 if (err)
2526 return err;
2527
2528 dev_id->serdes_irq = irq;
2529
2530 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2531}
2532
2533static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
Pavana Sharma193c5b22021-03-17 14:46:40 +01002534 int lane)
Vivien Didelot45de77f2019-08-31 16:18:36 -04002535{
2536 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2537 unsigned int irq = dev_id->serdes_irq;
2538 int err;
2539
2540 /* Nothing to free if no IRQ has been requested */
2541 if (!irq)
2542 return 0;
2543
2544 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2545
2546 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2547 mv88e6xxx_reg_unlock(chip);
2548 free_irq(irq, dev_id);
2549 mv88e6xxx_reg_lock(chip);
2550
2551 dev_id->serdes_irq = 0;
2552
2553 return err;
2554}
2555
Andrew Lunn6d917822017-05-26 01:03:21 +02002556static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2557 bool on)
2558{
Pavana Sharma193c5b22021-03-17 14:46:40 +01002559 int lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002560 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002561
Vivien Didelotdc272f62019-08-31 16:18:33 -04002562 lane = mv88e6xxx_serdes_get_lane(chip, port);
Pavana Sharma193c5b22021-03-17 14:46:40 +01002563 if (lane < 0)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002564 return 0;
2565
2566 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002567 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002568 if (err)
2569 return err;
2570
Vivien Didelot45de77f2019-08-31 16:18:36 -04002571 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002572 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002573 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2574 if (err)
2575 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002576
Vivien Didelotdc272f62019-08-31 16:18:33 -04002577 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002578 }
2579
2580 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002581}
2582
Marek Behún2fda45f2021-03-17 14:46:41 +01002583static int mv88e6xxx_set_egress_port(struct mv88e6xxx_chip *chip,
2584 enum mv88e6xxx_egress_direction direction,
2585 int port)
2586{
2587 int err;
2588
2589 if (!chip->info->ops->set_egress_port)
2590 return -EOPNOTSUPP;
2591
2592 err = chip->info->ops->set_egress_port(chip, direction, port);
2593 if (err)
2594 return err;
2595
2596 if (direction == MV88E6XXX_EGRESS_DIR_INGRESS)
2597 chip->ingress_dest_port = port;
2598 else
2599 chip->egress_dest_port = port;
2600
2601 return 0;
2602}
2603
Vivien Didelotfa371c82017-12-05 15:34:10 -05002604static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2605{
2606 struct dsa_switch *ds = chip->ds;
2607 int upstream_port;
2608 int err;
2609
Vivien Didelot07073c72017-12-05 15:34:13 -05002610 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002611 if (chip->info->ops->port_set_upstream_port) {
2612 err = chip->info->ops->port_set_upstream_port(chip, port,
2613 upstream_port);
2614 if (err)
2615 return err;
2616 }
2617
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002618 if (port == upstream_port) {
2619 if (chip->info->ops->set_cpu_port) {
2620 err = chip->info->ops->set_cpu_port(chip,
2621 upstream_port);
2622 if (err)
2623 return err;
2624 }
2625
Marek Behún2fda45f2021-03-17 14:46:41 +01002626 err = mv88e6xxx_set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002627 MV88E6XXX_EGRESS_DIR_INGRESS,
2628 upstream_port);
Marek Behún2fda45f2021-03-17 14:46:41 +01002629 if (err && err != -EOPNOTSUPP)
2630 return err;
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002631
Marek Behún2fda45f2021-03-17 14:46:41 +01002632 err = mv88e6xxx_set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002633 MV88E6XXX_EGRESS_DIR_EGRESS,
2634 upstream_port);
Marek Behún2fda45f2021-03-17 14:46:41 +01002635 if (err && err != -EOPNOTSUPP)
2636 return err;
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002637 }
2638
Vivien Didelotfa371c82017-12-05 15:34:10 -05002639 return 0;
2640}
2641
Vivien Didelotfad09c72016-06-21 12:28:20 -04002642static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002643{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002644 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002645 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002646 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002647
Andrew Lunn7b898462018-08-09 15:38:47 +02002648 chip->ports[port].chip = chip;
2649 chip->ports[port].port = port;
2650
Vivien Didelotd78343d2016-11-04 03:23:36 +01002651 /* MAC Forcing register: don't force link, speed, duplex or flow control
2652 * state to any particular values on physical ports, but force the CPU
2653 * port and all DSA ports to their maximum bandwidth and full duplex.
2654 */
2655 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2656 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2657 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002658 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002659 PHY_INTERFACE_MODE_NA);
2660 else
2661 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2662 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002663 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002664 PHY_INTERFACE_MODE_NA);
2665 if (err)
2666 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002667
2668 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2669 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2670 * tunneling, determine priority by looking at 802.1p and IP
2671 * priority fields (IP prio has precedence), and set STP state
2672 * to Forwarding.
2673 *
2674 * If this is the CPU link, use DSA or EDSA tagging depending
2675 * on which tagging mode was configured.
2676 *
2677 * If this is a link to another switch, use DSA tagging mode.
2678 *
2679 * If this is the upstream port for this switch, enable
2680 * forwarding of unknown unicasts and multicasts.
2681 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002682 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2683 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2684 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2685 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002686 if (err)
2687 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002688
Vivien Didelot601aeed2017-03-11 16:13:00 -05002689 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002690 if (err)
2691 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002692
Vivien Didelot601aeed2017-03-11 16:13:00 -05002693 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002694 if (err)
2695 return err;
2696
Vivien Didelot8efdda42015-08-13 12:52:23 -04002697 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002698 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002699 * untagged frames on this port, do a destination address lookup on all
2700 * received packets as usual, disable ARP mirroring and don't send a
2701 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002702 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002703 err = mv88e6xxx_port_set_map_da(chip, port);
2704 if (err)
2705 return err;
2706
Vivien Didelotfa371c82017-12-05 15:34:10 -05002707 err = mv88e6xxx_setup_upstream_port(chip, port);
2708 if (err)
2709 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002710
Andrew Lunna23b2962017-02-04 20:15:28 +01002711 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002712 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002713 if (err)
2714 return err;
2715
Vivien Didelotcd782652017-06-08 18:34:13 -04002716 if (chip->info->ops->port_set_jumbo_size) {
2717 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002718 if (err)
2719 return err;
2720 }
2721
Andrew Lunn54d792f2015-05-06 01:09:47 +02002722 /* Port Association Vector: when learning source addresses
2723 * of packets, add the address to the address database using
2724 * a port bitmap that has only the bit for this port set and
2725 * the other bits clear.
2726 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002727 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002728 /* Disable learning for CPU port */
2729 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002730 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002731
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002732 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2733 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002734 if (err)
2735 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002736
2737 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002738 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2739 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002740 if (err)
2741 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002742
Vivien Didelot08984322017-06-08 18:34:12 -04002743 if (chip->info->ops->port_pause_limit) {
2744 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002745 if (err)
2746 return err;
2747 }
2748
Vivien Didelotc8c94892017-03-11 16:13:01 -05002749 if (chip->info->ops->port_disable_learn_limit) {
2750 err = chip->info->ops->port_disable_learn_limit(chip, port);
2751 if (err)
2752 return err;
2753 }
2754
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002755 if (chip->info->ops->port_disable_pri_override) {
2756 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002757 if (err)
2758 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002759 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002760
Andrew Lunnef0a7312016-12-03 04:35:16 +01002761 if (chip->info->ops->port_tag_remap) {
2762 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002763 if (err)
2764 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002765 }
2766
Andrew Lunnef70b112016-12-03 04:45:18 +01002767 if (chip->info->ops->port_egress_rate_limiting) {
2768 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002769 if (err)
2770 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002771 }
2772
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002773 if (chip->info->ops->port_setup_message_port) {
2774 err = chip->info->ops->port_setup_message_port(chip, port);
2775 if (err)
2776 return err;
2777 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002778
Vivien Didelot207afda2016-04-14 14:42:09 -04002779 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002780 * database, and allow bidirectional communication between the
2781 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002782 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002783 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002784 if (err)
2785 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002786
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002787 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002788 if (err)
2789 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002790
2791 /* Default VLAN ID and priority: don't set a default VLAN
2792 * ID, and set the default packet priority to zero.
2793 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002794 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002795}
2796
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002797static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
2798{
2799 struct mv88e6xxx_chip *chip = ds->priv;
2800
2801 if (chip->info->ops->port_set_jumbo_size)
2802 return 10240;
Chris Packham1baf0fa2020-07-24 11:21:22 +12002803 else if (chip->info->ops->set_max_frame_size)
2804 return 1632;
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002805 return 1522;
2806}
2807
2808static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
2809{
2810 struct mv88e6xxx_chip *chip = ds->priv;
2811 int ret = 0;
2812
2813 mv88e6xxx_reg_lock(chip);
2814 if (chip->info->ops->port_set_jumbo_size)
2815 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Chris Packham1baf0fa2020-07-24 11:21:22 +12002816 else if (chip->info->ops->set_max_frame_size)
2817 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002818 else
2819 if (new_mtu > 1522)
2820 ret = -EINVAL;
2821 mv88e6xxx_reg_unlock(chip);
2822
2823 return ret;
2824}
2825
Andrew Lunn04aca992017-05-26 01:03:24 +02002826static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2827 struct phy_device *phydev)
2828{
2829 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002830 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002831
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002832 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002833 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002834 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002835
2836 return err;
2837}
2838
Andrew Lunn75104db2019-02-24 20:44:43 +01002839static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002840{
2841 struct mv88e6xxx_chip *chip = ds->priv;
2842
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002843 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002844 if (mv88e6xxx_serdes_power(chip, port, false))
2845 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002846 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002847}
2848
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002849static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2850 unsigned int ageing_time)
2851{
Vivien Didelot04bed142016-08-31 18:06:13 -04002852 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002853 int err;
2854
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002855 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002856 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002857 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002858
2859 return err;
2860}
2861
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002862static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002863{
2864 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002865
Andrew Lunnde2273872016-11-21 23:27:01 +01002866 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002867 if (chip->info->ops->stats_set_histogram) {
2868 err = chip->info->ops->stats_set_histogram(chip);
2869 if (err)
2870 return err;
2871 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002872
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002873 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002874}
2875
Andrew Lunnea890982019-01-09 00:24:03 +01002876/* Check if the errata has already been applied. */
2877static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2878{
2879 int port;
2880 int err;
2881 u16 val;
2882
2883 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002884 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002885 if (err) {
2886 dev_err(chip->dev,
2887 "Error reading hidden register: %d\n", err);
2888 return false;
2889 }
2890 if (val != 0x01c0)
2891 return false;
2892 }
2893
2894 return true;
2895}
2896
2897/* The 6390 copper ports have an errata which require poking magic
2898 * values into undocumented hidden registers and then performing a
2899 * software reset.
2900 */
2901static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2902{
2903 int port;
2904 int err;
2905
2906 if (mv88e6390_setup_errata_applied(chip))
2907 return 0;
2908
2909 /* Set the ports into blocking mode */
2910 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2911 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2912 if (err)
2913 return err;
2914 }
2915
2916 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002917 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002918 if (err)
2919 return err;
2920 }
2921
2922 return mv88e6xxx_software_reset(chip);
2923}
2924
Andrew Lunn23e8b472019-10-25 01:03:52 +02002925static void mv88e6xxx_teardown(struct dsa_switch *ds)
2926{
2927 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002928 dsa_devlink_resources_unregister(ds);
Andrew Lunnbfb25542020-09-18 21:11:07 +02002929 mv88e6xxx_teardown_devlink_regions(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002930}
2931
Vivien Didelotf81ec902016-05-09 13:22:58 -04002932static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002933{
Vivien Didelot04bed142016-08-31 18:06:13 -04002934 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002935 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002936 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002937 int i;
2938
Vivien Didelotfad09c72016-06-21 12:28:20 -04002939 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002940 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002941
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002942 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002943
Andrew Lunnea890982019-01-09 00:24:03 +01002944 if (chip->info->ops->setup_errata) {
2945 err = chip->info->ops->setup_errata(chip);
2946 if (err)
2947 goto unlock;
2948 }
2949
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002950 /* Cache the cmode of each port. */
2951 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2952 if (chip->info->ops->port_get_cmode) {
2953 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2954 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002955 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002956
2957 chip->ports[i].cmode = cmode;
2958 }
2959 }
2960
Vivien Didelot97299342016-07-18 20:45:30 -04002961 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002962 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002963 if (dsa_is_unused_port(ds, i))
2964 continue;
2965
Hubert Feursteinc8574862019-07-31 10:23:48 +02002966 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002967 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002968 dev_err(chip->dev, "port %d is invalid\n", i);
2969 err = -EINVAL;
2970 goto unlock;
2971 }
2972
Vivien Didelot97299342016-07-18 20:45:30 -04002973 err = mv88e6xxx_setup_port(chip, i);
2974 if (err)
2975 goto unlock;
2976 }
2977
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002978 err = mv88e6xxx_irl_setup(chip);
2979 if (err)
2980 goto unlock;
2981
Vivien Didelot04a69a12017-10-13 14:18:05 -04002982 err = mv88e6xxx_mac_setup(chip);
2983 if (err)
2984 goto unlock;
2985
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002986 err = mv88e6xxx_phy_setup(chip);
2987 if (err)
2988 goto unlock;
2989
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002990 err = mv88e6xxx_vtu_setup(chip);
2991 if (err)
2992 goto unlock;
2993
Vivien Didelot81228992017-03-30 17:37:08 -04002994 err = mv88e6xxx_pvt_setup(chip);
2995 if (err)
2996 goto unlock;
2997
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002998 err = mv88e6xxx_atu_setup(chip);
2999 if (err)
3000 goto unlock;
3001
Andrew Lunn87fa8862017-11-09 22:29:56 +01003002 err = mv88e6xxx_broadcast_setup(chip, 0);
3003 if (err)
3004 goto unlock;
3005
Vivien Didelot9e907d72017-07-17 13:03:43 -04003006 err = mv88e6xxx_pot_setup(chip);
3007 if (err)
3008 goto unlock;
3009
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003010 err = mv88e6xxx_rmu_setup(chip);
3011 if (err)
3012 goto unlock;
3013
Vivien Didelot51c901a2017-07-17 13:03:41 -04003014 err = mv88e6xxx_rsvd2cpu_setup(chip);
3015 if (err)
3016 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003017
Vivien Didelotb28f8722018-04-26 21:56:44 -04003018 err = mv88e6xxx_trunk_setup(chip);
3019 if (err)
3020 goto unlock;
3021
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003022 err = mv88e6xxx_devmap_setup(chip);
3023 if (err)
3024 goto unlock;
3025
Vivien Didelot93e18d62018-05-11 17:16:35 -04003026 err = mv88e6xxx_pri_setup(chip);
3027 if (err)
3028 goto unlock;
3029
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003030 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003031 if (chip->info->ptp_support) {
3032 err = mv88e6xxx_ptp_setup(chip);
3033 if (err)
3034 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003035
3036 err = mv88e6xxx_hwtstamp_setup(chip);
3037 if (err)
3038 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003039 }
3040
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003041 err = mv88e6xxx_stats_setup(chip);
3042 if (err)
3043 goto unlock;
3044
Vivien Didelot6b17e862015-08-13 12:52:18 -04003045unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003046 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003047
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003048 if (err)
3049 return err;
3050
3051 /* Have to be called without holding the register lock, since
3052 * they take the devlink lock, and we later take the locks in
3053 * the reverse order when getting/setting parameters or
3054 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003055 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003056 err = mv88e6xxx_setup_devlink_resources(ds);
3057 if (err)
3058 return err;
3059
3060 err = mv88e6xxx_setup_devlink_params(ds);
3061 if (err)
Andrew Lunnbfb25542020-09-18 21:11:07 +02003062 goto out_resources;
3063
3064 err = mv88e6xxx_setup_devlink_regions(ds);
3065 if (err)
3066 goto out_params;
3067
3068 return 0;
3069
3070out_params:
3071 mv88e6xxx_teardown_devlink_params(ds);
3072out_resources:
3073 dsa_devlink_resources_unregister(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003074
3075 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003076}
3077
Vivien Didelote57e5e72016-08-15 17:19:00 -04003078static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003079{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003080 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3081 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003082 u16 val;
3083 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003084
Andrew Lunnee26a222017-01-24 14:53:48 +01003085 if (!chip->info->ops->phy_read)
3086 return -EOPNOTSUPP;
3087
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003088 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003089 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003090 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003091
Andrew Lunnda9f3302017-02-01 03:40:05 +01003092 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003093 /* Some internal PHYs don't have a model number. */
3094 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3095 /* Then there is the 6165 family. It gets is
3096 * PHYs correct. But it can also have two
3097 * SERDES interfaces in the PHY address
3098 * space. And these don't have a model
3099 * number. But they are not PHYs, so we don't
3100 * want to give them something a PHY driver
3101 * will recognise.
3102 *
3103 * Use the mv88e6390 family model number
3104 * instead, for anything which really could be
3105 * a PHY,
3106 */
3107 if (!(val & 0x3f0))
3108 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003109 }
3110
Vivien Didelote57e5e72016-08-15 17:19:00 -04003111 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003112}
3113
Vivien Didelote57e5e72016-08-15 17:19:00 -04003114static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003115{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003116 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3117 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003118 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003119
Andrew Lunnee26a222017-01-24 14:53:48 +01003120 if (!chip->info->ops->phy_write)
3121 return -EOPNOTSUPP;
3122
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003123 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003124 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003125 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003126
3127 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003128}
3129
Vivien Didelotfad09c72016-06-21 12:28:20 -04003130static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003131 struct device_node *np,
3132 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003133{
3134 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003135 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003136 struct mii_bus *bus;
3137 int err;
3138
Andrew Lunn2510bab2018-02-22 01:51:49 +01003139 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003140 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003141 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003142 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003143
3144 if (err)
3145 return err;
3146 }
3147
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003148 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003149 if (!bus)
3150 return -ENOMEM;
3151
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003152 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003153 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003154 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003155 INIT_LIST_HEAD(&mdio_bus->list);
3156 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003157
Andrew Lunnb516d452016-06-04 21:17:06 +02003158 if (np) {
3159 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003160 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003161 } else {
3162 bus->name = "mv88e6xxx SMI";
3163 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3164 }
3165
3166 bus->read = mv88e6xxx_mdio_read;
3167 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003168 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003169
Andrew Lunn6f882842018-03-17 20:32:05 +01003170 if (!external) {
3171 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3172 if (err)
3173 return err;
3174 }
3175
Florian Fainelli00e798c2018-05-15 16:56:19 -07003176 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003177 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003178 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003179 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003180 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003181 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003182
3183 if (external)
3184 list_add_tail(&mdio_bus->list, &chip->mdios);
3185 else
3186 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003187
3188 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003189}
3190
Andrew Lunn3126aee2017-12-07 01:05:57 +01003191static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3192
3193{
3194 struct mv88e6xxx_mdio_bus *mdio_bus;
3195 struct mii_bus *bus;
3196
3197 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3198 bus = mdio_bus->bus;
3199
Andrew Lunn6f882842018-03-17 20:32:05 +01003200 if (!mdio_bus->external)
3201 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3202
Andrew Lunn3126aee2017-12-07 01:05:57 +01003203 mdiobus_unregister(bus);
3204 }
3205}
3206
Andrew Lunna3c53be52017-01-24 14:53:50 +01003207static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3208 struct device_node *np)
3209{
Andrew Lunna3c53be52017-01-24 14:53:50 +01003210 struct device_node *child;
3211 int err;
3212
3213 /* Always register one mdio bus for the internal/default mdio
3214 * bus. This maybe represented in the device tree, but is
3215 * optional.
3216 */
3217 child = of_get_child_by_name(np, "mdio");
3218 err = mv88e6xxx_mdio_register(chip, child, false);
3219 if (err)
3220 return err;
3221
3222 /* Walk the device tree, and see if there are any other nodes
3223 * which say they are compatible with the external mdio
3224 * bus.
3225 */
3226 for_each_available_child_of_node(np, child) {
Andrew Lunnceb96fa2020-09-01 04:32:57 +02003227 if (of_device_is_compatible(
3228 child, "marvell,mv88e6xxx-mdio-external")) {
Andrew Lunna3c53be52017-01-24 14:53:50 +01003229 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003230 if (err) {
3231 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303232 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003233 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003234 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003235 }
3236 }
3237
3238 return 0;
3239}
3240
Vivien Didelot855b1932016-07-20 18:18:35 -04003241static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3242{
Vivien Didelot04bed142016-08-31 18:06:13 -04003243 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003244
3245 return chip->eeprom_len;
3246}
3247
Vivien Didelot855b1932016-07-20 18:18:35 -04003248static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3249 struct ethtool_eeprom *eeprom, u8 *data)
3250{
Vivien Didelot04bed142016-08-31 18:06:13 -04003251 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003252 int err;
3253
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003254 if (!chip->info->ops->get_eeprom)
3255 return -EOPNOTSUPP;
3256
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003257 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003258 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003259 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003260
3261 if (err)
3262 return err;
3263
3264 eeprom->magic = 0xc3ec4951;
3265
3266 return 0;
3267}
3268
Vivien Didelot855b1932016-07-20 18:18:35 -04003269static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3270 struct ethtool_eeprom *eeprom, u8 *data)
3271{
Vivien Didelot04bed142016-08-31 18:06:13 -04003272 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003273 int err;
3274
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003275 if (!chip->info->ops->set_eeprom)
3276 return -EOPNOTSUPP;
3277
Vivien Didelot855b1932016-07-20 18:18:35 -04003278 if (eeprom->magic != 0xc3ec4951)
3279 return -EINVAL;
3280
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003281 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003282 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003283 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003284
3285 return err;
3286}
3287
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003288static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003289 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003290 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3291 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003292 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003293 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003294 .phy_read = mv88e6185_phy_ppu_read,
3295 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003296 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003297 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003298 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003299 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003300 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003301 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3302 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003303 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003304 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003305 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003306 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003307 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003308 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003309 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003310 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003311 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003312 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3313 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003314 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003315 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3316 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003317 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003318 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003319 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003320 .ppu_enable = mv88e6185_g1_ppu_enable,
3321 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003322 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003323 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003324 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003325 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003326 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003327 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003328};
3329
3330static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003331 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003332 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3333 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003334 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003335 .phy_read = mv88e6185_phy_ppu_read,
3336 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003337 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003338 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003339 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003340 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003341 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3342 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunna23b2962017-02-04 20:15:28 +01003343 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003344 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003345 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003346 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003347 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003348 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3349 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003350 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003351 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003352 .serdes_power = mv88e6185_serdes_power,
3353 .serdes_get_lane = mv88e6185_serdes_get_lane,
3354 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003355 .ppu_enable = mv88e6185_g1_ppu_enable,
3356 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003357 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003358 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003359 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003360 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003361 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003362};
3363
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003364static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003365 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003366 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3367 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003368 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003369 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3370 .phy_read = mv88e6xxx_g2_smi_phy_read,
3371 .phy_write = mv88e6xxx_g2_smi_phy_write,
3372 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003373 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003374 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003375 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003376 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003377 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3378 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003379 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003380 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003381 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003382 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003383 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003384 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003385 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003386 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003387 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003388 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3389 .stats_get_strings = mv88e6095_stats_get_strings,
3390 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003391 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3392 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003393 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003394 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003395 .serdes_power = mv88e6185_serdes_power,
3396 .serdes_get_lane = mv88e6185_serdes_get_lane,
3397 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Chris Packham5c19bc82020-11-24 17:34:39 +13003398 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
3399 .serdes_irq_enable = mv88e6097_serdes_irq_enable,
3400 .serdes_irq_status = mv88e6097_serdes_irq_status,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003401 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003402 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003403 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003404 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003405 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003406 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003407 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003408};
3409
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003410static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003411 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003412 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3413 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003414 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003415 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003416 .phy_read = mv88e6xxx_g2_smi_phy_read,
3417 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003418 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003419 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003420 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003421 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003422 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3423 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003424 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003425 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003426 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003427 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003428 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003429 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003430 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3431 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003432 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003433 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3434 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003435 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003436 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003437 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003438 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003439 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3440 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003441 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003442 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003443 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003444 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003445};
3446
3447static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003448 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003449 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3450 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003451 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003452 .phy_read = mv88e6185_phy_ppu_read,
3453 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003454 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003455 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003456 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003457 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003458 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003459 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3460 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003461 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003462 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003463 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003464 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003465 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003466 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003467 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003468 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003469 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003470 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003471 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3472 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003473 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003474 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3475 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003476 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003477 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003478 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003479 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003480 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003481 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003482 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003483 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003484 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003485};
3486
Vivien Didelot990e27b2017-03-28 13:50:32 -04003487static const struct mv88e6xxx_ops mv88e6141_ops = {
3488 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003489 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3490 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003491 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003492 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3493 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3494 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3495 .phy_read = mv88e6xxx_g2_smi_phy_read,
3496 .phy_write = mv88e6xxx_g2_smi_phy_write,
3497 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003498 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003499 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003500 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003501 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003502 .port_tag_remap = mv88e6095_port_tag_remap,
3503 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003504 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3505 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003506 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003507 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003508 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003509 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003510 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3511 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003512 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003513 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003514 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003515 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003516 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003517 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3518 .stats_get_strings = mv88e6320_stats_get_strings,
3519 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003520 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3521 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003522 .watchdog_ops = &mv88e6390_watchdog_ops,
3523 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003524 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003525 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003526 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003527 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003528 .serdes_power = mv88e6390_serdes_power,
3529 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003530 /* Check status register pause & lpa register */
3531 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3532 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3533 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3534 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003535 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003536 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003537 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003538 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003539 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003540};
3541
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003542static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003543 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003544 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3545 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003546 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003547 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003548 .phy_read = mv88e6xxx_g2_smi_phy_read,
3549 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003550 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003551 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003552 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003553 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003554 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003555 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3556 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003557 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003558 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003559 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003560 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003561 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003562 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003563 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003564 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003565 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003566 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003567 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3568 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003569 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003570 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3571 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003572 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003573 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003574 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003575 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003576 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3577 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003578 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003579 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003580 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003581 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003582 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003583};
3584
3585static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003586 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003587 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3588 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003589 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003590 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003591 .phy_read = mv88e6165_phy_read,
3592 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003593 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003594 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003595 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003596 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003597 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003598 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003599 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003600 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003601 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003602 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3603 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003604 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003605 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3606 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003607 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003608 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003609 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003610 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003611 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3612 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003613 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003614 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003615 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003616 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003617 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003618};
3619
3620static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003621 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003622 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3623 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003624 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003625 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003626 .phy_read = mv88e6xxx_g2_smi_phy_read,
3627 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003628 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003629 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003630 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003631 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003632 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003633 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003634 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3635 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
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 mv88e6172_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,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003679 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3680 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003681 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003682 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003683 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003684 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003685 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003686 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003687 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003688 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003689 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003690 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003691 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3692 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003693 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003694 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3695 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003696 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003697 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003698 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003699 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003700 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003701 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3702 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003703 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003704 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003705 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003706 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3707 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3708 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3709 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003710 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003711 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3712 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003713 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003714 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003715};
3716
3717static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003718 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003719 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3720 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003721 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003722 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003723 .phy_read = mv88e6xxx_g2_smi_phy_read,
3724 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003725 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003726 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003727 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003728 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003729 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003730 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003731 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3732 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003733 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003734 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003735 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003736 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003737 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003738 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003739 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003740 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003741 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003742 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003743 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3744 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003745 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003746 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3747 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003748 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003749 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003750 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003751 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003752 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3753 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003754 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003755 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003756 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003757};
3758
3759static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003760 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003761 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3762 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003763 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003764 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3765 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003766 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003767 .phy_read = mv88e6xxx_g2_smi_phy_read,
3768 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003769 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003770 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003771 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003772 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003773 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003774 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003775 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003776 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3777 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003778 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003779 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003780 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003781 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003782 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003783 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003784 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003785 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003786 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003787 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003788 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3789 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003790 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003791 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3792 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003793 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003794 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003795 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003796 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003797 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003798 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3799 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003800 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003801 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003802 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003803 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3804 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3805 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3806 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003807 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003808 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003809 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003810 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003811 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3812 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003813 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003814 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003815};
3816
3817static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003818 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003819 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3820 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003821 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003822 .phy_read = mv88e6185_phy_ppu_read,
3823 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003824 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003825 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003826 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003827 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003828 .port_set_ucast_flood = mv88e6185_port_set_forward_unknown,
3829 .port_set_mcast_flood = mv88e6185_port_set_default_forward,
Andrew Lunnef70b112016-12-03 04:45:18 +01003830 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003831 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003832 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003833 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003834 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003835 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003836 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003837 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3838 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003839 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003840 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3841 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003842 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003843 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003844 .serdes_power = mv88e6185_serdes_power,
3845 .serdes_get_lane = mv88e6185_serdes_get_lane,
3846 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelot02317e62018-05-09 11:38:49 -04003847 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003848 .ppu_enable = mv88e6185_g1_ppu_enable,
3849 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003850 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003851 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003852 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003853 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003854 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003855};
3856
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003857static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003858 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003859 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003860 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003861 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3862 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003863 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3864 .phy_read = mv88e6xxx_g2_smi_phy_read,
3865 .phy_write = mv88e6xxx_g2_smi_phy_write,
3866 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003867 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003868 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003869 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003870 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003871 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003872 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003873 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003874 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3875 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003876 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003877 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003878 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003879 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003880 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003881 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003882 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003883 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003884 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003885 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003886 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3887 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003888 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003889 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3890 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003891 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003892 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003893 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003894 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003895 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003896 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3897 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003898 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3899 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003900 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003901 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003902 /* Check status register pause & lpa register */
3903 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3904 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3905 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3906 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003907 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003908 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003909 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003910 .serdes_get_strings = mv88e6390_serdes_get_strings,
3911 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003912 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3913 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003914 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003915 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003916};
3917
3918static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003919 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003920 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003921 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003922 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3923 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003924 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3925 .phy_read = mv88e6xxx_g2_smi_phy_read,
3926 .phy_write = mv88e6xxx_g2_smi_phy_write,
3927 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003928 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003929 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003930 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003931 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003932 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003933 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003934 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003935 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3936 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003937 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003938 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003939 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003940 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003941 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003942 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003943 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003944 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003945 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003946 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003947 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3948 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003949 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003950 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3951 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003952 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003953 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003954 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003955 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003956 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003957 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3958 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003959 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3960 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003961 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003962 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003963 /* Check status register pause & lpa register */
3964 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3965 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3966 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3967 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003968 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003969 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003970 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003971 .serdes_get_strings = mv88e6390_serdes_get_strings,
3972 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003973 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3974 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003975 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003976 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003977};
3978
3979static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003980 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003981 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003982 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003983 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3984 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003985 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3986 .phy_read = mv88e6xxx_g2_smi_phy_read,
3987 .phy_write = mv88e6xxx_g2_smi_phy_write,
3988 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003989 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003990 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003991 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003992 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003993 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003994 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02003995 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
3996 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003997 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003998 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003999 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004000 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004001 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004002 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004003 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004004 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004005 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004006 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4007 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004008 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004009 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4010 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004011 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004012 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004013 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004014 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004015 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004016 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4017 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004018 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4019 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004020 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004021 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004022 /* Check status register pause & lpa register */
4023 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4024 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4025 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4026 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004027 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004028 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004029 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004030 .serdes_get_strings = mv88e6390_serdes_get_strings,
4031 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004032 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4033 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004034 .avb_ops = &mv88e6390_avb_ops,
4035 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004036 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004037};
4038
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004039static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004040 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004041 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4042 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004043 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004044 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4045 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004046 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004047 .phy_read = mv88e6xxx_g2_smi_phy_read,
4048 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004049 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004050 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004051 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004052 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004053 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004054 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004055 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004056 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4057 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004058 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004059 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004060 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004061 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004062 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004063 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004064 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004065 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004066 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004067 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004068 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4069 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004070 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004071 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4072 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004073 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004074 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004075 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004076 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004077 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004078 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4079 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004080 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004081 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004082 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004083 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4084 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4085 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4086 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004087 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004088 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004089 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004090 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004091 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4092 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004093 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004094 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004095 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004096 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004097};
4098
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004099static const struct mv88e6xxx_ops mv88e6250_ops = {
4100 /* MV88E6XXX_FAMILY_6250 */
4101 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4102 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4103 .irl_init_all = mv88e6352_g2_irl_init_all,
4104 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4105 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4106 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4107 .phy_read = mv88e6xxx_g2_smi_phy_read,
4108 .phy_write = mv88e6xxx_g2_smi_phy_write,
4109 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004110 .port_sync_link = mv88e6xxx_port_sync_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004111 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004112 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004113 .port_tag_remap = mv88e6095_port_tag_remap,
4114 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004115 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4116 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004117 .port_set_ether_type = mv88e6351_port_set_ether_type,
4118 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4119 .port_pause_limit = mv88e6097_port_pause_limit,
4120 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004121 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4122 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4123 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4124 .stats_get_strings = mv88e6250_stats_get_strings,
4125 .stats_get_stats = mv88e6250_stats_get_stats,
4126 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4127 .set_egress_port = mv88e6095_g1_set_egress_port,
4128 .watchdog_ops = &mv88e6250_watchdog_ops,
4129 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4130 .pot_clear = mv88e6xxx_g2_pot_clear,
4131 .reset = mv88e6250_g1_reset,
Rasmus Villemoes67c9ed12021-01-25 16:04:48 +01004132 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Rasmus Villemoesb28f3f32021-01-25 16:04:49 +01004133 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004134 .avb_ops = &mv88e6352_avb_ops,
4135 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004136 .phylink_validate = mv88e6065_phylink_validate,
4137};
4138
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004139static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004140 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004141 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004142 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004143 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4144 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004145 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4146 .phy_read = mv88e6xxx_g2_smi_phy_read,
4147 .phy_write = mv88e6xxx_g2_smi_phy_write,
4148 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004149 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004150 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004151 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004152 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004153 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004154 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004155 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004156 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4157 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004158 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004159 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004160 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004161 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004162 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004163 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004164 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004165 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004166 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004167 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4168 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004169 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004170 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4171 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004172 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004173 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004174 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004175 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004176 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004177 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4178 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004179 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4180 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004181 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004182 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004183 /* Check status register pause & lpa register */
4184 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4185 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4186 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4187 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004188 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004189 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004190 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004191 .serdes_get_strings = mv88e6390_serdes_get_strings,
4192 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004193 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4194 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004195 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004196 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004197 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004198 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004199};
4200
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004201static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004202 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004203 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4204 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004205 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004206 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4207 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004208 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004209 .phy_read = mv88e6xxx_g2_smi_phy_read,
4210 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004211 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004212 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004213 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004214 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004215 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004216 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4217 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004218 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004219 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004220 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004221 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004222 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004223 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004224 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004225 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004226 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004227 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004228 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4229 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004230 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004231 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4232 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004233 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004234 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004235 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004236 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004237 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004238 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004239 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004240 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004241 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004242 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004243};
4244
4245static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004246 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004247 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4248 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004249 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004250 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4251 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004252 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004253 .phy_read = mv88e6xxx_g2_smi_phy_read,
4254 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004255 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004256 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004257 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004258 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004259 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004260 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4261 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004262 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004263 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004264 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004265 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004266 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004267 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004268 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004269 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004270 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004271 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004272 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4273 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004274 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004275 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4276 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004277 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004278 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004279 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004280 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004281 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004282 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004283 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004284 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004285};
4286
Vivien Didelot16e329a2017-03-28 13:50:33 -04004287static const struct mv88e6xxx_ops mv88e6341_ops = {
4288 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004289 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4290 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004291 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004292 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4293 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4294 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4295 .phy_read = mv88e6xxx_g2_smi_phy_read,
4296 .phy_write = mv88e6xxx_g2_smi_phy_write,
4297 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004298 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004299 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004300 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004301 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004302 .port_tag_remap = mv88e6095_port_tag_remap,
4303 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004304 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4305 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004306 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004307 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004308 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004309 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004310 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4311 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004312 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004313 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004314 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004315 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004316 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004317 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4318 .stats_get_strings = mv88e6320_stats_get_strings,
4319 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004320 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4321 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004322 .watchdog_ops = &mv88e6390_watchdog_ops,
4323 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004324 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004325 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004326 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004327 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004328 .serdes_power = mv88e6390_serdes_power,
4329 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004330 /* Check status register pause & lpa register */
4331 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4332 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4333 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4334 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004335 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004336 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004337 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004338 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004339 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004340 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004341 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004342};
4343
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004344static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004345 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004346 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4347 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004348 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004349 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004350 .phy_read = mv88e6xxx_g2_smi_phy_read,
4351 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004352 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004353 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004354 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004355 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004356 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004357 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004358 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4359 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004360 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004361 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004362 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004363 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004364 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004365 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004366 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004367 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004368 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004369 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004370 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4371 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004372 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004373 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4374 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004375 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004376 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004377 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004378 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004379 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4380 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004381 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004382 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004383 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004384};
4385
4386static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004387 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004388 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4389 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004390 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004391 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004392 .phy_read = mv88e6xxx_g2_smi_phy_read,
4393 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004394 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004395 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004396 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004397 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004398 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004399 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004400 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4401 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004402 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004403 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004404 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004405 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004406 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004407 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004408 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004409 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004410 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004411 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004412 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4413 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004414 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004415 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4416 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004417 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004418 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004419 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004420 .reset = mv88e6352_g1_reset,
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 Didelotf1394b782017-05-01 14:05:22 -04004423 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004424 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004425 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004426 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004427 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004428};
4429
4430static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004431 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004432 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4433 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004434 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004435 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4436 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004437 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004438 .phy_read = mv88e6xxx_g2_smi_phy_read,
4439 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004440 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004441 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004442 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004443 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004444 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004445 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004446 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004447 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4448 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004449 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004450 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004451 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004452 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004453 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004454 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004455 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004456 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004457 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004458 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004459 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4460 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004461 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004462 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4463 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004464 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004465 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004466 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004467 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004468 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004469 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4470 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004471 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004472 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004473 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004474 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4475 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4476 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4477 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004478 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004479 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004480 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004481 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004482 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004483 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004484 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004485 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4486 .serdes_get_strings = mv88e6352_serdes_get_strings,
4487 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004488 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4489 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004490 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004491};
4492
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004493static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004494 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004495 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004496 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004497 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4498 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004499 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4500 .phy_read = mv88e6xxx_g2_smi_phy_read,
4501 .phy_write = mv88e6xxx_g2_smi_phy_write,
4502 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004503 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004504 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004505 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004506 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004507 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004508 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004509 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004510 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4511 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004512 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004513 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004514 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004515 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004516 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004517 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004518 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004519 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004520 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004521 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004522 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004523 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4524 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004525 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004526 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4527 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004528 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004529 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004530 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004531 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004532 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004533 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4534 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004535 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4536 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004537 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004538 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004539 /* Check status register pause & lpa register */
4540 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4541 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4542 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4543 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004544 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004545 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004546 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004547 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004548 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004549 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004550 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4551 .serdes_get_strings = mv88e6390_serdes_get_strings,
4552 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004553 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4554 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004555 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004556};
4557
4558static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004559 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004560 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004561 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004562 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4563 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004564 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4565 .phy_read = mv88e6xxx_g2_smi_phy_read,
4566 .phy_write = mv88e6xxx_g2_smi_phy_write,
4567 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004568 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004569 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004570 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004571 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004572 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004573 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004574 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02004575 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4576 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004577 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004578 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004579 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004580 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004581 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004582 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004583 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004584 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004585 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004586 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004587 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004588 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4589 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004590 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004591 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4592 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004593 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004594 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004595 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004596 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004597 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004598 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4599 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004600 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4601 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004602 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004603 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004604 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4605 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4606 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4607 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004608 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004609 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004610 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004611 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4612 .serdes_get_strings = mv88e6390_serdes_get_strings,
4613 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004614 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4615 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004616 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004617 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004618 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004619 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004620};
4621
Pavana Sharmade776d02021-03-17 14:46:42 +01004622static const struct mv88e6xxx_ops mv88e6393x_ops = {
4623 /* MV88E6XXX_FAMILY_6393 */
4624 .setup_errata = mv88e6393x_serdes_setup_errata,
4625 .irl_init_all = mv88e6390_g2_irl_init_all,
4626 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4627 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4628 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4629 .phy_read = mv88e6xxx_g2_smi_phy_read,
4630 .phy_write = mv88e6xxx_g2_smi_phy_write,
4631 .port_set_link = mv88e6xxx_port_set_link,
4632 .port_sync_link = mv88e6xxx_port_sync_link,
4633 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
4634 .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex,
4635 .port_max_speed_mode = mv88e6393x_port_max_speed_mode,
4636 .port_tag_remap = mv88e6390_port_tag_remap,
Marek Behún6584b262021-03-17 14:46:43 +01004637 .port_set_policy = mv88e6393x_port_set_policy,
Pavana Sharmade776d02021-03-17 14:46:42 +01004638 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4639 .port_set_ucast_flood = mv88e6352_port_set_ucast_flood,
4640 .port_set_mcast_flood = mv88e6352_port_set_mcast_flood,
4641 .port_set_ether_type = mv88e6393x_port_set_ether_type,
4642 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
4643 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4644 .port_pause_limit = mv88e6390_port_pause_limit,
4645 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4646 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
4647 .port_get_cmode = mv88e6352_port_get_cmode,
4648 .port_set_cmode = mv88e6393x_port_set_cmode,
4649 .port_setup_message_port = mv88e6xxx_setup_message_port,
4650 .port_set_upstream_port = mv88e6393x_port_set_upstream_port,
4651 .stats_snapshot = mv88e6390_g1_stats_snapshot,
4652 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
4653 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4654 .stats_get_strings = mv88e6320_stats_get_strings,
4655 .stats_get_stats = mv88e6390_stats_get_stats,
4656 /* .set_cpu_port is missing because this family does not support a global
4657 * CPU port, only per port CPU port which is set via
4658 * .port_set_upstream_port method.
4659 */
4660 .set_egress_port = mv88e6393x_set_egress_port,
4661 .watchdog_ops = &mv88e6390_watchdog_ops,
4662 .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu,
4663 .pot_clear = mv88e6xxx_g2_pot_clear,
4664 .reset = mv88e6352_g1_reset,
4665 .rmu_disable = mv88e6390_g1_rmu_disable,
4666 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4667 .atu_set_hash = mv88e6165_g1_atu_set_hash,
4668 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4669 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
4670 .serdes_power = mv88e6393x_serdes_power,
4671 .serdes_get_lane = mv88e6393x_serdes_get_lane,
4672 .serdes_pcs_get_state = mv88e6393x_serdes_pcs_get_state,
4673 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4674 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4675 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
4676 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
4677 .serdes_irq_enable = mv88e6393x_serdes_irq_enable,
4678 .serdes_irq_status = mv88e6393x_serdes_irq_status,
4679 /* TODO: serdes stats */
4680 .gpio_ops = &mv88e6352_gpio_ops,
4681 .avb_ops = &mv88e6390_avb_ops,
4682 .ptp_ops = &mv88e6352_ptp_ops,
4683 .phylink_validate = mv88e6393x_phylink_validate,
4684};
4685
Vivien Didelotf81ec902016-05-09 13:22:58 -04004686static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4687 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004688 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004689 .family = MV88E6XXX_FAMILY_6097,
4690 .name = "Marvell 88E6085",
4691 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004692 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004693 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004694 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004695 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004696 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004697 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004698 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004699 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004700 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004701 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004702 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004703 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004704 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004705 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004706 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004707 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004708 },
4709
4710 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004711 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004712 .family = MV88E6XXX_FAMILY_6095,
4713 .name = "Marvell 88E6095/88E6095F",
4714 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004715 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004716 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004717 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004718 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004719 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004720 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004721 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004722 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004723 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004724 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004725 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004726 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004727 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004728 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004729 },
4730
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004731 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004732 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004733 .family = MV88E6XXX_FAMILY_6097,
4734 .name = "Marvell 88E6097/88E6097F",
4735 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004736 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004737 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004738 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004739 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004740 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004741 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004742 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004743 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004744 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004745 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004746 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004747 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004748 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004749 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004750 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004751 .ops = &mv88e6097_ops,
4752 },
4753
Vivien Didelotf81ec902016-05-09 13:22:58 -04004754 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004755 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004756 .family = MV88E6XXX_FAMILY_6165,
4757 .name = "Marvell 88E6123",
4758 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004759 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004760 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004761 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004762 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004763 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004764 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004765 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004766 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004767 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004768 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004769 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004770 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004771 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004772 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004773 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004774 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004775 },
4776
4777 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004778 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004779 .family = MV88E6XXX_FAMILY_6185,
4780 .name = "Marvell 88E6131",
4781 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004782 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004783 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004784 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004785 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004786 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004787 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004788 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004789 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004790 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004791 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004792 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004793 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004794 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004795 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004796 },
4797
Vivien Didelot990e27b2017-03-28 13:50:32 -04004798 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004799 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004800 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004801 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004802 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004803 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004804 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004805 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004806 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004807 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004808 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004809 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004810 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004811 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004812 .age_time_coeff = 3750,
4813 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004814 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004815 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004816 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004817 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004818 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004819 .ops = &mv88e6141_ops,
4820 },
4821
Vivien Didelotf81ec902016-05-09 13:22:58 -04004822 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004823 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004824 .family = MV88E6XXX_FAMILY_6165,
4825 .name = "Marvell 88E6161",
4826 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004827 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004828 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004829 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004830 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004831 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004832 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004833 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004834 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004835 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004836 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004837 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004838 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004839 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004840 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004841 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004842 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004843 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004844 },
4845
4846 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004847 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004848 .family = MV88E6XXX_FAMILY_6165,
4849 .name = "Marvell 88E6165",
4850 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004851 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004852 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004853 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004854 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004855 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004856 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004857 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004858 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004859 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004860 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004861 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004862 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004863 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004864 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004865 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004866 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004867 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004868 },
4869
4870 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004871 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004872 .family = MV88E6XXX_FAMILY_6351,
4873 .name = "Marvell 88E6171",
4874 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004875 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004876 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004877 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004878 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004879 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004880 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004881 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004882 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004883 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004884 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004885 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004886 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004887 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004888 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004889 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004890 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004891 },
4892
4893 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004894 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004895 .family = MV88E6XXX_FAMILY_6352,
4896 .name = "Marvell 88E6172",
4897 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004898 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004899 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004900 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004901 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004902 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004903 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004904 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004905 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004906 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004907 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004908 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004909 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004910 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004911 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004912 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004913 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004914 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004915 },
4916
4917 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004918 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004919 .family = MV88E6XXX_FAMILY_6351,
4920 .name = "Marvell 88E6175",
4921 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004922 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004923 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004924 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004925 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004926 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004927 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004928 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004929 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004930 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004931 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004932 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004933 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004934 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004935 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004936 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004937 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004938 },
4939
4940 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004941 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004942 .family = MV88E6XXX_FAMILY_6352,
4943 .name = "Marvell 88E6176",
4944 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004945 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004946 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004947 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004948 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004949 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004950 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004951 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004952 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004953 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004954 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004955 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004956 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004957 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004958 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004959 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004960 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004961 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004962 },
4963
4964 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004965 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004966 .family = MV88E6XXX_FAMILY_6185,
4967 .name = "Marvell 88E6185",
4968 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004969 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004970 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004971 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004972 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004973 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004974 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004975 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004976 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004977 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004978 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004979 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004980 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004981 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004982 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004983 },
4984
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004985 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004986 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004987 .family = MV88E6XXX_FAMILY_6390,
4988 .name = "Marvell 88E6190",
4989 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004990 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004991 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004992 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004993 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004994 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004995 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004996 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004997 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004998 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004999 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005000 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005001 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005002 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04005003 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005004 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05005005 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005006 .ops = &mv88e6190_ops,
5007 },
5008
5009 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005010 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005011 .family = MV88E6XXX_FAMILY_6390,
5012 .name = "Marvell 88E6190X",
5013 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005014 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005015 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005016 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005017 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005018 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005019 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005020 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005021 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005022 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005023 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005024 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005025 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005026 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005027 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005028 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005029 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005030 .ops = &mv88e6190x_ops,
5031 },
5032
5033 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005034 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005035 .family = MV88E6XXX_FAMILY_6390,
5036 .name = "Marvell 88E6191",
5037 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005038 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005039 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005040 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005041 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005042 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005043 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005044 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005045 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005046 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005047 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005048 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005049 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005050 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005051 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005052 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005053 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005054 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005055 },
5056
Pavana Sharmade776d02021-03-17 14:46:42 +01005057 [MV88E6191X] = {
5058 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191X,
5059 .family = MV88E6XXX_FAMILY_6393,
5060 .name = "Marvell 88E6191X",
5061 .num_databases = 4096,
5062 .num_ports = 11, /* 10 + Z80 */
5063 .num_internal_phys = 9,
5064 .max_vid = 8191,
5065 .port_base_addr = 0x0,
5066 .phy_base_addr = 0x0,
5067 .global1_addr = 0x1b,
5068 .global2_addr = 0x1c,
5069 .age_time_coeff = 3750,
5070 .g1_irqs = 10,
5071 .g2_irqs = 14,
5072 .atu_move_port_mask = 0x1f,
5073 .pvt = true,
5074 .multi_chip = true,
5075 .tag_protocol = DSA_TAG_PROTO_DSA,
5076 .ptp_support = true,
5077 .ops = &mv88e6393x_ops,
5078 },
5079
5080 [MV88E6193X] = {
5081 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6193X,
5082 .family = MV88E6XXX_FAMILY_6393,
5083 .name = "Marvell 88E6193X",
5084 .num_databases = 4096,
5085 .num_ports = 11, /* 10 + Z80 */
5086 .num_internal_phys = 9,
5087 .max_vid = 8191,
5088 .port_base_addr = 0x0,
5089 .phy_base_addr = 0x0,
5090 .global1_addr = 0x1b,
5091 .global2_addr = 0x1c,
5092 .age_time_coeff = 3750,
5093 .g1_irqs = 10,
5094 .g2_irqs = 14,
5095 .atu_move_port_mask = 0x1f,
5096 .pvt = true,
5097 .multi_chip = true,
5098 .tag_protocol = DSA_TAG_PROTO_DSA,
5099 .ptp_support = true,
5100 .ops = &mv88e6393x_ops,
5101 },
5102
Hubert Feurstein49022642019-07-31 10:23:46 +02005103 [MV88E6220] = {
5104 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5105 .family = MV88E6XXX_FAMILY_6250,
5106 .name = "Marvell 88E6220",
5107 .num_databases = 64,
5108
5109 /* Ports 2-4 are not routed to pins
5110 * => usable ports 0, 1, 5, 6
5111 */
5112 .num_ports = 7,
5113 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005114 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005115 .max_vid = 4095,
5116 .port_base_addr = 0x08,
5117 .phy_base_addr = 0x00,
5118 .global1_addr = 0x0f,
5119 .global2_addr = 0x07,
5120 .age_time_coeff = 15000,
5121 .g1_irqs = 9,
5122 .g2_irqs = 10,
5123 .atu_move_port_mask = 0xf,
5124 .dual_chip = true,
5125 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005126 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005127 .ops = &mv88e6250_ops,
5128 },
5129
Vivien Didelotf81ec902016-05-09 13:22:58 -04005130 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005131 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005132 .family = MV88E6XXX_FAMILY_6352,
5133 .name = "Marvell 88E6240",
5134 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005135 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005136 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005137 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005138 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005139 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005140 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005141 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005142 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005143 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005144 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005145 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005146 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005147 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005148 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005149 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005150 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005151 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005152 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005153 },
5154
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005155 [MV88E6250] = {
5156 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5157 .family = MV88E6XXX_FAMILY_6250,
5158 .name = "Marvell 88E6250",
5159 .num_databases = 64,
5160 .num_ports = 7,
5161 .num_internal_phys = 5,
5162 .max_vid = 4095,
5163 .port_base_addr = 0x08,
5164 .phy_base_addr = 0x00,
5165 .global1_addr = 0x0f,
5166 .global2_addr = 0x07,
5167 .age_time_coeff = 15000,
5168 .g1_irqs = 9,
5169 .g2_irqs = 10,
5170 .atu_move_port_mask = 0xf,
5171 .dual_chip = true,
5172 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005173 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005174 .ops = &mv88e6250_ops,
5175 },
5176
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005177 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005178 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005179 .family = MV88E6XXX_FAMILY_6390,
5180 .name = "Marvell 88E6290",
5181 .num_databases = 4096,
5182 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005183 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005184 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005185 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005186 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005187 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005188 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005189 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005190 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005191 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005192 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005193 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005194 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005195 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005196 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005197 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005198 .ops = &mv88e6290_ops,
5199 },
5200
Vivien Didelotf81ec902016-05-09 13:22:58 -04005201 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005202 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005203 .family = MV88E6XXX_FAMILY_6320,
5204 .name = "Marvell 88E6320",
5205 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005206 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005207 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005208 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005209 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005210 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005211 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005212 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005213 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005214 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005215 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005216 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005217 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005218 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005219 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005220 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005221 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005222 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005223 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005224 },
5225
5226 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005227 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005228 .family = MV88E6XXX_FAMILY_6320,
5229 .name = "Marvell 88E6321",
5230 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005231 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005232 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005233 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005234 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005235 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005236 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005237 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005238 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005239 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005240 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005241 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005242 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005243 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005244 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005245 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005246 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005247 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005248 },
5249
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005250 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005251 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005252 .family = MV88E6XXX_FAMILY_6341,
5253 .name = "Marvell 88E6341",
5254 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005255 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005256 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005257 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005258 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005259 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005260 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005261 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005262 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005263 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005264 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005265 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005266 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005267 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005268 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005269 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005270 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005271 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005272 .ops = &mv88e6341_ops,
5273 },
5274
Vivien Didelotf81ec902016-05-09 13:22:58 -04005275 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005276 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005277 .family = MV88E6XXX_FAMILY_6351,
5278 .name = "Marvell 88E6350",
5279 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005280 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005281 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005282 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005283 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005284 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005285 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005286 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005287 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005288 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005289 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005290 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005291 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005292 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005293 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005294 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005295 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005296 },
5297
5298 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005299 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005300 .family = MV88E6XXX_FAMILY_6351,
5301 .name = "Marvell 88E6351",
5302 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005303 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005304 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005305 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005306 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005307 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005308 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005309 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005310 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005311 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005312 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005313 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005314 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005315 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005316 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005317 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005318 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005319 },
5320
5321 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005322 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005323 .family = MV88E6XXX_FAMILY_6352,
5324 .name = "Marvell 88E6352",
5325 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005326 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005327 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005328 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005329 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005330 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005331 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005332 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005333 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005334 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005335 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005336 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005337 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005338 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005339 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005340 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005341 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005342 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005343 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005344 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005345 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005346 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005347 .family = MV88E6XXX_FAMILY_6390,
5348 .name = "Marvell 88E6390",
5349 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005350 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005351 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005352 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005353 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005354 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005355 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005356 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005357 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005358 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005359 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005360 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005361 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005362 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005363 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005364 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005365 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005366 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005367 .ops = &mv88e6390_ops,
5368 },
5369 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005370 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005371 .family = MV88E6XXX_FAMILY_6390,
5372 .name = "Marvell 88E6390X",
5373 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005374 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005375 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005376 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005377 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005378 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005379 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005380 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005381 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005382 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005383 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005384 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005385 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005386 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005387 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005388 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005389 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005390 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005391 .ops = &mv88e6390x_ops,
5392 },
Pavana Sharmade776d02021-03-17 14:46:42 +01005393
5394 [MV88E6393X] = {
5395 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6393X,
5396 .family = MV88E6XXX_FAMILY_6393,
5397 .name = "Marvell 88E6393X",
5398 .num_databases = 4096,
5399 .num_ports = 11, /* 10 + Z80 */
5400 .num_internal_phys = 9,
5401 .max_vid = 8191,
5402 .port_base_addr = 0x0,
5403 .phy_base_addr = 0x0,
5404 .global1_addr = 0x1b,
5405 .global2_addr = 0x1c,
5406 .age_time_coeff = 3750,
5407 .g1_irqs = 10,
5408 .g2_irqs = 14,
5409 .atu_move_port_mask = 0x1f,
5410 .pvt = true,
5411 .multi_chip = true,
5412 .tag_protocol = DSA_TAG_PROTO_DSA,
5413 .ptp_support = true,
5414 .ops = &mv88e6393x_ops,
5415 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005416};
5417
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005418static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005419{
Vivien Didelota439c062016-04-17 13:23:58 -04005420 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005421
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005422 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5423 if (mv88e6xxx_table[i].prod_num == prod_num)
5424 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005425
Vivien Didelotb9b37712015-10-30 19:39:48 -04005426 return NULL;
5427}
5428
Vivien Didelotfad09c72016-06-21 12:28:20 -04005429static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005430{
5431 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005432 unsigned int prod_num, rev;
5433 u16 id;
5434 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005435
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005436 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005437 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005438 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005439 if (err)
5440 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005441
Vivien Didelot107fcc12017-06-12 12:37:36 -04005442 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5443 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005444
5445 info = mv88e6xxx_lookup_info(prod_num);
5446 if (!info)
5447 return -ENODEV;
5448
Vivien Didelotcaac8542016-06-20 13:14:09 -04005449 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005450 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005451
Vivien Didelotfad09c72016-06-21 12:28:20 -04005452 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5453 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005454
5455 return 0;
5456}
5457
Vivien Didelotfad09c72016-06-21 12:28:20 -04005458static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005459{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005460 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005461
Vivien Didelotfad09c72016-06-21 12:28:20 -04005462 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5463 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005464 return NULL;
5465
Vivien Didelotfad09c72016-06-21 12:28:20 -04005466 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005467
Vivien Didelotfad09c72016-06-21 12:28:20 -04005468 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005469 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005470 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005471
Vivien Didelotfad09c72016-06-21 12:28:20 -04005472 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005473}
5474
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005475static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005476 int port,
5477 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005478{
Vivien Didelot04bed142016-08-31 18:06:13 -04005479 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005480
Andrew Lunn443d5a12016-12-03 04:35:18 +01005481 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005482}
5483
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005484static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
5485 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005486{
Vivien Didelot04bed142016-08-31 18:06:13 -04005487 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005488 int err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005489
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005490 mv88e6xxx_reg_lock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005491 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
5492 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005493 mv88e6xxx_reg_unlock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005494
5495 return err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005496}
5497
5498static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5499 const struct switchdev_obj_port_mdb *mdb)
5500{
Vivien Didelot04bed142016-08-31 18:06:13 -04005501 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005502 int err;
5503
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005504 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005505 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005506 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005507
5508 return err;
5509}
5510
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005511static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5512 struct dsa_mall_mirror_tc_entry *mirror,
5513 bool ingress)
5514{
5515 enum mv88e6xxx_egress_direction direction = ingress ?
5516 MV88E6XXX_EGRESS_DIR_INGRESS :
5517 MV88E6XXX_EGRESS_DIR_EGRESS;
5518 struct mv88e6xxx_chip *chip = ds->priv;
5519 bool other_mirrors = false;
5520 int i;
5521 int err;
5522
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005523 mutex_lock(&chip->reg_lock);
5524 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5525 mirror->to_local_port) {
5526 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5527 other_mirrors |= ingress ?
5528 chip->ports[i].mirror_ingress :
5529 chip->ports[i].mirror_egress;
5530
5531 /* Can't change egress port when other mirror is active */
5532 if (other_mirrors) {
5533 err = -EBUSY;
5534 goto out;
5535 }
5536
Marek Behún2fda45f2021-03-17 14:46:41 +01005537 err = mv88e6xxx_set_egress_port(chip, direction,
5538 mirror->to_local_port);
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005539 if (err)
5540 goto out;
5541 }
5542
5543 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5544out:
5545 mutex_unlock(&chip->reg_lock);
5546
5547 return err;
5548}
5549
5550static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5551 struct dsa_mall_mirror_tc_entry *mirror)
5552{
5553 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5554 MV88E6XXX_EGRESS_DIR_INGRESS :
5555 MV88E6XXX_EGRESS_DIR_EGRESS;
5556 struct mv88e6xxx_chip *chip = ds->priv;
5557 bool other_mirrors = false;
5558 int i;
5559
5560 mutex_lock(&chip->reg_lock);
5561 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5562 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5563
5564 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5565 other_mirrors |= mirror->ingress ?
5566 chip->ports[i].mirror_ingress :
5567 chip->ports[i].mirror_egress;
5568
5569 /* Reset egress port when no other mirror is active */
5570 if (!other_mirrors) {
Marek Behún2fda45f2021-03-17 14:46:41 +01005571 if (mv88e6xxx_set_egress_port(chip, direction,
5572 dsa_upstream_port(ds, port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005573 dev_err(ds->dev, "failed to set egress port\n");
5574 }
5575
5576 mutex_unlock(&chip->reg_lock);
5577}
5578
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005579static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port,
5580 struct switchdev_brport_flags flags,
5581 struct netlink_ext_ack *extack)
5582{
5583 struct mv88e6xxx_chip *chip = ds->priv;
5584 const struct mv88e6xxx_ops *ops;
5585
5586 if (flags.mask & ~(BR_FLOOD | BR_MCAST_FLOOD))
5587 return -EINVAL;
5588
5589 ops = chip->info->ops;
5590
5591 if ((flags.mask & BR_FLOOD) && !ops->port_set_ucast_flood)
5592 return -EINVAL;
5593
5594 if ((flags.mask & BR_MCAST_FLOOD) && !ops->port_set_mcast_flood)
5595 return -EINVAL;
5596
5597 return 0;
5598}
5599
5600static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port,
5601 struct switchdev_brport_flags flags,
5602 struct netlink_ext_ack *extack)
Russell King4f859012019-02-20 15:35:05 -08005603{
5604 struct mv88e6xxx_chip *chip = ds->priv;
5605 int err = -EOPNOTSUPP;
5606
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005607 mv88e6xxx_reg_lock(chip);
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005608
5609 if (flags.mask & BR_FLOOD) {
5610 bool unicast = !!(flags.val & BR_FLOOD);
5611
5612 err = chip->info->ops->port_set_ucast_flood(chip, port,
5613 unicast);
5614 if (err)
5615 goto out;
5616 }
5617
5618 if (flags.mask & BR_MCAST_FLOOD) {
5619 bool multicast = !!(flags.val & BR_MCAST_FLOOD);
5620
5621 err = chip->info->ops->port_set_mcast_flood(chip, port,
5622 multicast);
5623 if (err)
5624 goto out;
5625 }
5626
5627out:
5628 mv88e6xxx_reg_unlock(chip);
5629
5630 return err;
5631}
5632
5633static int mv88e6xxx_port_set_mrouter(struct dsa_switch *ds, int port,
5634 bool mrouter,
5635 struct netlink_ext_ack *extack)
5636{
5637 struct mv88e6xxx_chip *chip = ds->priv;
5638 int err;
5639
5640 if (!chip->info->ops->port_set_mcast_flood)
5641 return -EOPNOTSUPP;
5642
5643 mv88e6xxx_reg_lock(chip);
5644 err = chip->info->ops->port_set_mcast_flood(chip, port, mrouter);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005645 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005646
5647 return err;
5648}
5649
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005650static bool mv88e6xxx_lag_can_offload(struct dsa_switch *ds,
5651 struct net_device *lag,
5652 struct netdev_lag_upper_info *info)
5653{
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01005654 struct mv88e6xxx_chip *chip = ds->priv;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005655 struct dsa_port *dp;
5656 int id, members = 0;
5657
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01005658 if (!mv88e6xxx_has_lag(chip))
5659 return false;
5660
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005661 id = dsa_lag_id(ds->dst, lag);
5662 if (id < 0 || id >= ds->num_lag_ids)
5663 return false;
5664
5665 dsa_lag_foreach_port(dp, ds->dst, lag)
5666 /* Includes the port joining the LAG */
5667 members++;
5668
5669 if (members > 8)
5670 return false;
5671
5672 /* We could potentially relax this to include active
5673 * backup in the future.
5674 */
5675 if (info->tx_type != NETDEV_LAG_TX_TYPE_HASH)
5676 return false;
5677
5678 /* Ideally we would also validate that the hash type matches
5679 * the hardware. Alas, this is always set to unknown on team
5680 * interfaces.
5681 */
5682 return true;
5683}
5684
5685static int mv88e6xxx_lag_sync_map(struct dsa_switch *ds, struct net_device *lag)
5686{
5687 struct mv88e6xxx_chip *chip = ds->priv;
5688 struct dsa_port *dp;
5689 u16 map = 0;
5690 int id;
5691
5692 id = dsa_lag_id(ds->dst, lag);
5693
5694 /* Build the map of all ports to distribute flows destined for
5695 * this LAG. This can be either a local user port, or a DSA
5696 * port if the LAG port is on a remote chip.
5697 */
5698 dsa_lag_foreach_port(dp, ds->dst, lag)
5699 map |= BIT(dsa_towards_port(ds, dp->ds->index, dp->index));
5700
5701 return mv88e6xxx_g2_trunk_mapping_write(chip, id, map);
5702}
5703
5704static const u8 mv88e6xxx_lag_mask_table[8][8] = {
5705 /* Row number corresponds to the number of active members in a
5706 * LAG. Each column states which of the eight hash buckets are
5707 * mapped to the column:th port in the LAG.
5708 *
5709 * Example: In a LAG with three active ports, the second port
5710 * ([2][1]) would be selected for traffic mapped to buckets
5711 * 3,4,5 (0x38).
5712 */
5713 { 0xff, 0, 0, 0, 0, 0, 0, 0 },
5714 { 0x0f, 0xf0, 0, 0, 0, 0, 0, 0 },
5715 { 0x07, 0x38, 0xc0, 0, 0, 0, 0, 0 },
5716 { 0x03, 0x0c, 0x30, 0xc0, 0, 0, 0, 0 },
5717 { 0x03, 0x0c, 0x30, 0x40, 0x80, 0, 0, 0 },
5718 { 0x03, 0x0c, 0x10, 0x20, 0x40, 0x80, 0, 0 },
5719 { 0x03, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0 },
5720 { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 },
5721};
5722
5723static void mv88e6xxx_lag_set_port_mask(u16 *mask, int port,
5724 int num_tx, int nth)
5725{
5726 u8 active = 0;
5727 int i;
5728
5729 num_tx = num_tx <= 8 ? num_tx : 8;
5730 if (nth < num_tx)
5731 active = mv88e6xxx_lag_mask_table[num_tx - 1][nth];
5732
5733 for (i = 0; i < 8; i++) {
5734 if (BIT(i) & active)
5735 mask[i] |= BIT(port);
5736 }
5737}
5738
5739static int mv88e6xxx_lag_sync_masks(struct dsa_switch *ds)
5740{
5741 struct mv88e6xxx_chip *chip = ds->priv;
5742 unsigned int id, num_tx;
5743 struct net_device *lag;
5744 struct dsa_port *dp;
5745 int i, err, nth;
5746 u16 mask[8];
5747 u16 ivec;
5748
5749 /* Assume no port is a member of any LAG. */
5750 ivec = BIT(mv88e6xxx_num_ports(chip)) - 1;
5751
5752 /* Disable all masks for ports that _are_ members of a LAG. */
5753 list_for_each_entry(dp, &ds->dst->ports, list) {
5754 if (!dp->lag_dev || dp->ds != ds)
5755 continue;
5756
5757 ivec &= ~BIT(dp->index);
5758 }
5759
5760 for (i = 0; i < 8; i++)
5761 mask[i] = ivec;
5762
5763 /* Enable the correct subset of masks for all LAG ports that
5764 * are in the Tx set.
5765 */
5766 dsa_lags_foreach_id(id, ds->dst) {
5767 lag = dsa_lag_dev(ds->dst, id);
5768 if (!lag)
5769 continue;
5770
5771 num_tx = 0;
5772 dsa_lag_foreach_port(dp, ds->dst, lag) {
5773 if (dp->lag_tx_enabled)
5774 num_tx++;
5775 }
5776
5777 if (!num_tx)
5778 continue;
5779
5780 nth = 0;
5781 dsa_lag_foreach_port(dp, ds->dst, lag) {
5782 if (!dp->lag_tx_enabled)
5783 continue;
5784
5785 if (dp->ds == ds)
5786 mv88e6xxx_lag_set_port_mask(mask, dp->index,
5787 num_tx, nth);
5788
5789 nth++;
5790 }
5791 }
5792
5793 for (i = 0; i < 8; i++) {
5794 err = mv88e6xxx_g2_trunk_mask_write(chip, i, true, mask[i]);
5795 if (err)
5796 return err;
5797 }
5798
5799 return 0;
5800}
5801
5802static int mv88e6xxx_lag_sync_masks_map(struct dsa_switch *ds,
5803 struct net_device *lag)
5804{
5805 int err;
5806
5807 err = mv88e6xxx_lag_sync_masks(ds);
5808
5809 if (!err)
5810 err = mv88e6xxx_lag_sync_map(ds, lag);
5811
5812 return err;
5813}
5814
5815static int mv88e6xxx_port_lag_change(struct dsa_switch *ds, int port)
5816{
5817 struct mv88e6xxx_chip *chip = ds->priv;
5818 int err;
5819
5820 mv88e6xxx_reg_lock(chip);
5821 err = mv88e6xxx_lag_sync_masks(ds);
5822 mv88e6xxx_reg_unlock(chip);
5823 return err;
5824}
5825
5826static int mv88e6xxx_port_lag_join(struct dsa_switch *ds, int port,
5827 struct net_device *lag,
5828 struct netdev_lag_upper_info *info)
5829{
5830 struct mv88e6xxx_chip *chip = ds->priv;
5831 int err, id;
5832
5833 if (!mv88e6xxx_lag_can_offload(ds, lag, info))
5834 return -EOPNOTSUPP;
5835
5836 id = dsa_lag_id(ds->dst, lag);
5837
5838 mv88e6xxx_reg_lock(chip);
5839
5840 err = mv88e6xxx_port_set_trunk(chip, port, true, id);
5841 if (err)
5842 goto err_unlock;
5843
5844 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
5845 if (err)
5846 goto err_clear_trunk;
5847
5848 mv88e6xxx_reg_unlock(chip);
5849 return 0;
5850
5851err_clear_trunk:
5852 mv88e6xxx_port_set_trunk(chip, port, false, 0);
5853err_unlock:
5854 mv88e6xxx_reg_unlock(chip);
5855 return err;
5856}
5857
5858static int mv88e6xxx_port_lag_leave(struct dsa_switch *ds, int port,
5859 struct net_device *lag)
5860{
5861 struct mv88e6xxx_chip *chip = ds->priv;
5862 int err_sync, err_trunk;
5863
5864 mv88e6xxx_reg_lock(chip);
5865 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
5866 err_trunk = mv88e6xxx_port_set_trunk(chip, port, false, 0);
5867 mv88e6xxx_reg_unlock(chip);
5868 return err_sync ? : err_trunk;
5869}
5870
5871static int mv88e6xxx_crosschip_lag_change(struct dsa_switch *ds, int sw_index,
5872 int port)
5873{
5874 struct mv88e6xxx_chip *chip = ds->priv;
5875 int err;
5876
5877 mv88e6xxx_reg_lock(chip);
5878 err = mv88e6xxx_lag_sync_masks(ds);
5879 mv88e6xxx_reg_unlock(chip);
5880 return err;
5881}
5882
5883static int mv88e6xxx_crosschip_lag_join(struct dsa_switch *ds, int sw_index,
5884 int port, struct net_device *lag,
5885 struct netdev_lag_upper_info *info)
5886{
5887 struct mv88e6xxx_chip *chip = ds->priv;
5888 int err;
5889
5890 if (!mv88e6xxx_lag_can_offload(ds, lag, info))
5891 return -EOPNOTSUPP;
5892
5893 mv88e6xxx_reg_lock(chip);
5894
5895 err = mv88e6xxx_lag_sync_masks_map(ds, lag);
5896 if (err)
5897 goto unlock;
5898
5899 err = mv88e6xxx_pvt_map(chip, sw_index, port);
5900
5901unlock:
5902 mv88e6xxx_reg_unlock(chip);
5903 return err;
5904}
5905
5906static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index,
5907 int port, struct net_device *lag)
5908{
5909 struct mv88e6xxx_chip *chip = ds->priv;
5910 int err_sync, err_pvt;
5911
5912 mv88e6xxx_reg_lock(chip);
5913 err_sync = mv88e6xxx_lag_sync_masks_map(ds, lag);
5914 err_pvt = mv88e6xxx_pvt_map(chip, sw_index, port);
5915 mv88e6xxx_reg_unlock(chip);
5916 return err_sync ? : err_pvt;
5917}
5918
Florian Fainellia82f67a2017-01-08 14:52:08 -08005919static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005920 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005921 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005922 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005923 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005924 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005925 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005926 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005927 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5928 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005929 .get_strings = mv88e6xxx_get_strings,
5930 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5931 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005932 .port_enable = mv88e6xxx_port_enable,
5933 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02005934 .port_max_mtu = mv88e6xxx_get_max_mtu,
5935 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04005936 .get_mac_eee = mv88e6xxx_get_mac_eee,
5937 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005938 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005939 .get_eeprom = mv88e6xxx_get_eeprom,
5940 .set_eeprom = mv88e6xxx_set_eeprom,
5941 .get_regs_len = mv88e6xxx_get_regs_len,
5942 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005943 .get_rxnfc = mv88e6xxx_get_rxnfc,
5944 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005945 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005946 .port_bridge_join = mv88e6xxx_port_bridge_join,
5947 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Vladimir Olteana8b659e2021-02-12 17:15:56 +02005948 .port_pre_bridge_flags = mv88e6xxx_port_pre_bridge_flags,
5949 .port_bridge_flags = mv88e6xxx_port_bridge_flags,
5950 .port_set_mrouter = mv88e6xxx_port_set_mrouter,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005951 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005952 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005953 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005954 .port_vlan_add = mv88e6xxx_port_vlan_add,
5955 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005956 .port_fdb_add = mv88e6xxx_port_fdb_add,
5957 .port_fdb_del = mv88e6xxx_port_fdb_del,
5958 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005959 .port_mdb_add = mv88e6xxx_port_mdb_add,
5960 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005961 .port_mirror_add = mv88e6xxx_port_mirror_add,
5962 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005963 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5964 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005965 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5966 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5967 .port_txtstamp = mv88e6xxx_port_txtstamp,
5968 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5969 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005970 .devlink_param_get = mv88e6xxx_devlink_param_get,
5971 .devlink_param_set = mv88e6xxx_devlink_param_set,
Andrew Lunn93157302020-09-18 21:11:09 +02005972 .devlink_info_get = mv88e6xxx_devlink_info_get,
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005973 .port_lag_change = mv88e6xxx_port_lag_change,
5974 .port_lag_join = mv88e6xxx_port_lag_join,
5975 .port_lag_leave = mv88e6xxx_port_lag_leave,
5976 .crosschip_lag_change = mv88e6xxx_crosschip_lag_change,
5977 .crosschip_lag_join = mv88e6xxx_crosschip_lag_join,
5978 .crosschip_lag_leave = mv88e6xxx_crosschip_lag_leave,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005979};
5980
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005981static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005982{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005983 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005984 struct dsa_switch *ds;
5985
Vivien Didelot7e99e342019-10-21 16:51:30 -04005986 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005987 if (!ds)
5988 return -ENOMEM;
5989
Vivien Didelot7e99e342019-10-21 16:51:30 -04005990 ds->dev = dev;
5991 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005992 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005993 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005994 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005995 ds->ageing_time_min = chip->info->age_time_coeff;
5996 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005997
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01005998 /* Some chips support up to 32, but that requires enabling the
5999 * 5-bit port mode, which we do not support. 640k^W16 ought to
6000 * be enough for anyone.
6001 */
Tobias Waldekranzb80dc512021-01-15 13:52:59 +01006002 ds->num_lag_ids = mv88e6xxx_has_lag(chip) ? 16 : 0;
Tobias Waldekranz57e661a2021-01-13 09:42:54 +01006003
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006004 dev_set_drvdata(dev, ds);
6005
Vivien Didelot23c9ee42017-05-26 18:12:51 -04006006 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006007}
6008
Vivien Didelotfad09c72016-06-21 12:28:20 -04006009static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006010{
Vivien Didelotfad09c72016-06-21 12:28:20 -04006011 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04006012}
6013
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006014static const void *pdata_device_get_match_data(struct device *dev)
6015{
6016 const struct of_device_id *matches = dev->driver->of_match_table;
6017 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
6018
6019 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
6020 matches++) {
6021 if (!strcmp(pdata->compatible, matches->compatible))
6022 return matches->data;
6023 }
6024 return NULL;
6025}
6026
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01006027/* There is no suspend to RAM support at DSA level yet, the switch configuration
6028 * would be lost after a power cycle so prevent it to be suspended.
6029 */
6030static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
6031{
6032 return -EOPNOTSUPP;
6033}
6034
6035static int __maybe_unused mv88e6xxx_resume(struct device *dev)
6036{
6037 return 0;
6038}
6039
6040static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
6041
Vivien Didelot57d32312016-06-20 13:13:58 -04006042static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006043{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006044 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04006045 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006046 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006047 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04006048 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006049 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02006050 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006051
Andrew Lunn7bb8c992018-05-31 00:15:42 +02006052 if (!np && !pdata)
6053 return -EINVAL;
6054
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006055 if (np)
6056 compat_info = of_device_get_match_data(dev);
6057
6058 if (pdata) {
6059 compat_info = pdata_device_get_match_data(dev);
6060
6061 if (!pdata->netdev)
6062 return -EINVAL;
6063
6064 for (port = 0; port < DSA_MAX_PORTS; port++) {
6065 if (!(pdata->enabled_ports & (1 << port)))
6066 continue;
6067 if (strcmp(pdata->cd.port_names[port], "cpu"))
6068 continue;
6069 pdata->cd.netdev[port] = &pdata->netdev->dev;
6070 break;
6071 }
6072 }
6073
Vivien Didelotcaac8542016-06-20 13:14:09 -04006074 if (!compat_info)
6075 return -EINVAL;
6076
Vivien Didelotfad09c72016-06-21 12:28:20 -04006077 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006078 if (!chip) {
6079 err = -ENOMEM;
6080 goto out;
6081 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006082
Vivien Didelotfad09c72016-06-21 12:28:20 -04006083 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04006084
Vivien Didelotfad09c72016-06-21 12:28:20 -04006085 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04006086 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006087 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006088
Andrew Lunnb4308f02016-11-21 23:26:55 +01006089 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006090 if (IS_ERR(chip->reset)) {
6091 err = PTR_ERR(chip->reset);
6092 goto out;
6093 }
Baruch Siach7b75e492019-06-27 21:17:39 +03006094 if (chip->reset)
6095 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01006096
Vivien Didelotfad09c72016-06-21 12:28:20 -04006097 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04006098 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006099 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006100
Vivien Didelote57e5e72016-08-15 17:19:00 -04006101 mv88e6xxx_phy_init(chip);
6102
Andrew Lunn00baabe2018-05-19 22:31:35 +02006103 if (chip->info->ops->get_eeprom) {
6104 if (np)
6105 of_property_read_u32(np, "eeprom-length",
6106 &chip->eeprom_len);
6107 else
6108 chip->eeprom_len = pdata->eeprom_len;
6109 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02006110
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006111 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006112 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006113 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02006114 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02006115 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02006116
Andrew Lunna27415d2019-05-01 00:10:50 +02006117 if (np) {
6118 chip->irq = of_irq_get(np, 0);
6119 if (chip->irq == -EPROBE_DEFER) {
6120 err = chip->irq;
6121 goto out;
6122 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02006123 }
6124
Andrew Lunna27415d2019-05-01 00:10:50 +02006125 if (pdata)
6126 chip->irq = pdata->irq;
6127
Andrew Lunn294d7112018-02-22 22:58:32 +01006128 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01006129 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01006130 * controllers
6131 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006132 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006133 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02006134 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006135 else
6136 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00006137 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006138
Andrew Lunn294d7112018-02-22 22:58:32 +01006139 if (err)
6140 goto out;
6141
6142 if (chip->info->g2_irqs > 0) {
6143 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006144 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01006145 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02006146 }
6147
Andrew Lunn294d7112018-02-22 22:58:32 +01006148 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
6149 if (err)
6150 goto out_g2_irq;
6151
6152 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
6153 if (err)
6154 goto out_g1_atu_prob_irq;
6155
Andrew Lunna3c53be52017-01-24 14:53:50 +01006156 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02006157 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01006158 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02006159
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08006160 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006161 if (err)
6162 goto out_mdio;
6163
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006164 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02006165
6166out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01006167 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01006168out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006169 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01006170out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006171 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006172out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006173 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02006174 mv88e6xxx_g2_irq_free(chip);
6175out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01006176 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01006177 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01006178 else
6179 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006180out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02006181 if (pdata)
6182 dev_put(pdata->netdev);
6183
Andrew Lunndc30c352016-10-16 19:56:49 +02006184 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006185}
6186
6187static void mv88e6xxx_remove(struct mdio_device *mdiodev)
6188{
6189 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04006190 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006191
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006192 if (chip->info->ptp_support) {
6193 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01006194 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01006195 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01006196
Andrew Lunn930188c2016-08-22 16:01:03 +02006197 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04006198 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01006199 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02006200
Andrew Lunn76f38f12018-03-17 20:21:09 +01006201 mv88e6xxx_g1_vtu_prob_irq_free(chip);
6202 mv88e6xxx_g1_atu_prob_irq_free(chip);
6203
6204 if (chip->info->g2_irqs > 0)
6205 mv88e6xxx_g2_irq_free(chip);
6206
Andrew Lunn76f38f12018-03-17 20:21:09 +01006207 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01006208 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01006209 else
6210 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006211}
6212
6213static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04006214 {
6215 .compatible = "marvell,mv88e6085",
6216 .data = &mv88e6xxx_table[MV88E6085],
6217 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01006218 {
6219 .compatible = "marvell,mv88e6190",
6220 .data = &mv88e6xxx_table[MV88E6190],
6221 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00006222 {
6223 .compatible = "marvell,mv88e6250",
6224 .data = &mv88e6xxx_table[MV88E6250],
6225 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006226 { /* sentinel */ },
6227};
6228
6229MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
6230
6231static struct mdio_driver mv88e6xxx_driver = {
6232 .probe = mv88e6xxx_probe,
6233 .remove = mv88e6xxx_remove,
6234 .mdiodrv.driver = {
6235 .name = "mv88e6085",
6236 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01006237 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02006238 },
6239};
6240
Andrew Lunn7324d502019-04-27 19:19:10 +02006241mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00006242
6243MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
6244MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
6245MODULE_LICENSE("GPL");