blob: e9c517c0f89c3ac36cd9f0ac55ef419f39823746 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00002/*
Vivien Didelot0d3cd4b2016-06-21 12:28:19 -04003 * Marvell 88e6xxx Ethernet switch single-chip support
4 *
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00005 * Copyright (c) 2008 Marvell Semiconductor
6 *
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02007 * Copyright (c) 2016 Andrew Lunn <andrew@lunn.ch>
8 *
Vivien Didelot4333d612017-03-28 15:10:36 -04009 * Copyright (c) 2016-2017 Savoir-faire Linux Inc.
10 * Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000011 */
12
Vivien Didelot19fb7f62019-08-09 18:47:55 -040013#include <linux/bitfield.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000014#include <linux/delay.h>
Guenter Roeckdefb05b2015-03-26 18:36:38 -070015#include <linux/etherdevice.h>
Andrew Lunndea87022015-08-31 15:56:47 +020016#include <linux/ethtool.h>
Guenter Roeckfacd95b2015-03-26 18:36:35 -070017#include <linux/if_bridge.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020018#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <linux/irqdomain.h>
Barry Grussling19b2f972013-01-08 16:05:54 +000021#include <linux/jiffies.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000022#include <linux/list.h>
Andrew Lunn14c7b3c2016-05-10 23:27:21 +020023#include <linux/mdio.h>
Paul Gortmaker2bbba272012-01-24 10:41:40 +000024#include <linux/module.h>
Vivien Didelotcaac8542016-06-20 13:14:09 -040025#include <linux/of_device.h>
Andrew Lunndc30c352016-10-16 19:56:49 +020026#include <linux/of_irq.h>
Andrew Lunnb516d452016-06-04 21:17:06 +020027#include <linux/of_mdio.h>
Andrew Lunn877b7cb2018-05-19 22:31:34 +020028#include <linux/platform_data/mv88e6xxx.h>
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000029#include <linux/netdevice.h>
Andrew Lunnc8c1b39a2015-11-20 03:56:24 +010030#include <linux/gpio/consumer.h>
Russell Kingc9a23562018-05-10 13:17:35 -070031#include <linux/phylink.h>
Ben Hutchingsc8f0b862011-11-27 17:06:08 +000032#include <net/dsa.h>
Vivien Didelotec561272016-09-02 14:45:33 -040033
Vivien Didelot4d5f2ba72017-06-02 17:06:15 -040034#include "chip.h"
Andrew Lunn9dd43aa2020-09-18 21:11:05 +020035#include "devlink.h"
Vivien Didelota935c052016-09-29 12:21:53 -040036#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040037#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010038#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020039#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010040#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010041#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020042#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040043#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000044
Vivien Didelotfad09c72016-06-21 12:28:20 -040045static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040046{
Vivien Didelotfad09c72016-06-21 12:28:20 -040047 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
48 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040049 dump_stack();
50 }
51}
52
Vivien Didelotec561272016-09-02 14:45:33 -040053int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040054{
55 int err;
56
Vivien Didelotfad09c72016-06-21 12:28:20 -040057 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040058
Vivien Didelotfad09c72016-06-21 12:28:20 -040059 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040060 if (err)
61 return err;
62
Vivien Didelotfad09c72016-06-21 12:28:20 -040063 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040064 addr, reg, *val);
65
66 return 0;
67}
68
Vivien Didelotec561272016-09-02 14:45:33 -040069int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040070{
71 int err;
72
Vivien Didelotfad09c72016-06-21 12:28:20 -040073 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040074
Vivien Didelotfad09c72016-06-21 12:28:20 -040075 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040076 if (err)
77 return err;
78
Vivien Didelotfad09c72016-06-21 12:28:20 -040079 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040080 addr, reg, val);
81
82 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000083}
84
Vivien Didelot683f2242019-08-09 18:47:54 -040085int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
86 u16 mask, u16 val)
87{
88 u16 data;
89 int err;
90 int i;
91
92 /* There's no bus specific operation to wait for a mask */
93 for (i = 0; i < 16; i++) {
94 err = mv88e6xxx_read(chip, addr, reg, &data);
95 if (err)
96 return err;
97
98 if ((data & mask) == val)
99 return 0;
100
101 usleep_range(1000, 2000);
102 }
103
104 dev_err(chip->dev, "Timeout while waiting for switch\n");
105 return -ETIMEDOUT;
106}
107
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400108int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
109 int bit, int val)
110{
111 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
112 val ? BIT(bit) : 0x0000);
113}
114
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200115struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100116{
117 struct mv88e6xxx_mdio_bus *mdio_bus;
118
119 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
120 list);
121 if (!mdio_bus)
122 return NULL;
123
124 return mdio_bus->bus;
125}
126
Andrew Lunndc30c352016-10-16 19:56:49 +0200127static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
128{
129 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
130 unsigned int n = d->hwirq;
131
132 chip->g1_irq.masked |= (1 << n);
133}
134
135static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
136{
137 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
138 unsigned int n = d->hwirq;
139
140 chip->g1_irq.masked &= ~(1 << n);
141}
142
Andrew Lunn294d7112018-02-22 22:58:32 +0100143static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200144{
Andrew Lunndc30c352016-10-16 19:56:49 +0200145 unsigned int nhandled = 0;
146 unsigned int sub_irq;
147 unsigned int n;
148 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500149 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200150 int err;
151
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000152 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400153 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000154 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200155
156 if (err)
157 goto out;
158
John David Anglin7c0db242019-02-11 13:40:21 -0500159 do {
160 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
161 if (reg & (1 << n)) {
162 sub_irq = irq_find_mapping(chip->g1_irq.domain,
163 n);
164 handle_nested_irq(sub_irq);
165 ++nhandled;
166 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200167 }
John David Anglin7c0db242019-02-11 13:40:21 -0500168
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000169 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500170 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
171 if (err)
172 goto unlock;
173 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
174unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000175 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500176 if (err)
177 goto out;
178 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
179 } while (reg & ctl1);
180
Andrew Lunndc30c352016-10-16 19:56:49 +0200181out:
182 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
183}
184
Andrew Lunn294d7112018-02-22 22:58:32 +0100185static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
186{
187 struct mv88e6xxx_chip *chip = dev_id;
188
189 return mv88e6xxx_g1_irq_thread_work(chip);
190}
191
Andrew Lunndc30c352016-10-16 19:56:49 +0200192static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
193{
194 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
195
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000196 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200197}
198
199static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
200{
201 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
202 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
203 u16 reg;
204 int err;
205
Vivien Didelotd77f4322017-06-15 12:14:03 -0400206 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200207 if (err)
208 goto out;
209
210 reg &= ~mask;
211 reg |= (~chip->g1_irq.masked & mask);
212
Vivien Didelotd77f4322017-06-15 12:14:03 -0400213 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200214 if (err)
215 goto out;
216
217out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000218 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200219}
220
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530221static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200222 .name = "mv88e6xxx-g1",
223 .irq_mask = mv88e6xxx_g1_irq_mask,
224 .irq_unmask = mv88e6xxx_g1_irq_unmask,
225 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
226 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
227};
228
229static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
230 unsigned int irq,
231 irq_hw_number_t hwirq)
232{
233 struct mv88e6xxx_chip *chip = d->host_data;
234
235 irq_set_chip_data(irq, d->host_data);
236 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
237 irq_set_noprobe(irq);
238
239 return 0;
240}
241
242static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
243 .map = mv88e6xxx_g1_irq_domain_map,
244 .xlate = irq_domain_xlate_twocell,
245};
246
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200247/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100248static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200249{
250 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100251 u16 mask;
252
Vivien Didelotd77f4322017-06-15 12:14:03 -0400253 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100254 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400255 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100256
Andreas Färber5edef2f2016-11-27 23:26:28 +0100257 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100258 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200259 irq_dispose_mapping(virq);
260 }
261
Andrew Lunna3db3d32016-11-20 20:14:14 +0100262 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200263}
264
Andrew Lunn294d7112018-02-22 22:58:32 +0100265static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
266{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200267 /*
268 * free_irq must be called without reg_lock taken because the irq
269 * handler takes this lock, too.
270 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100271 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200272
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000273 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200274 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000275 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100276}
277
278static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200279{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100280 int err, irq, virq;
281 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200282
283 chip->g1_irq.nirqs = chip->info->g1_irqs;
284 chip->g1_irq.domain = irq_domain_add_simple(
285 NULL, chip->g1_irq.nirqs, 0,
286 &mv88e6xxx_g1_irq_domain_ops, chip);
287 if (!chip->g1_irq.domain)
288 return -ENOMEM;
289
290 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
291 irq_create_mapping(chip->g1_irq.domain, irq);
292
293 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
294 chip->g1_irq.masked = ~0;
295
Vivien Didelotd77f4322017-06-15 12:14:03 -0400296 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200297 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100298 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200299
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100300 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200301
Vivien Didelotd77f4322017-06-15 12:14:03 -0400302 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200303 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100304 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200305
306 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400307 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200308 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100309 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200310
Andrew Lunndc30c352016-10-16 19:56:49 +0200311 return 0;
312
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100313out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100314 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400315 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100316
317out_mapping:
318 for (irq = 0; irq < 16; irq++) {
319 virq = irq_find_mapping(chip->g1_irq.domain, irq);
320 irq_dispose_mapping(virq);
321 }
322
323 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200324
325 return err;
326}
327
Andrew Lunn294d7112018-02-22 22:58:32 +0100328static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
329{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100330 static struct lock_class_key lock_key;
331 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100332 int err;
333
334 err = mv88e6xxx_g1_irq_setup_common(chip);
335 if (err)
336 return err;
337
Andrew Lunnf6d97582019-02-23 17:43:56 +0100338 /* These lock classes tells lockdep that global 1 irqs are in
339 * a different category than their parent GPIO, so it won't
340 * report false recursion.
341 */
342 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
343
Andrew Lunn30953832020-01-06 17:13:48 +0100344 snprintf(chip->irq_name, sizeof(chip->irq_name),
345 "mv88e6xxx-%s", dev_name(chip->dev));
346
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000347 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100348 err = request_threaded_irq(chip->irq, NULL,
349 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200350 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100351 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000352 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100353 if (err)
354 mv88e6xxx_g1_irq_free_common(chip);
355
356 return err;
357}
358
359static void mv88e6xxx_irq_poll(struct kthread_work *work)
360{
361 struct mv88e6xxx_chip *chip = container_of(work,
362 struct mv88e6xxx_chip,
363 irq_poll_work.work);
364 mv88e6xxx_g1_irq_thread_work(chip);
365
366 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
367 msecs_to_jiffies(100));
368}
369
370static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
371{
372 int err;
373
374 err = mv88e6xxx_g1_irq_setup_common(chip);
375 if (err)
376 return err;
377
378 kthread_init_delayed_work(&chip->irq_poll_work,
379 mv88e6xxx_irq_poll);
380
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800381 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100382 if (IS_ERR(chip->kworker))
383 return PTR_ERR(chip->kworker);
384
385 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
386 msecs_to_jiffies(100));
387
388 return 0;
389}
390
391static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
392{
393 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
394 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200395
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000396 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200397 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000398 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100399}
400
Russell King64d47d52020-03-14 10:15:38 +0000401static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
402 int port, phy_interface_t interface)
403{
404 int err;
405
406 if (chip->info->ops->port_set_rgmii_delay) {
407 err = chip->info->ops->port_set_rgmii_delay(chip, port,
408 interface);
409 if (err && err != -EOPNOTSUPP)
410 return err;
411 }
412
413 if (chip->info->ops->port_set_cmode) {
414 err = chip->info->ops->port_set_cmode(chip, port,
415 interface);
416 if (err && err != -EOPNOTSUPP)
417 return err;
418 }
419
420 return 0;
421}
422
Russell Kinga5a68582020-03-14 10:15:43 +0000423static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
424 int link, int speed, int duplex, int pause,
425 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100426{
427 int err;
428
429 if (!chip->info->ops->port_set_link)
430 return 0;
431
432 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200433 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100434 if (err)
435 return err;
436
Russell Kingf365c6f2020-03-14 10:15:53 +0000437 if (chip->info->ops->port_set_speed_duplex) {
438 err = chip->info->ops->port_set_speed_duplex(chip, port,
439 speed, duplex);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100440 if (err && err != -EOPNOTSUPP)
441 goto restore_link;
442 }
443
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100444 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
445 mode = chip->info->ops->port_max_speed_mode(port);
446
Andrew Lunn54186b92018-08-09 15:38:37 +0200447 if (chip->info->ops->port_set_pause) {
448 err = chip->info->ops->port_set_pause(chip, port, pause);
449 if (err)
450 goto restore_link;
451 }
452
Russell King64d47d52020-03-14 10:15:38 +0000453 err = mv88e6xxx_port_config_interface(chip, port, mode);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100454restore_link:
455 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400456 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100457
458 return err;
459}
460
Marek Vasutd700ec42018-09-12 00:15:24 +0200461static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
462{
463 struct mv88e6xxx_chip *chip = ds->priv;
464
465 return port < chip->info->num_internal_phys;
466}
467
Russell King5d5b2312020-03-14 10:16:03 +0000468static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)
469{
470 u16 reg;
471 int err;
472
473 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
474 if (err) {
475 dev_err(chip->dev,
476 "p%d: %s: failed to read port status\n",
477 port, __func__);
478 return err;
479 }
480
481 return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
482}
483
Russell Kinga5a68582020-03-14 10:15:43 +0000484static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
485 struct phylink_link_state *state)
486{
487 struct mv88e6xxx_chip *chip = ds->priv;
488 u8 lane;
489 int err;
490
491 mv88e6xxx_reg_lock(chip);
492 lane = mv88e6xxx_serdes_get_lane(chip, port);
493 if (lane && chip->info->ops->serdes_pcs_get_state)
494 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
495 state);
496 else
497 err = -EOPNOTSUPP;
498 mv88e6xxx_reg_unlock(chip);
499
500 return err;
501}
502
503static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
504 unsigned int mode,
505 phy_interface_t interface,
506 const unsigned long *advertise)
507{
508 const struct mv88e6xxx_ops *ops = chip->info->ops;
509 u8 lane;
510
511 if (ops->serdes_pcs_config) {
512 lane = mv88e6xxx_serdes_get_lane(chip, port);
513 if (lane)
514 return ops->serdes_pcs_config(chip, port, lane, mode,
515 interface, advertise);
516 }
517
518 return 0;
519}
520
521static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
522{
523 struct mv88e6xxx_chip *chip = ds->priv;
524 const struct mv88e6xxx_ops *ops;
525 int err = 0;
526 u8 lane;
527
528 ops = chip->info->ops;
529
530 if (ops->serdes_pcs_an_restart) {
531 mv88e6xxx_reg_lock(chip);
532 lane = mv88e6xxx_serdes_get_lane(chip, port);
533 if (lane)
534 err = ops->serdes_pcs_an_restart(chip, port, lane);
535 mv88e6xxx_reg_unlock(chip);
536
537 if (err)
538 dev_err(ds->dev, "p%d: failed to restart AN\n", port);
539 }
540}
541
542static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
543 unsigned int mode,
544 int speed, int duplex)
545{
546 const struct mv88e6xxx_ops *ops = chip->info->ops;
547 u8 lane;
548
549 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
550 lane = mv88e6xxx_serdes_get_lane(chip, port);
551 if (lane)
552 return ops->serdes_pcs_link_up(chip, port, lane,
553 speed, duplex);
554 }
555
556 return 0;
557}
558
Russell King6c422e32018-08-09 15:38:39 +0200559static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
560 unsigned long *mask,
561 struct phylink_link_state *state)
562{
563 if (!phy_interface_mode_is_8023z(state->interface)) {
564 /* 10M and 100M are only supported in non-802.3z mode */
565 phylink_set(mask, 10baseT_Half);
566 phylink_set(mask, 10baseT_Full);
567 phylink_set(mask, 100baseT_Half);
568 phylink_set(mask, 100baseT_Full);
569 }
570}
571
572static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
573 unsigned long *mask,
574 struct phylink_link_state *state)
575{
576 /* FIXME: if the port is in 1000Base-X mode, then it only supports
577 * 1000M FD speeds. In this case, CMODE will indicate 5.
578 */
579 phylink_set(mask, 1000baseT_Full);
580 phylink_set(mask, 1000baseX_Full);
581
582 mv88e6065_phylink_validate(chip, port, mask, state);
583}
584
Marek Behúne3af71a2019-02-25 12:39:55 +0100585static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
586 unsigned long *mask,
587 struct phylink_link_state *state)
588{
589 if (port >= 5)
590 phylink_set(mask, 2500baseX_Full);
591
592 /* No ethtool bits for 200Mbps */
593 phylink_set(mask, 1000baseT_Full);
594 phylink_set(mask, 1000baseX_Full);
595
596 mv88e6065_phylink_validate(chip, port, mask, state);
597}
598
Russell King6c422e32018-08-09 15:38:39 +0200599static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
600 unsigned long *mask,
601 struct phylink_link_state *state)
602{
603 /* No ethtool bits for 200Mbps */
604 phylink_set(mask, 1000baseT_Full);
605 phylink_set(mask, 1000baseX_Full);
606
607 mv88e6065_phylink_validate(chip, port, mask, state);
608}
609
610static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
611 unsigned long *mask,
612 struct phylink_link_state *state)
613{
Andrew Lunnec260162019-02-08 22:25:44 +0100614 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200615 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100616 phylink_set(mask, 2500baseT_Full);
617 }
Russell King6c422e32018-08-09 15:38:39 +0200618
619 /* No ethtool bits for 200Mbps */
620 phylink_set(mask, 1000baseT_Full);
621 phylink_set(mask, 1000baseX_Full);
622
623 mv88e6065_phylink_validate(chip, port, mask, state);
624}
625
626static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
627 unsigned long *mask,
628 struct phylink_link_state *state)
629{
630 if (port >= 9) {
631 phylink_set(mask, 10000baseT_Full);
632 phylink_set(mask, 10000baseKR_Full);
633 }
634
635 mv88e6390_phylink_validate(chip, port, mask, state);
636}
637
Russell Kingc9a23562018-05-10 13:17:35 -0700638static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
639 unsigned long *supported,
640 struct phylink_link_state *state)
641{
Russell King6c422e32018-08-09 15:38:39 +0200642 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
643 struct mv88e6xxx_chip *chip = ds->priv;
644
645 /* Allow all the expected bits */
646 phylink_set(mask, Autoneg);
647 phylink_set(mask, Pause);
648 phylink_set_port_modes(mask);
649
650 if (chip->info->ops->phylink_validate)
651 chip->info->ops->phylink_validate(chip, port, mask, state);
652
653 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
654 bitmap_and(state->advertising, state->advertising, mask,
655 __ETHTOOL_LINK_MODE_MASK_NBITS);
656
657 /* We can only operate at 2500BaseX or 1000BaseX. If requested
658 * to advertise both, only report advertising at 2500BaseX.
659 */
660 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700661}
662
Russell Kingc9a23562018-05-10 13:17:35 -0700663static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
664 unsigned int mode,
665 const struct phylink_link_state *state)
666{
667 struct mv88e6xxx_chip *chip = ds->priv;
Russell Kingfad58192020-07-19 12:00:35 +0100668 struct mv88e6xxx_port *p;
Russell King64d47d52020-03-14 10:15:38 +0000669 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700670
Russell Kingfad58192020-07-19 12:00:35 +0100671 p = &chip->ports[port];
672
Russell King64d47d52020-03-14 10:15:38 +0000673 /* FIXME: is this the correct test? If we're in fixed mode on an
674 * internal port, why should we process this any different from
675 * PHY mode? On the other hand, the port may be automedia between
676 * an internal PHY and the serdes...
677 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200678 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700679 return;
680
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000681 mv88e6xxx_reg_lock(chip);
Russell Kingfad58192020-07-19 12:00:35 +0100682 /* In inband mode, the link may come up at any time while the link
683 * is not forced down. Force the link down while we reconfigure the
684 * interface mode.
Russell King64d47d52020-03-14 10:15:38 +0000685 */
Russell Kingfad58192020-07-19 12:00:35 +0100686 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
687 chip->info->ops->port_set_link)
688 chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
689
Russell King64d47d52020-03-14 10:15:38 +0000690 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000691 if (err && err != -EOPNOTSUPP)
692 goto err_unlock;
693
694 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
695 state->advertising);
696 /* FIXME: we should restart negotiation if something changed - which
697 * is something we get if we convert to using phylinks PCS operations.
698 */
699 if (err > 0)
700 err = 0;
701
Russell Kingfad58192020-07-19 12:00:35 +0100702 /* Undo the forced down state above after completing configuration
703 * irrespective of its state on entry, which allows the link to come up.
704 */
705 if (mode == MLO_AN_INBAND && p->interface != state->interface &&
706 chip->info->ops->port_set_link)
707 chip->info->ops->port_set_link(chip, port, LINK_UNFORCED);
708
709 p->interface = state->interface;
710
Russell Kinga5a68582020-03-14 10:15:43 +0000711err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000712 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700713
714 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000715 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700716}
717
Russell Kingc9a23562018-05-10 13:17:35 -0700718static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
719 unsigned int mode,
720 phy_interface_t interface)
721{
Russell King30c4a5b2020-02-26 10:23:51 +0000722 struct mv88e6xxx_chip *chip = ds->priv;
723 const struct mv88e6xxx_ops *ops;
724 int err = 0;
725
726 ops = chip->info->ops;
727
Russell King5d5b2312020-03-14 10:16:03 +0000728 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200729 if ((!mv88e6xxx_port_ppu_updates(chip, port) ||
Chris Packham4efe76622020-11-24 17:34:37 +1300730 mode == MLO_AN_FIXED) && ops->port_sync_link)
731 err = ops->port_sync_link(chip, port, mode, false);
Russell King5d5b2312020-03-14 10:16:03 +0000732 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000733
Russell King5d5b2312020-03-14 10:16:03 +0000734 if (err)
735 dev_err(chip->dev,
736 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700737}
738
739static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
740 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000741 struct phy_device *phydev,
742 int speed, int duplex,
743 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700744{
Russell King30c4a5b2020-02-26 10:23:51 +0000745 struct mv88e6xxx_chip *chip = ds->priv;
746 const struct mv88e6xxx_ops *ops;
747 int err = 0;
748
749 ops = chip->info->ops;
750
Russell King5d5b2312020-03-14 10:16:03 +0000751 mv88e6xxx_reg_lock(chip);
Andrew Lunn34b5e6a2020-04-14 02:34:38 +0200752 if (!mv88e6xxx_port_ppu_updates(chip, port) || mode == MLO_AN_FIXED) {
Russell King30c4a5b2020-02-26 10:23:51 +0000753 /* FIXME: for an automedia port, should we force the link
754 * down here - what if the link comes up due to "other" media
755 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000756 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000757 * shared between internal PHY and Serdes.
758 */
Russell Kinga5a68582020-03-14 10:15:43 +0000759 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
760 duplex);
761 if (err)
762 goto error;
763
Russell Kingf365c6f2020-03-14 10:15:53 +0000764 if (ops->port_set_speed_duplex) {
765 err = ops->port_set_speed_duplex(chip, port,
766 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000767 if (err && err != -EOPNOTSUPP)
768 goto error;
769 }
770
Chris Packham4efe76622020-11-24 17:34:37 +1300771 if (ops->port_sync_link)
772 err = ops->port_sync_link(chip, port, mode, true);
Russell King30c4a5b2020-02-26 10:23:51 +0000773 }
Russell King5d5b2312020-03-14 10:16:03 +0000774error:
775 mv88e6xxx_reg_unlock(chip);
776
777 if (err && err != -EOPNOTSUPP)
778 dev_err(ds->dev,
779 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700780}
781
Andrew Lunna605a0f2016-11-21 23:26:58 +0100782static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000783{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100784 if (!chip->info->ops->stats_snapshot)
785 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000786
Andrew Lunna605a0f2016-11-21 23:26:58 +0100787 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000788}
789
Andrew Lunne413e7e2015-04-02 04:06:38 +0200790static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100791 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
792 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
793 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
794 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
795 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
796 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
797 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
798 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
799 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
800 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
801 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
802 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
803 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
804 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
805 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
806 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
807 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
808 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
809 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
810 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
811 { "single", 4, 0x14, STATS_TYPE_BANK0, },
812 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
813 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
814 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
815 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
816 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
817 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
818 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
819 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
820 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
821 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
822 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
823 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
824 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
825 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
826 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
827 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
828 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
829 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
830 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
831 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
832 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
833 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
834 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
835 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
836 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
837 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
838 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
839 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
840 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
841 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
842 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
843 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
844 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
845 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
846 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
847 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
848 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
849 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200850};
851
Vivien Didelotfad09c72016-06-21 12:28:20 -0400852static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100853 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100854 int port, u16 bank1_select,
855 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200856{
Andrew Lunn80c46272015-06-20 18:42:30 +0200857 u32 low;
858 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100859 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200860 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200861 u64 value;
862
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100863 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100864 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200865 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
866 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800867 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200868
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200869 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100870 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200871 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
872 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800873 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000874 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200875 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100876 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100877 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100878 reg = bank1_select;
Gustavo A. R. Silvadf561f662020-08-23 17:36:59 -0500879 fallthrough;
Andrew Lunndfafe442016-11-21 23:27:02 +0100880 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100881 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100882 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100883 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100884 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500885 break;
886 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800887 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200888 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100889 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200890 return value;
891}
892
Andrew Lunn436fe172018-03-01 02:02:29 +0100893static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
894 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100895{
896 struct mv88e6xxx_hw_stat *stat;
897 int i, j;
898
899 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
900 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100901 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100902 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
903 ETH_GSTRING_LEN);
904 j++;
905 }
906 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100907
908 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100909}
910
Andrew Lunn436fe172018-03-01 02:02:29 +0100911static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
912 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100913{
Andrew Lunn436fe172018-03-01 02:02:29 +0100914 return mv88e6xxx_stats_get_strings(chip, data,
915 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100916}
917
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000918static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
919 uint8_t *data)
920{
921 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
922}
923
Andrew Lunn436fe172018-03-01 02:02:29 +0100924static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
925 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100926{
Andrew Lunn436fe172018-03-01 02:02:29 +0100927 return mv88e6xxx_stats_get_strings(chip, data,
928 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100929}
930
Andrew Lunn65f60e42018-03-28 23:50:28 +0200931static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
932 "atu_member_violation",
933 "atu_miss_violation",
934 "atu_full_violation",
935 "vtu_member_violation",
936 "vtu_miss_violation",
937};
938
939static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
940{
941 unsigned int i;
942
943 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
944 strlcpy(data + i * ETH_GSTRING_LEN,
945 mv88e6xxx_atu_vtu_stats_strings[i],
946 ETH_GSTRING_LEN);
947}
948
Andrew Lunndfafe442016-11-21 23:27:02 +0100949static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700950 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100951{
Vivien Didelot04bed142016-08-31 18:06:13 -0400952 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100953 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100954
Florian Fainelli89f09042018-04-25 12:12:50 -0700955 if (stringset != ETH_SS_STATS)
956 return;
957
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000958 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100959
Andrew Lunndfafe442016-11-21 23:27:02 +0100960 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100961 count = chip->info->ops->stats_get_strings(chip, data);
962
963 if (chip->info->ops->serdes_get_strings) {
964 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200965 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100966 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100967
Andrew Lunn65f60e42018-03-28 23:50:28 +0200968 data += count * ETH_GSTRING_LEN;
969 mv88e6xxx_atu_vtu_get_strings(data);
970
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000971 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100972}
973
974static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
975 int types)
976{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100977 struct mv88e6xxx_hw_stat *stat;
978 int i, j;
979
980 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
981 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100982 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100983 j++;
984 }
985 return j;
986}
987
Andrew Lunndfafe442016-11-21 23:27:02 +0100988static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
989{
990 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
991 STATS_TYPE_PORT);
992}
993
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000994static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
995{
996 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
997}
998
Andrew Lunndfafe442016-11-21 23:27:02 +0100999static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
1000{
1001 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
1002 STATS_TYPE_BANK1);
1003}
1004
Florian Fainelli89f09042018-04-25 12:12:50 -07001005static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +01001006{
1007 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +01001008 int serdes_count = 0;
1009 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +01001010
Florian Fainelli89f09042018-04-25 12:12:50 -07001011 if (sset != ETH_SS_STATS)
1012 return 0;
1013
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001014 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001015 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +01001016 count = chip->info->ops->stats_get_sset_count(chip);
1017 if (count < 0)
1018 goto out;
1019
1020 if (chip->info->ops->serdes_get_sset_count)
1021 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1022 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001023 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001024 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001025 goto out;
1026 }
1027 count += serdes_count;
1028 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1029
Andrew Lunn436fe172018-03-01 02:02:29 +01001030out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001031 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001032
Andrew Lunn436fe172018-03-01 02:02:29 +01001033 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001034}
1035
Andrew Lunn436fe172018-03-01 02:02:29 +01001036static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1037 uint64_t *data, int types,
1038 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001039{
1040 struct mv88e6xxx_hw_stat *stat;
1041 int i, j;
1042
1043 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1044 stat = &mv88e6xxx_hw_stats[i];
1045 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001046 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001047 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1048 bank1_select,
1049 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001050 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001051
Andrew Lunn052f9472016-11-21 23:27:03 +01001052 j++;
1053 }
1054 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001055 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001056}
1057
Andrew Lunn436fe172018-03-01 02:02:29 +01001058static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1059 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001060{
1061 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001062 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001063 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001064}
1065
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001066static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1067 uint64_t *data)
1068{
1069 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1070 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1071}
1072
Andrew Lunn436fe172018-03-01 02:02:29 +01001073static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1074 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001075{
1076 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001077 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001078 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1079 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001080}
1081
Andrew Lunn436fe172018-03-01 02:02:29 +01001082static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1083 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001084{
1085 return mv88e6xxx_stats_get_stats(chip, port, data,
1086 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001087 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1088 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001089}
1090
Andrew Lunn65f60e42018-03-28 23:50:28 +02001091static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1092 uint64_t *data)
1093{
1094 *data++ = chip->ports[port].atu_member_violation;
1095 *data++ = chip->ports[port].atu_miss_violation;
1096 *data++ = chip->ports[port].atu_full_violation;
1097 *data++ = chip->ports[port].vtu_member_violation;
1098 *data++ = chip->ports[port].vtu_miss_violation;
1099}
1100
Andrew Lunn052f9472016-11-21 23:27:03 +01001101static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1102 uint64_t *data)
1103{
Andrew Lunn436fe172018-03-01 02:02:29 +01001104 int count = 0;
1105
Andrew Lunn052f9472016-11-21 23:27:03 +01001106 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001107 count = chip->info->ops->stats_get_stats(chip, port, data);
1108
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001109 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001110 if (chip->info->ops->serdes_get_stats) {
1111 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001112 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001113 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001114 data += count;
1115 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001116 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001117}
1118
Vivien Didelotf81ec902016-05-09 13:22:58 -04001119static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1120 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001121{
Vivien Didelot04bed142016-08-31 18:06:13 -04001122 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001123 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001124
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001125 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001126
Andrew Lunna605a0f2016-11-21 23:26:58 +01001127 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001128 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001129
1130 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001131 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001132
1133 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001134
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001135}
Ben Hutchings98e67302011-11-25 14:36:19 +00001136
Vivien Didelotf81ec902016-05-09 13:22:58 -04001137static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001138{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001139 struct mv88e6xxx_chip *chip = ds->priv;
1140 int len;
1141
1142 len = 32 * sizeof(u16);
1143 if (chip->info->ops->serdes_get_regs_len)
1144 len += chip->info->ops->serdes_get_regs_len(chip, port);
1145
1146 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001147}
1148
Vivien Didelotf81ec902016-05-09 13:22:58 -04001149static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1150 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001151{
Vivien Didelot04bed142016-08-31 18:06:13 -04001152 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001153 int err;
1154 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001155 u16 *p = _p;
1156 int i;
1157
Vivien Didelota5f39322018-12-17 16:05:21 -05001158 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001159
1160 memset(p, 0xff, 32 * sizeof(u16));
1161
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001162 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001163
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001164 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001165
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001166 err = mv88e6xxx_port_read(chip, port, i, &reg);
1167 if (!err)
1168 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001169 }
Vivien Didelot23062512016-05-09 13:22:45 -04001170
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001171 if (chip->info->ops->serdes_get_regs)
1172 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1173
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001174 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001175}
1176
Vivien Didelot08f50062017-08-01 16:32:41 -04001177static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1178 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001179{
Vivien Didelot5480db62017-08-01 16:32:40 -04001180 /* Nothing to do on the port's MAC */
1181 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001182}
1183
Vivien Didelot08f50062017-08-01 16:32:41 -04001184static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1185 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001186{
Vivien Didelot5480db62017-08-01 16:32:40 -04001187 /* Nothing to do on the port's MAC */
1188 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001189}
1190
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001191/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001192static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001193{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001194 struct dsa_switch *ds = chip->ds;
1195 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001196 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001197 struct dsa_port *dp;
1198 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001199 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001200
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001201 list_for_each_entry(dp, &dst->ports, list) {
1202 if (dp->ds->index == dev && dp->index == port) {
1203 found = true;
1204 break;
1205 }
1206 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001207
Vivien Didelote5887a22017-03-30 17:37:11 -04001208 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001209 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001210 return 0;
1211
1212 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001213 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001214 return mv88e6xxx_port_mask(chip);
1215
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001216 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001217 pvlan = 0;
1218
1219 /* Frames from user ports can egress any local DSA links and CPU ports,
1220 * as well as any local member of their bridge group.
1221 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001222 list_for_each_entry(dp, &dst->ports, list)
1223 if (dp->ds == ds &&
1224 (dp->type == DSA_PORT_TYPE_CPU ||
1225 dp->type == DSA_PORT_TYPE_DSA ||
1226 (br && dp->bridge_dev == br)))
1227 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001228
1229 return pvlan;
1230}
1231
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001232static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001233{
1234 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001235
1236 /* prevent frames from going back out of the port they came in on */
1237 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001238
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001239 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001240}
1241
Vivien Didelotf81ec902016-05-09 13:22:58 -04001242static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1243 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001244{
Vivien Didelot04bed142016-08-31 18:06:13 -04001245 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001246 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001247
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001248 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001249 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001250 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001251
1252 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001253 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001254}
1255
Vivien Didelot93e18d62018-05-11 17:16:35 -04001256static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1257{
1258 int err;
1259
1260 if (chip->info->ops->ieee_pri_map) {
1261 err = chip->info->ops->ieee_pri_map(chip);
1262 if (err)
1263 return err;
1264 }
1265
1266 if (chip->info->ops->ip_pri_map) {
1267 err = chip->info->ops->ip_pri_map(chip);
1268 if (err)
1269 return err;
1270 }
1271
1272 return 0;
1273}
1274
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001275static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1276{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001277 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001278 int target, port;
1279 int err;
1280
1281 if (!chip->info->global2_addr)
1282 return 0;
1283
1284 /* Initialize the routing port to the 32 possible target devices */
1285 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001286 port = dsa_routing_port(ds, target);
1287 if (port == ds->num_ports)
1288 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001289
1290 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1291 if (err)
1292 return err;
1293 }
1294
Vivien Didelot02317e62018-05-09 11:38:49 -04001295 if (chip->info->ops->set_cascade_port) {
1296 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1297 err = chip->info->ops->set_cascade_port(chip, port);
1298 if (err)
1299 return err;
1300 }
1301
Vivien Didelot23c98912018-05-09 11:38:50 -04001302 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1303 if (err)
1304 return err;
1305
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001306 return 0;
1307}
1308
Vivien Didelotb28f8722018-04-26 21:56:44 -04001309static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1310{
1311 /* Clear all trunk masks and mapping */
1312 if (chip->info->global2_addr)
1313 return mv88e6xxx_g2_trunk_clear(chip);
1314
1315 return 0;
1316}
1317
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001318static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1319{
1320 if (chip->info->ops->rmu_disable)
1321 return chip->info->ops->rmu_disable(chip);
1322
1323 return 0;
1324}
1325
Vivien Didelot9e907d72017-07-17 13:03:43 -04001326static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1327{
1328 if (chip->info->ops->pot_clear)
1329 return chip->info->ops->pot_clear(chip);
1330
1331 return 0;
1332}
1333
Vivien Didelot51c901a2017-07-17 13:03:41 -04001334static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1335{
1336 if (chip->info->ops->mgmt_rsvd2cpu)
1337 return chip->info->ops->mgmt_rsvd2cpu(chip);
1338
1339 return 0;
1340}
1341
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001342static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1343{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001344 int err;
1345
Vivien Didelotdaefc942017-03-11 16:12:54 -05001346 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1347 if (err)
1348 return err;
1349
Rasmus Villemoes49506a92020-12-10 12:06:44 +01001350 /* The chips that have a "learn2all" bit in Global1, ATU
1351 * Control are precisely those whose port registers have a
1352 * Message Port bit in Port Control 1 and hence implement
1353 * ->port_setup_message_port.
1354 */
1355 if (chip->info->ops->port_setup_message_port) {
1356 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1357 if (err)
1358 return err;
1359 }
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001360
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001361 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1362}
1363
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001364static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1365{
1366 int port;
1367 int err;
1368
1369 if (!chip->info->ops->irl_init_all)
1370 return 0;
1371
1372 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1373 /* Disable ingress rate limiting by resetting all per port
1374 * ingress rate limit resources to their initial state.
1375 */
1376 err = chip->info->ops->irl_init_all(chip, port);
1377 if (err)
1378 return err;
1379 }
1380
1381 return 0;
1382}
1383
Vivien Didelot04a69a12017-10-13 14:18:05 -04001384static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1385{
1386 if (chip->info->ops->set_switch_mac) {
1387 u8 addr[ETH_ALEN];
1388
1389 eth_random_addr(addr);
1390
1391 return chip->info->ops->set_switch_mac(chip, addr);
1392 }
1393
1394 return 0;
1395}
1396
Vivien Didelot17a15942017-03-30 17:37:09 -04001397static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1398{
1399 u16 pvlan = 0;
1400
1401 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001402 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001403
1404 /* Skip the local source device, which uses in-chip port VLAN */
1405 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001406 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001407
1408 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1409}
1410
Vivien Didelot81228992017-03-30 17:37:08 -04001411static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1412{
Vivien Didelot17a15942017-03-30 17:37:09 -04001413 int dev, port;
1414 int err;
1415
Vivien Didelot81228992017-03-30 17:37:08 -04001416 if (!mv88e6xxx_has_pvt(chip))
1417 return 0;
1418
1419 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1420 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1421 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001422 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1423 if (err)
1424 return err;
1425
1426 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1427 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1428 err = mv88e6xxx_pvt_map(chip, dev, port);
1429 if (err)
1430 return err;
1431 }
1432 }
1433
1434 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001435}
1436
Vivien Didelot749efcb2016-09-22 16:49:24 -04001437static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1438{
1439 struct mv88e6xxx_chip *chip = ds->priv;
1440 int err;
1441
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001442 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001443 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001444 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001445
1446 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001447 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001448}
1449
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001450static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1451{
Tobias Waldekranze545f862020-11-10 19:57:20 +01001452 if (!mv88e6xxx_max_vid(chip))
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001453 return 0;
1454
1455 return mv88e6xxx_g1_vtu_flush(chip);
1456}
1457
Vivien Didelotf1394b782017-05-01 14:05:22 -04001458static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1459 struct mv88e6xxx_vtu_entry *entry)
1460{
1461 if (!chip->info->ops->vtu_getnext)
1462 return -EOPNOTSUPP;
1463
1464 return chip->info->ops->vtu_getnext(chip, entry);
1465}
1466
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001467static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1468 struct mv88e6xxx_vtu_entry *entry)
1469{
1470 if (!chip->info->ops->vtu_loadpurge)
1471 return -EOPNOTSUPP;
1472
1473 return chip->info->ops->vtu_loadpurge(chip, entry);
1474}
1475
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001476int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001477{
Vivien Didelot425d2d32019-08-01 14:36:34 -04001478 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001479 int i, err;
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001480 u16 fid;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001481
1482 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1483
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001484 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001485 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001486 err = mv88e6xxx_port_get_fid(chip, i, &fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001487 if (err)
1488 return err;
1489
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001490 set_bit(fid, fid_bitmap);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001491 }
1492
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001493 /* Set every FID bit used by the VLAN entries */
Tobias Waldekranze545f862020-11-10 19:57:20 +01001494 vlan.vid = mv88e6xxx_max_vid(chip);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001495 vlan.valid = false;
1496
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001497 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001498 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001499 if (err)
1500 return err;
1501
1502 if (!vlan.valid)
1503 break;
1504
1505 set_bit(vlan.fid, fid_bitmap);
Tobias Waldekranze545f862020-11-10 19:57:20 +01001506 } while (vlan.vid < mv88e6xxx_max_vid(chip));
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001507
Andrew Lunn90b6dbd2020-09-18 21:11:06 +02001508 return 0;
1509}
1510
1511static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
1512{
1513 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
1514 int err;
1515
1516 err = mv88e6xxx_fid_map(chip, fid_bitmap);
1517 if (err)
1518 return err;
1519
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001520 /* The reset value 0x000 is used to indicate that multiple address
1521 * databases are not needed. Return the next positive available.
1522 */
1523 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001524 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001525 return -ENOSPC;
1526
1527 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001528 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001529}
1530
Vivien Didelotda9c3592016-02-12 12:09:40 -05001531static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001532 u16 vid)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001533{
Vivien Didelot04bed142016-08-31 18:06:13 -04001534 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001535 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001536 int i, err;
1537
Vladimir Oltean3e85f582021-01-09 02:01:47 +02001538 if (!vid)
1539 return -EOPNOTSUPP;
1540
Andrew Lunndb06ae412017-09-25 23:32:20 +02001541 /* DSA and CPU ports have to be members of multiple vlans */
1542 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1543 return 0;
1544
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001545 vlan.vid = vid - 1;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001546 vlan.valid = false;
1547
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001548 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1549 if (err)
1550 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001551
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001552 if (!vlan.valid)
1553 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001554
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001555 if (vlan.vid != vid)
1556 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001557
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001558 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
1559 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1560 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001561
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001562 if (!dsa_to_port(ds, i)->slave)
1563 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001564
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001565 if (vlan.member[i] ==
1566 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
1567 continue;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001568
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001569 if (dsa_to_port(ds, i)->bridge_dev ==
1570 dsa_to_port(ds, port)->bridge_dev)
1571 break; /* same bridge, check next VLAN */
Vivien Didelotda9c3592016-02-12 12:09:40 -05001572
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001573 if (!dsa_to_port(ds, i)->bridge_dev)
1574 continue;
Andrew Lunn66e28092016-12-11 21:07:19 +01001575
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001576 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1577 port, vlan.vid, i,
1578 netdev_name(dsa_to_port(ds, i)->bridge_dev));
1579 return -EOPNOTSUPP;
1580 }
Vivien Didelotda9c3592016-02-12 12:09:40 -05001581
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001582 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001583}
1584
Vivien Didelotf81ec902016-05-09 13:22:58 -04001585static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
Vladimir Olteanbae33f22021-01-09 02:01:50 +02001586 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001587{
Vivien Didelot04bed142016-08-31 18:06:13 -04001588 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001589 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1590 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001591 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001592
Vladimir Olteanbae33f22021-01-09 02:01:50 +02001593 if (!mv88e6xxx_max_vid(chip))
1594 return -EOPNOTSUPP;
Vivien Didelot54d77b52016-05-09 13:22:47 -04001595
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001596 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001597 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001598 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001599
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001600 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001601}
1602
Vivien Didelot57d32312016-06-20 13:13:58 -04001603static int
1604mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001605 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001606{
Vivien Didelot04bed142016-08-31 18:06:13 -04001607 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001608 int err;
1609
Tobias Waldekranze545f862020-11-10 19:57:20 +01001610 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001611 return -EOPNOTSUPP;
1612
Vivien Didelotda9c3592016-02-12 12:09:40 -05001613 /* If the requested port doesn't belong to the same bridge as the VLAN
1614 * members, do not support it (yet) and fallback to software VLAN.
1615 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001616 mv88e6xxx_reg_lock(chip);
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001617 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001618 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001619
Vivien Didelot76e398a2015-11-01 12:33:55 -05001620 /* We don't need any dynamic resource from the kernel (yet),
1621 * so skip the prepare phase.
1622 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001623 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001624}
1625
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001626static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1627 const unsigned char *addr, u16 vid,
1628 u8 state)
1629{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001630 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001631 struct mv88e6xxx_vtu_entry vlan;
1632 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001633 int err;
1634
1635 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001636 if (vid == 0) {
1637 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1638 if (err)
1639 return err;
1640 } else {
1641 vlan.vid = vid - 1;
1642 vlan.valid = false;
1643
1644 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1645 if (err)
1646 return err;
1647
1648 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1649 if (vlan.vid != vid || !vlan.valid)
1650 return -EOPNOTSUPP;
1651
1652 fid = vlan.fid;
1653 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001654
Vivien Didelotd8291a92019-09-07 16:00:47 -04001655 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001656 ether_addr_copy(entry.mac, addr);
1657 eth_addr_dec(entry.mac);
1658
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001659 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001660 if (err)
1661 return err;
1662
1663 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001664 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001665 memset(&entry, 0, sizeof(entry));
1666 ether_addr_copy(entry.mac, addr);
1667 }
1668
1669 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001670 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001671 entry.portvec &= ~BIT(port);
1672 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001673 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001674 } else {
1675 entry.portvec |= BIT(port);
1676 entry.state = state;
1677 }
1678
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001679 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001680}
1681
Vivien Didelotda7dc872019-09-07 16:00:49 -04001682static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1683 const struct mv88e6xxx_policy *policy)
1684{
1685 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1686 enum mv88e6xxx_policy_action action = policy->action;
1687 const u8 *addr = policy->addr;
1688 u16 vid = policy->vid;
1689 u8 state;
1690 int err;
1691 int id;
1692
1693 if (!chip->info->ops->port_set_policy)
1694 return -EOPNOTSUPP;
1695
1696 switch (mapping) {
1697 case MV88E6XXX_POLICY_MAPPING_DA:
1698 case MV88E6XXX_POLICY_MAPPING_SA:
1699 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1700 state = 0; /* Dissociate the port and address */
1701 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1702 is_multicast_ether_addr(addr))
1703 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1704 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1705 is_unicast_ether_addr(addr))
1706 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1707 else
1708 return -EOPNOTSUPP;
1709
1710 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1711 state);
1712 if (err)
1713 return err;
1714 break;
1715 default:
1716 return -EOPNOTSUPP;
1717 }
1718
1719 /* Skip the port's policy clearing if the mapping is still in use */
1720 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1721 idr_for_each_entry(&chip->policies, policy, id)
1722 if (policy->port == port &&
1723 policy->mapping == mapping &&
1724 policy->action != action)
1725 return 0;
1726
1727 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1728}
1729
1730static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1731 struct ethtool_rx_flow_spec *fs)
1732{
1733 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1734 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1735 enum mv88e6xxx_policy_mapping mapping;
1736 enum mv88e6xxx_policy_action action;
1737 struct mv88e6xxx_policy *policy;
1738 u16 vid = 0;
1739 u8 *addr;
1740 int err;
1741 int id;
1742
1743 if (fs->location != RX_CLS_LOC_ANY)
1744 return -EINVAL;
1745
1746 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1747 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1748 else
1749 return -EOPNOTSUPP;
1750
1751 switch (fs->flow_type & ~FLOW_EXT) {
1752 case ETHER_FLOW:
1753 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1754 is_zero_ether_addr(mac_mask->h_source)) {
1755 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1756 addr = mac_entry->h_dest;
1757 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1758 !is_zero_ether_addr(mac_mask->h_source)) {
1759 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1760 addr = mac_entry->h_source;
1761 } else {
1762 /* Cannot support DA and SA mapping in the same rule */
1763 return -EOPNOTSUPP;
1764 }
1765 break;
1766 default:
1767 return -EOPNOTSUPP;
1768 }
1769
1770 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001771 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001772 return -EOPNOTSUPP;
1773 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1774 }
1775
1776 idr_for_each_entry(&chip->policies, policy, id) {
1777 if (policy->port == port && policy->mapping == mapping &&
1778 policy->action == action && policy->vid == vid &&
1779 ether_addr_equal(policy->addr, addr))
1780 return -EEXIST;
1781 }
1782
1783 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1784 if (!policy)
1785 return -ENOMEM;
1786
1787 fs->location = 0;
1788 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1789 GFP_KERNEL);
1790 if (err) {
1791 devm_kfree(chip->dev, policy);
1792 return err;
1793 }
1794
1795 memcpy(&policy->fs, fs, sizeof(*fs));
1796 ether_addr_copy(policy->addr, addr);
1797 policy->mapping = mapping;
1798 policy->action = action;
1799 policy->port = port;
1800 policy->vid = vid;
1801
1802 err = mv88e6xxx_policy_apply(chip, port, policy);
1803 if (err) {
1804 idr_remove(&chip->policies, fs->location);
1805 devm_kfree(chip->dev, policy);
1806 return err;
1807 }
1808
1809 return 0;
1810}
1811
1812static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1813 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1814{
1815 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1816 struct mv88e6xxx_chip *chip = ds->priv;
1817 struct mv88e6xxx_policy *policy;
1818 int err;
1819 int id;
1820
1821 mv88e6xxx_reg_lock(chip);
1822
1823 switch (rxnfc->cmd) {
1824 case ETHTOOL_GRXCLSRLCNT:
1825 rxnfc->data = 0;
1826 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1827 rxnfc->rule_cnt = 0;
1828 idr_for_each_entry(&chip->policies, policy, id)
1829 if (policy->port == port)
1830 rxnfc->rule_cnt++;
1831 err = 0;
1832 break;
1833 case ETHTOOL_GRXCLSRULE:
1834 err = -ENOENT;
1835 policy = idr_find(&chip->policies, fs->location);
1836 if (policy) {
1837 memcpy(fs, &policy->fs, sizeof(*fs));
1838 err = 0;
1839 }
1840 break;
1841 case ETHTOOL_GRXCLSRLALL:
1842 rxnfc->data = 0;
1843 rxnfc->rule_cnt = 0;
1844 idr_for_each_entry(&chip->policies, policy, id)
1845 if (policy->port == port)
1846 rule_locs[rxnfc->rule_cnt++] = id;
1847 err = 0;
1848 break;
1849 default:
1850 err = -EOPNOTSUPP;
1851 break;
1852 }
1853
1854 mv88e6xxx_reg_unlock(chip);
1855
1856 return err;
1857}
1858
1859static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1860 struct ethtool_rxnfc *rxnfc)
1861{
1862 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1863 struct mv88e6xxx_chip *chip = ds->priv;
1864 struct mv88e6xxx_policy *policy;
1865 int err;
1866
1867 mv88e6xxx_reg_lock(chip);
1868
1869 switch (rxnfc->cmd) {
1870 case ETHTOOL_SRXCLSRLINS:
1871 err = mv88e6xxx_policy_insert(chip, port, fs);
1872 break;
1873 case ETHTOOL_SRXCLSRLDEL:
1874 err = -ENOENT;
1875 policy = idr_remove(&chip->policies, fs->location);
1876 if (policy) {
1877 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1878 err = mv88e6xxx_policy_apply(chip, port, policy);
1879 devm_kfree(chip->dev, policy);
1880 }
1881 break;
1882 default:
1883 err = -EOPNOTSUPP;
1884 break;
1885 }
1886
1887 mv88e6xxx_reg_unlock(chip);
1888
1889 return err;
1890}
1891
Andrew Lunn87fa8862017-11-09 22:29:56 +01001892static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1893 u16 vid)
1894{
1895 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1896 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1897
1898 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1899}
1900
1901static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1902{
1903 int port;
1904 int err;
1905
1906 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1907 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1908 if (err)
1909 return err;
1910 }
1911
1912 return 0;
1913}
1914
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001915static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001916 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001917{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001918 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001919 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001920 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001921
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001922 vlan.vid = vid - 1;
1923 vlan.valid = false;
1924
1925 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001926 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001927 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001928
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001929 if (vlan.vid != vid || !vlan.valid) {
1930 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001931
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001932 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1933 if (err)
1934 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001935
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001936 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1937 if (i == port)
1938 vlan.member[i] = member;
1939 else
1940 vlan.member[i] = non_member;
1941
1942 vlan.vid = vid;
1943 vlan.valid = true;
1944
1945 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1946 if (err)
1947 return err;
1948
1949 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1950 if (err)
1951 return err;
1952 } else if (vlan.member[port] != member) {
1953 vlan.member[port] = member;
1954
1955 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1956 if (err)
1957 return err;
Russell King933b4422020-02-26 17:14:26 +00001958 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001959 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1960 port, vid);
1961 }
1962
1963 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001964}
1965
Vivien Didelotf81ec902016-05-09 13:22:58 -04001966static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001967 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001968{
Vivien Didelot04bed142016-08-31 18:06:13 -04001969 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001970 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1971 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001972 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001973 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001974
Tobias Waldekranze545f862020-11-10 19:57:20 +01001975 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001976 return;
1977
Vivien Didelotc91498e2017-06-07 18:12:13 -04001978 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001979 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001980 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001981 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001982 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001983 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001984
Russell King933b4422020-02-26 17:14:26 +00001985 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1986 * and then the CPU port. Do not warn for duplicates for the CPU port.
1987 */
1988 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1989
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001990 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001991
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001992 if (mv88e6xxx_port_vlan_join(chip, port, vlan->vid, member, warn))
1993 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1994 vlan->vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001995
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001996 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid))
Vivien Didelot774439e52017-06-08 18:34:08 -04001997 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02001998 vlan->vid);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001999
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002000 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002001}
2002
Vivien Didelot521098922019-08-01 14:36:36 -04002003static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2004 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002005{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002006 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002007 int i, err;
2008
Vivien Didelot521098922019-08-01 14:36:36 -04002009 if (!vid)
2010 return -EOPNOTSUPP;
2011
2012 vlan.vid = vid - 1;
2013 vlan.valid = false;
2014
2015 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002016 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002017 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002018
Vivien Didelot521098922019-08-01 14:36:36 -04002019 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2020 * tell switchdev that this VLAN is likely handled in software.
2021 */
2022 if (vlan.vid != vid || !vlan.valid ||
2023 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002024 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002025
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002026 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002027
2028 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002029 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002030 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002031 if (vlan.member[i] !=
2032 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002033 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002034 break;
2035 }
2036 }
2037
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002038 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002039 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002040 return err;
2041
Vivien Didelote606ca32017-03-11 16:12:55 -05002042 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002043}
2044
Vivien Didelotf81ec902016-05-09 13:22:58 -04002045static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2046 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002047{
Vivien Didelot04bed142016-08-31 18:06:13 -04002048 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002049 int err = 0;
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002050 u16 pvid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002051
Tobias Waldekranze545f862020-11-10 19:57:20 +01002052 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04002053 return -EOPNOTSUPP;
2054
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002055 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002056
Vivien Didelot77064f32016-11-04 03:23:30 +01002057 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002058 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002059 goto unlock;
2060
Vladimir Olteanb7a9e0d2021-01-09 02:01:46 +02002061 err = mv88e6xxx_port_vlan_leave(chip, port, vlan->vid);
2062 if (err)
2063 goto unlock;
2064
2065 if (vlan->vid == pvid) {
2066 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002067 if (err)
2068 goto unlock;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002069 }
2070
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002071unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002072 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002073
2074 return err;
2075}
2076
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002077static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2078 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002079{
Vivien Didelot04bed142016-08-31 18:06:13 -04002080 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002081 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002082
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002083 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002084 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2085 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002086 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002087
2088 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002089}
2090
Vivien Didelotf81ec902016-05-09 13:22:58 -04002091static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002092 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002093{
Vivien Didelot04bed142016-08-31 18:06:13 -04002094 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002095 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002096
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002097 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002098 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002099 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002100
Vivien Didelot83dabd12016-08-31 11:50:04 -04002101 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002102}
2103
Vivien Didelot83dabd12016-08-31 11:50:04 -04002104static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2105 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002106 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002107{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002108 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002109 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002110 int err;
2111
Vivien Didelotd8291a92019-09-07 16:00:47 -04002112 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002113 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002114
2115 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002116 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002117 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002118 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002119
Vivien Didelotd8291a92019-09-07 16:00:47 -04002120 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002121 break;
2122
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002123 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002124 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002125
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002126 if (!is_unicast_ether_addr(addr.mac))
2127 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002128
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002129 is_static = (addr.state ==
2130 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2131 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002132 if (err)
2133 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002134 } while (!is_broadcast_ether_addr(addr.mac));
2135
2136 return err;
2137}
2138
Vivien Didelot83dabd12016-08-31 11:50:04 -04002139static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002140 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002141{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002142 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002143 u16 fid;
2144 int err;
2145
2146 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002147 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002148 if (err)
2149 return err;
2150
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002151 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002152 if (err)
2153 return err;
2154
2155 /* Dump VLANs' Filtering Information Databases */
Tobias Waldekranze545f862020-11-10 19:57:20 +01002156 vlan.vid = mv88e6xxx_max_vid(chip);
Vivien Didelot425d2d32019-08-01 14:36:34 -04002157 vlan.valid = false;
2158
Vivien Didelot83dabd12016-08-31 11:50:04 -04002159 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002160 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002161 if (err)
2162 return err;
2163
2164 if (!vlan.valid)
2165 break;
2166
2167 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002168 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002169 if (err)
2170 return err;
Tobias Waldekranze545f862020-11-10 19:57:20 +01002171 } while (vlan.vid < mv88e6xxx_max_vid(chip));
Vivien Didelot83dabd12016-08-31 11:50:04 -04002172
2173 return err;
2174}
2175
Vivien Didelotf81ec902016-05-09 13:22:58 -04002176static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002177 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002178{
Vivien Didelot04bed142016-08-31 18:06:13 -04002179 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002180 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002181
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002182 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002183 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002184 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002185
2186 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002187}
2188
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002189static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2190 struct net_device *br)
2191{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002192 struct dsa_switch *ds = chip->ds;
2193 struct dsa_switch_tree *dst = ds->dst;
2194 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002195 int err;
2196
Vivien Didelotef2025e2019-10-21 16:51:27 -04002197 list_for_each_entry(dp, &dst->ports, list) {
2198 if (dp->bridge_dev == br) {
2199 if (dp->ds == ds) {
2200 /* This is a local bridge group member,
2201 * remap its Port VLAN Map.
2202 */
2203 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2204 if (err)
2205 return err;
2206 } else {
2207 /* This is an external bridge group member,
2208 * remap its cross-chip Port VLAN Table entry.
2209 */
2210 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2211 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002212 if (err)
2213 return err;
2214 }
2215 }
2216 }
2217
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002218 return 0;
2219}
2220
Vivien Didelotf81ec902016-05-09 13:22:58 -04002221static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002222 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002223{
Vivien Didelot04bed142016-08-31 18:06:13 -04002224 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002225 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002226
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002227 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002228 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002229 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002230
Vivien Didelot466dfa02016-02-26 13:16:05 -05002231 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002232}
2233
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002234static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2235 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002236{
Vivien Didelot04bed142016-08-31 18:06:13 -04002237 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002238
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002239 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002240 if (mv88e6xxx_bridge_map(chip, br) ||
2241 mv88e6xxx_port_vlan_map(chip, port))
2242 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002243 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002244}
2245
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002246static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2247 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002248 int port, struct net_device *br)
2249{
2250 struct mv88e6xxx_chip *chip = ds->priv;
2251 int err;
2252
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002253 if (tree_index != ds->dst->index)
2254 return 0;
2255
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002256 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002257 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002258 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002259
2260 return err;
2261}
2262
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002263static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2264 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002265 int port, struct net_device *br)
2266{
2267 struct mv88e6xxx_chip *chip = ds->priv;
2268
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002269 if (tree_index != ds->dst->index)
2270 return;
2271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002272 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002273 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002274 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002275 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002276}
2277
Vivien Didelot17e708b2016-12-05 17:30:27 -05002278static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2279{
2280 if (chip->info->ops->reset)
2281 return chip->info->ops->reset(chip);
2282
2283 return 0;
2284}
2285
Vivien Didelot309eca62016-12-05 17:30:26 -05002286static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2287{
2288 struct gpio_desc *gpiod = chip->reset;
2289
2290 /* If there is a GPIO connected to the reset pin, toggle it */
2291 if (gpiod) {
2292 gpiod_set_value_cansleep(gpiod, 1);
2293 usleep_range(10000, 20000);
2294 gpiod_set_value_cansleep(gpiod, 0);
2295 usleep_range(10000, 20000);
Andrew Lunna3dcb3e2020-11-16 08:43:01 -08002296
2297 mv88e6xxx_g1_wait_eeprom_done(chip);
Vivien Didelot309eca62016-12-05 17:30:26 -05002298 }
2299}
2300
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002301static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2302{
2303 int i, err;
2304
2305 /* Set all ports to the Disabled state */
2306 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002307 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002308 if (err)
2309 return err;
2310 }
2311
2312 /* Wait for transmit queues to drain,
2313 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2314 */
2315 usleep_range(2000, 4000);
2316
2317 return 0;
2318}
2319
Vivien Didelotfad09c72016-06-21 12:28:20 -04002320static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002321{
Vivien Didelota935c052016-09-29 12:21:53 -04002322 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002323
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002324 err = mv88e6xxx_disable_ports(chip);
2325 if (err)
2326 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002327
Vivien Didelot309eca62016-12-05 17:30:26 -05002328 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002329
Vivien Didelot17e708b2016-12-05 17:30:27 -05002330 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002331}
2332
Vivien Didelot43145572017-03-11 16:12:59 -05002333static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002334 enum mv88e6xxx_frame_mode frame,
2335 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002336{
2337 int err;
2338
Vivien Didelot43145572017-03-11 16:12:59 -05002339 if (!chip->info->ops->port_set_frame_mode)
2340 return -EOPNOTSUPP;
2341
2342 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002343 if (err)
2344 return err;
2345
Vivien Didelot43145572017-03-11 16:12:59 -05002346 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2347 if (err)
2348 return err;
2349
2350 if (chip->info->ops->port_set_ether_type)
2351 return chip->info->ops->port_set_ether_type(chip, port, etype);
2352
2353 return 0;
2354}
2355
2356static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2357{
2358 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002359 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002360 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002361}
2362
2363static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2364{
2365 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002366 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002367 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002368}
2369
2370static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2371{
2372 return mv88e6xxx_set_port_mode(chip, port,
2373 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002374 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2375 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002376}
2377
2378static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2379{
2380 if (dsa_is_dsa_port(chip->ds, port))
2381 return mv88e6xxx_set_port_mode_dsa(chip, port);
2382
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002383 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002384 return mv88e6xxx_set_port_mode_normal(chip, port);
2385
2386 /* Setup CPU port mode depending on its supported tag format */
2387 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2388 return mv88e6xxx_set_port_mode_dsa(chip, port);
2389
2390 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2391 return mv88e6xxx_set_port_mode_edsa(chip, port);
2392
2393 return -EINVAL;
2394}
2395
Vivien Didelotea698f42017-03-11 16:12:50 -05002396static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2397{
2398 bool message = dsa_is_dsa_port(chip->ds, port);
2399
2400 return mv88e6xxx_port_set_message_port(chip, port, message);
2401}
2402
Vivien Didelot601aeed2017-03-11 16:13:00 -05002403static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2404{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002405 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002406 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002407
David S. Miller407308f2019-06-15 13:35:29 -07002408 /* Upstream ports flood frames with unknown unicast or multicast DA */
2409 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2410 if (chip->info->ops->port_set_egress_floods)
2411 return chip->info->ops->port_set_egress_floods(chip, port,
2412 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002413
David S. Miller407308f2019-06-15 13:35:29 -07002414 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002415}
2416
Vivien Didelot45de77f2019-08-31 16:18:36 -04002417static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2418{
2419 struct mv88e6xxx_port *mvp = dev_id;
2420 struct mv88e6xxx_chip *chip = mvp->chip;
2421 irqreturn_t ret = IRQ_NONE;
2422 int port = mvp->port;
2423 u8 lane;
2424
2425 mv88e6xxx_reg_lock(chip);
2426 lane = mv88e6xxx_serdes_get_lane(chip, port);
2427 if (lane)
2428 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2429 mv88e6xxx_reg_unlock(chip);
2430
2431 return ret;
2432}
2433
2434static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2435 u8 lane)
2436{
2437 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2438 unsigned int irq;
2439 int err;
2440
2441 /* Nothing to request if this SERDES port has no IRQ */
2442 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2443 if (!irq)
2444 return 0;
2445
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002446 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2447 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2448
Vivien Didelot45de77f2019-08-31 16:18:36 -04002449 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2450 mv88e6xxx_reg_unlock(chip);
2451 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002452 IRQF_ONESHOT, dev_id->serdes_irq_name,
2453 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002454 mv88e6xxx_reg_lock(chip);
2455 if (err)
2456 return err;
2457
2458 dev_id->serdes_irq = irq;
2459
2460 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2461}
2462
2463static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2464 u8 lane)
2465{
2466 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2467 unsigned int irq = dev_id->serdes_irq;
2468 int err;
2469
2470 /* Nothing to free if no IRQ has been requested */
2471 if (!irq)
2472 return 0;
2473
2474 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2475
2476 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2477 mv88e6xxx_reg_unlock(chip);
2478 free_irq(irq, dev_id);
2479 mv88e6xxx_reg_lock(chip);
2480
2481 dev_id->serdes_irq = 0;
2482
2483 return err;
2484}
2485
Andrew Lunn6d917822017-05-26 01:03:21 +02002486static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2487 bool on)
2488{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002489 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002490 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002491
Vivien Didelotdc272f62019-08-31 16:18:33 -04002492 lane = mv88e6xxx_serdes_get_lane(chip, port);
2493 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002494 return 0;
2495
2496 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002497 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002498 if (err)
2499 return err;
2500
Vivien Didelot45de77f2019-08-31 16:18:36 -04002501 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002502 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002503 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2504 if (err)
2505 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002506
Vivien Didelotdc272f62019-08-31 16:18:33 -04002507 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002508 }
2509
2510 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002511}
2512
Vivien Didelotfa371c82017-12-05 15:34:10 -05002513static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2514{
2515 struct dsa_switch *ds = chip->ds;
2516 int upstream_port;
2517 int err;
2518
Vivien Didelot07073c72017-12-05 15:34:13 -05002519 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002520 if (chip->info->ops->port_set_upstream_port) {
2521 err = chip->info->ops->port_set_upstream_port(chip, port,
2522 upstream_port);
2523 if (err)
2524 return err;
2525 }
2526
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002527 if (port == upstream_port) {
2528 if (chip->info->ops->set_cpu_port) {
2529 err = chip->info->ops->set_cpu_port(chip,
2530 upstream_port);
2531 if (err)
2532 return err;
2533 }
2534
2535 if (chip->info->ops->set_egress_port) {
2536 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002537 MV88E6XXX_EGRESS_DIR_INGRESS,
2538 upstream_port);
2539 if (err)
2540 return err;
2541
2542 err = chip->info->ops->set_egress_port(chip,
2543 MV88E6XXX_EGRESS_DIR_EGRESS,
2544 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002545 if (err)
2546 return err;
2547 }
2548 }
2549
Vivien Didelotfa371c82017-12-05 15:34:10 -05002550 return 0;
2551}
2552
Vivien Didelotfad09c72016-06-21 12:28:20 -04002553static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002554{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002555 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002556 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002557 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002558
Andrew Lunn7b898462018-08-09 15:38:47 +02002559 chip->ports[port].chip = chip;
2560 chip->ports[port].port = port;
2561
Vivien Didelotd78343d2016-11-04 03:23:36 +01002562 /* MAC Forcing register: don't force link, speed, duplex or flow control
2563 * state to any particular values on physical ports, but force the CPU
2564 * port and all DSA ports to their maximum bandwidth and full duplex.
2565 */
2566 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2567 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2568 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002569 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002570 PHY_INTERFACE_MODE_NA);
2571 else
2572 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2573 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002574 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002575 PHY_INTERFACE_MODE_NA);
2576 if (err)
2577 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002578
2579 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2580 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2581 * tunneling, determine priority by looking at 802.1p and IP
2582 * priority fields (IP prio has precedence), and set STP state
2583 * to Forwarding.
2584 *
2585 * If this is the CPU link, use DSA or EDSA tagging depending
2586 * on which tagging mode was configured.
2587 *
2588 * If this is a link to another switch, use DSA tagging mode.
2589 *
2590 * If this is the upstream port for this switch, enable
2591 * forwarding of unknown unicasts and multicasts.
2592 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002593 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2594 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2595 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2596 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002597 if (err)
2598 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002599
Vivien Didelot601aeed2017-03-11 16:13:00 -05002600 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002601 if (err)
2602 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002603
Vivien Didelot601aeed2017-03-11 16:13:00 -05002604 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002605 if (err)
2606 return err;
2607
Vivien Didelot8efdda42015-08-13 12:52:23 -04002608 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002609 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002610 * untagged frames on this port, do a destination address lookup on all
2611 * received packets as usual, disable ARP mirroring and don't send a
2612 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002613 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002614 err = mv88e6xxx_port_set_map_da(chip, port);
2615 if (err)
2616 return err;
2617
Vivien Didelotfa371c82017-12-05 15:34:10 -05002618 err = mv88e6xxx_setup_upstream_port(chip, port);
2619 if (err)
2620 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002621
Andrew Lunna23b2962017-02-04 20:15:28 +01002622 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002623 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002624 if (err)
2625 return err;
2626
Vivien Didelotcd782652017-06-08 18:34:13 -04002627 if (chip->info->ops->port_set_jumbo_size) {
2628 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002629 if (err)
2630 return err;
2631 }
2632
Andrew Lunn54d792f2015-05-06 01:09:47 +02002633 /* Port Association Vector: when learning source addresses
2634 * of packets, add the address to the address database using
2635 * a port bitmap that has only the bit for this port set and
2636 * the other bits clear.
2637 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002638 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002639 /* Disable learning for CPU port */
2640 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002641 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002642
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002643 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2644 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002645 if (err)
2646 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002647
2648 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002649 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2650 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002651 if (err)
2652 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002653
Vivien Didelot08984322017-06-08 18:34:12 -04002654 if (chip->info->ops->port_pause_limit) {
2655 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002656 if (err)
2657 return err;
2658 }
2659
Vivien Didelotc8c94892017-03-11 16:13:01 -05002660 if (chip->info->ops->port_disable_learn_limit) {
2661 err = chip->info->ops->port_disable_learn_limit(chip, port);
2662 if (err)
2663 return err;
2664 }
2665
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002666 if (chip->info->ops->port_disable_pri_override) {
2667 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002668 if (err)
2669 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002670 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002671
Andrew Lunnef0a7312016-12-03 04:35:16 +01002672 if (chip->info->ops->port_tag_remap) {
2673 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002674 if (err)
2675 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002676 }
2677
Andrew Lunnef70b112016-12-03 04:45:18 +01002678 if (chip->info->ops->port_egress_rate_limiting) {
2679 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002680 if (err)
2681 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002682 }
2683
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002684 if (chip->info->ops->port_setup_message_port) {
2685 err = chip->info->ops->port_setup_message_port(chip, port);
2686 if (err)
2687 return err;
2688 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002689
Vivien Didelot207afda2016-04-14 14:42:09 -04002690 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002691 * database, and allow bidirectional communication between the
2692 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002693 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002694 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002695 if (err)
2696 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002697
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002698 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002699 if (err)
2700 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002701
2702 /* Default VLAN ID and priority: don't set a default VLAN
2703 * ID, and set the default packet priority to zero.
2704 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002705 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002706}
2707
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002708static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
2709{
2710 struct mv88e6xxx_chip *chip = ds->priv;
2711
2712 if (chip->info->ops->port_set_jumbo_size)
2713 return 10240;
Chris Packham1baf0fa2020-07-24 11:21:22 +12002714 else if (chip->info->ops->set_max_frame_size)
2715 return 1632;
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002716 return 1522;
2717}
2718
2719static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
2720{
2721 struct mv88e6xxx_chip *chip = ds->priv;
2722 int ret = 0;
2723
2724 mv88e6xxx_reg_lock(chip);
2725 if (chip->info->ops->port_set_jumbo_size)
2726 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Chris Packham1baf0fa2020-07-24 11:21:22 +12002727 else if (chip->info->ops->set_max_frame_size)
2728 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002729 else
2730 if (new_mtu > 1522)
2731 ret = -EINVAL;
2732 mv88e6xxx_reg_unlock(chip);
2733
2734 return ret;
2735}
2736
Andrew Lunn04aca992017-05-26 01:03:24 +02002737static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2738 struct phy_device *phydev)
2739{
2740 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002741 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002742
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002743 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002744 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002745 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002746
2747 return err;
2748}
2749
Andrew Lunn75104db2019-02-24 20:44:43 +01002750static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002751{
2752 struct mv88e6xxx_chip *chip = ds->priv;
2753
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002754 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002755 if (mv88e6xxx_serdes_power(chip, port, false))
2756 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002757 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002758}
2759
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002760static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2761 unsigned int ageing_time)
2762{
Vivien Didelot04bed142016-08-31 18:06:13 -04002763 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002764 int err;
2765
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002766 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002767 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002768 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002769
2770 return err;
2771}
2772
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002773static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002774{
2775 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002776
Andrew Lunnde2273872016-11-21 23:27:01 +01002777 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002778 if (chip->info->ops->stats_set_histogram) {
2779 err = chip->info->ops->stats_set_histogram(chip);
2780 if (err)
2781 return err;
2782 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002783
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002784 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002785}
2786
Andrew Lunnea890982019-01-09 00:24:03 +01002787/* Check if the errata has already been applied. */
2788static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2789{
2790 int port;
2791 int err;
2792 u16 val;
2793
2794 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002795 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002796 if (err) {
2797 dev_err(chip->dev,
2798 "Error reading hidden register: %d\n", err);
2799 return false;
2800 }
2801 if (val != 0x01c0)
2802 return false;
2803 }
2804
2805 return true;
2806}
2807
2808/* The 6390 copper ports have an errata which require poking magic
2809 * values into undocumented hidden registers and then performing a
2810 * software reset.
2811 */
2812static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2813{
2814 int port;
2815 int err;
2816
2817 if (mv88e6390_setup_errata_applied(chip))
2818 return 0;
2819
2820 /* Set the ports into blocking mode */
2821 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2822 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2823 if (err)
2824 return err;
2825 }
2826
2827 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002828 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002829 if (err)
2830 return err;
2831 }
2832
2833 return mv88e6xxx_software_reset(chip);
2834}
2835
Andrew Lunn23e8b472019-10-25 01:03:52 +02002836static void mv88e6xxx_teardown(struct dsa_switch *ds)
2837{
2838 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002839 dsa_devlink_resources_unregister(ds);
Andrew Lunnbfb25542020-09-18 21:11:07 +02002840 mv88e6xxx_teardown_devlink_regions(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002841}
2842
Vivien Didelotf81ec902016-05-09 13:22:58 -04002843static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002844{
Vivien Didelot04bed142016-08-31 18:06:13 -04002845 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002846 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002847 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002848 int i;
2849
Vivien Didelotfad09c72016-06-21 12:28:20 -04002850 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002851 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Russell King1fb74192020-10-29 16:09:03 +00002852 ds->configure_vlan_while_not_filtering = true;
Vivien Didelot552238b2016-05-09 13:22:49 -04002853
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002854 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002855
Andrew Lunnea890982019-01-09 00:24:03 +01002856 if (chip->info->ops->setup_errata) {
2857 err = chip->info->ops->setup_errata(chip);
2858 if (err)
2859 goto unlock;
2860 }
2861
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002862 /* Cache the cmode of each port. */
2863 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2864 if (chip->info->ops->port_get_cmode) {
2865 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2866 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002867 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002868
2869 chip->ports[i].cmode = cmode;
2870 }
2871 }
2872
Vivien Didelot97299342016-07-18 20:45:30 -04002873 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002874 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002875 if (dsa_is_unused_port(ds, i))
2876 continue;
2877
Hubert Feursteinc8574862019-07-31 10:23:48 +02002878 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002879 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002880 dev_err(chip->dev, "port %d is invalid\n", i);
2881 err = -EINVAL;
2882 goto unlock;
2883 }
2884
Vivien Didelot97299342016-07-18 20:45:30 -04002885 err = mv88e6xxx_setup_port(chip, i);
2886 if (err)
2887 goto unlock;
2888 }
2889
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002890 err = mv88e6xxx_irl_setup(chip);
2891 if (err)
2892 goto unlock;
2893
Vivien Didelot04a69a12017-10-13 14:18:05 -04002894 err = mv88e6xxx_mac_setup(chip);
2895 if (err)
2896 goto unlock;
2897
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002898 err = mv88e6xxx_phy_setup(chip);
2899 if (err)
2900 goto unlock;
2901
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002902 err = mv88e6xxx_vtu_setup(chip);
2903 if (err)
2904 goto unlock;
2905
Vivien Didelot81228992017-03-30 17:37:08 -04002906 err = mv88e6xxx_pvt_setup(chip);
2907 if (err)
2908 goto unlock;
2909
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002910 err = mv88e6xxx_atu_setup(chip);
2911 if (err)
2912 goto unlock;
2913
Andrew Lunn87fa8862017-11-09 22:29:56 +01002914 err = mv88e6xxx_broadcast_setup(chip, 0);
2915 if (err)
2916 goto unlock;
2917
Vivien Didelot9e907d72017-07-17 13:03:43 -04002918 err = mv88e6xxx_pot_setup(chip);
2919 if (err)
2920 goto unlock;
2921
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002922 err = mv88e6xxx_rmu_setup(chip);
2923 if (err)
2924 goto unlock;
2925
Vivien Didelot51c901a2017-07-17 13:03:41 -04002926 err = mv88e6xxx_rsvd2cpu_setup(chip);
2927 if (err)
2928 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002929
Vivien Didelotb28f8722018-04-26 21:56:44 -04002930 err = mv88e6xxx_trunk_setup(chip);
2931 if (err)
2932 goto unlock;
2933
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002934 err = mv88e6xxx_devmap_setup(chip);
2935 if (err)
2936 goto unlock;
2937
Vivien Didelot93e18d62018-05-11 17:16:35 -04002938 err = mv88e6xxx_pri_setup(chip);
2939 if (err)
2940 goto unlock;
2941
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002942 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002943 if (chip->info->ptp_support) {
2944 err = mv88e6xxx_ptp_setup(chip);
2945 if (err)
2946 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002947
2948 err = mv88e6xxx_hwtstamp_setup(chip);
2949 if (err)
2950 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002951 }
2952
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002953 err = mv88e6xxx_stats_setup(chip);
2954 if (err)
2955 goto unlock;
2956
Vivien Didelot6b17e862015-08-13 12:52:18 -04002957unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002958 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002959
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002960 if (err)
2961 return err;
2962
2963 /* Have to be called without holding the register lock, since
2964 * they take the devlink lock, and we later take the locks in
2965 * the reverse order when getting/setting parameters or
2966 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02002967 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002968 err = mv88e6xxx_setup_devlink_resources(ds);
2969 if (err)
2970 return err;
2971
2972 err = mv88e6xxx_setup_devlink_params(ds);
2973 if (err)
Andrew Lunnbfb25542020-09-18 21:11:07 +02002974 goto out_resources;
2975
2976 err = mv88e6xxx_setup_devlink_regions(ds);
2977 if (err)
2978 goto out_params;
2979
2980 return 0;
2981
2982out_params:
2983 mv88e6xxx_teardown_devlink_params(ds);
2984out_resources:
2985 dsa_devlink_resources_unregister(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002986
2987 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002988}
2989
Vivien Didelote57e5e72016-08-15 17:19:00 -04002990static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002991{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01002992 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
2993 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04002994 u16 val;
2995 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02002996
Andrew Lunnee26a222017-01-24 14:53:48 +01002997 if (!chip->info->ops->phy_read)
2998 return -EOPNOTSUPP;
2999
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003000 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003001 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003002 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003003
Andrew Lunnda9f3302017-02-01 03:40:05 +01003004 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003005 /* Some internal PHYs don't have a model number. */
3006 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3007 /* Then there is the 6165 family. It gets is
3008 * PHYs correct. But it can also have two
3009 * SERDES interfaces in the PHY address
3010 * space. And these don't have a model
3011 * number. But they are not PHYs, so we don't
3012 * want to give them something a PHY driver
3013 * will recognise.
3014 *
3015 * Use the mv88e6390 family model number
3016 * instead, for anything which really could be
3017 * a PHY,
3018 */
3019 if (!(val & 0x3f0))
3020 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003021 }
3022
Vivien Didelote57e5e72016-08-15 17:19:00 -04003023 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003024}
3025
Vivien Didelote57e5e72016-08-15 17:19:00 -04003026static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003027{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003028 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3029 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003030 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003031
Andrew Lunnee26a222017-01-24 14:53:48 +01003032 if (!chip->info->ops->phy_write)
3033 return -EOPNOTSUPP;
3034
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003035 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003036 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003037 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003038
3039 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003040}
3041
Vivien Didelotfad09c72016-06-21 12:28:20 -04003042static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003043 struct device_node *np,
3044 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003045{
3046 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003047 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003048 struct mii_bus *bus;
3049 int err;
3050
Andrew Lunn2510bab2018-02-22 01:51:49 +01003051 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003052 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003053 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003054 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003055
3056 if (err)
3057 return err;
3058 }
3059
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003060 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003061 if (!bus)
3062 return -ENOMEM;
3063
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003064 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003065 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003066 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003067 INIT_LIST_HEAD(&mdio_bus->list);
3068 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003069
Andrew Lunnb516d452016-06-04 21:17:06 +02003070 if (np) {
3071 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003072 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003073 } else {
3074 bus->name = "mv88e6xxx SMI";
3075 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3076 }
3077
3078 bus->read = mv88e6xxx_mdio_read;
3079 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003080 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003081
Andrew Lunn6f882842018-03-17 20:32:05 +01003082 if (!external) {
3083 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3084 if (err)
3085 return err;
3086 }
3087
Florian Fainelli00e798c2018-05-15 16:56:19 -07003088 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003089 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003090 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003091 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003092 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003093 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003094
3095 if (external)
3096 list_add_tail(&mdio_bus->list, &chip->mdios);
3097 else
3098 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003099
3100 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003101}
3102
Andrew Lunn3126aee2017-12-07 01:05:57 +01003103static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3104
3105{
3106 struct mv88e6xxx_mdio_bus *mdio_bus;
3107 struct mii_bus *bus;
3108
3109 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3110 bus = mdio_bus->bus;
3111
Andrew Lunn6f882842018-03-17 20:32:05 +01003112 if (!mdio_bus->external)
3113 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3114
Andrew Lunn3126aee2017-12-07 01:05:57 +01003115 mdiobus_unregister(bus);
3116 }
3117}
3118
Andrew Lunna3c53be52017-01-24 14:53:50 +01003119static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3120 struct device_node *np)
3121{
Andrew Lunna3c53be52017-01-24 14:53:50 +01003122 struct device_node *child;
3123 int err;
3124
3125 /* Always register one mdio bus for the internal/default mdio
3126 * bus. This maybe represented in the device tree, but is
3127 * optional.
3128 */
3129 child = of_get_child_by_name(np, "mdio");
3130 err = mv88e6xxx_mdio_register(chip, child, false);
3131 if (err)
3132 return err;
3133
3134 /* Walk the device tree, and see if there are any other nodes
3135 * which say they are compatible with the external mdio
3136 * bus.
3137 */
3138 for_each_available_child_of_node(np, child) {
Andrew Lunnceb96fa2020-09-01 04:32:57 +02003139 if (of_device_is_compatible(
3140 child, "marvell,mv88e6xxx-mdio-external")) {
Andrew Lunna3c53be52017-01-24 14:53:50 +01003141 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003142 if (err) {
3143 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303144 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003145 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003146 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003147 }
3148 }
3149
3150 return 0;
3151}
3152
Vivien Didelot855b1932016-07-20 18:18:35 -04003153static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3154{
Vivien Didelot04bed142016-08-31 18:06:13 -04003155 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003156
3157 return chip->eeprom_len;
3158}
3159
Vivien Didelot855b1932016-07-20 18:18:35 -04003160static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3161 struct ethtool_eeprom *eeprom, u8 *data)
3162{
Vivien Didelot04bed142016-08-31 18:06:13 -04003163 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003164 int err;
3165
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003166 if (!chip->info->ops->get_eeprom)
3167 return -EOPNOTSUPP;
3168
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003169 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003170 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003171 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003172
3173 if (err)
3174 return err;
3175
3176 eeprom->magic = 0xc3ec4951;
3177
3178 return 0;
3179}
3180
Vivien Didelot855b1932016-07-20 18:18:35 -04003181static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3182 struct ethtool_eeprom *eeprom, u8 *data)
3183{
Vivien Didelot04bed142016-08-31 18:06:13 -04003184 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003185 int err;
3186
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003187 if (!chip->info->ops->set_eeprom)
3188 return -EOPNOTSUPP;
3189
Vivien Didelot855b1932016-07-20 18:18:35 -04003190 if (eeprom->magic != 0xc3ec4951)
3191 return -EINVAL;
3192
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003193 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003194 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003195 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003196
3197 return err;
3198}
3199
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003200static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003201 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003202 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3203 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003204 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003205 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003206 .phy_read = mv88e6185_phy_ppu_read,
3207 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003208 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003209 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003210 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003211 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003212 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003213 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003214 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003215 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003216 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003217 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003218 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003219 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003220 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003221 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003222 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003223 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3224 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003225 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003226 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3227 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003228 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003229 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003230 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003231 .ppu_enable = mv88e6185_g1_ppu_enable,
3232 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003233 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003234 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003235 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003236 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003237 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003238 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003239};
3240
3241static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003242 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003243 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3244 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003245 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003246 .phy_read = mv88e6185_phy_ppu_read,
3247 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003248 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003249 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003250 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003251 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003252 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003253 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003254 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003255 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003256 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003257 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003258 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3259 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003260 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003261 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003262 .serdes_power = mv88e6185_serdes_power,
3263 .serdes_get_lane = mv88e6185_serdes_get_lane,
3264 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003265 .ppu_enable = mv88e6185_g1_ppu_enable,
3266 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003267 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003268 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003269 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003270 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003271 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003272};
3273
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003274static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003275 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003276 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3277 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003278 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003279 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3280 .phy_read = mv88e6xxx_g2_smi_phy_read,
3281 .phy_write = mv88e6xxx_g2_smi_phy_write,
3282 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003283 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003284 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003285 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003286 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003287 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003288 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003289 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003290 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003291 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003292 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003293 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003294 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003295 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003296 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003297 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3298 .stats_get_strings = mv88e6095_stats_get_strings,
3299 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003300 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3301 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003302 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003303 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003304 .serdes_power = mv88e6185_serdes_power,
3305 .serdes_get_lane = mv88e6185_serdes_get_lane,
3306 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Chris Packham5c19bc82020-11-24 17:34:39 +13003307 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
3308 .serdes_irq_enable = mv88e6097_serdes_irq_enable,
3309 .serdes_irq_status = mv88e6097_serdes_irq_status,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003310 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003311 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003312 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003313 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003314 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003315 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003316 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003317};
3318
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003319static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003320 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003321 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3322 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003323 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003324 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003325 .phy_read = mv88e6xxx_g2_smi_phy_read,
3326 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003327 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003328 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003329 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003330 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003331 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003332 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003333 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003334 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003335 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003336 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003337 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003338 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3339 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003340 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003341 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3342 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003343 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003344 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003345 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003346 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003347 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3348 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003349 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003350 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003351 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003352 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003353};
3354
3355static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003356 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003357 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3358 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003359 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003360 .phy_read = mv88e6185_phy_ppu_read,
3361 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003362 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003363 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003364 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003365 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003366 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003367 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003368 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003369 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003370 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003371 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003372 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003373 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003374 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003375 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003376 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003377 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003378 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3379 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003380 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003381 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3382 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003383 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003384 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003385 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003386 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003387 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003388 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003389 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003390 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003391 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003392};
3393
Vivien Didelot990e27b2017-03-28 13:50:32 -04003394static const struct mv88e6xxx_ops mv88e6141_ops = {
3395 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003396 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3397 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003398 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003399 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3400 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3401 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3402 .phy_read = mv88e6xxx_g2_smi_phy_read,
3403 .phy_write = mv88e6xxx_g2_smi_phy_write,
3404 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003405 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003406 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003407 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003408 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003409 .port_tag_remap = mv88e6095_port_tag_remap,
3410 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3411 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3412 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003413 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003414 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003415 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003416 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3417 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003418 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003419 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003420 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003421 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003422 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003423 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3424 .stats_get_strings = mv88e6320_stats_get_strings,
3425 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003426 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3427 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003428 .watchdog_ops = &mv88e6390_watchdog_ops,
3429 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003430 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003431 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003432 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003433 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003434 .serdes_power = mv88e6390_serdes_power,
3435 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003436 /* Check status register pause & lpa register */
3437 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3438 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3439 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3440 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003441 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003442 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003443 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003444 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003445 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003446};
3447
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003448static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003449 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003450 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3451 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003452 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003453 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003454 .phy_read = mv88e6xxx_g2_smi_phy_read,
3455 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003456 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003457 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003458 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003459 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003460 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003461 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003462 .port_set_ether_type = mv88e6351_port_set_ether_type,
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,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003466 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003467 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003468 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003469 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003470 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003471 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003472 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3473 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003474 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003475 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3476 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003477 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003478 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003479 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003480 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003481 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3482 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003483 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003484 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003485 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003486 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003487 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003488};
3489
3490static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003491 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003492 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3493 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003494 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003495 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003496 .phy_read = mv88e6165_phy_read,
3497 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003498 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003499 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003500 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003501 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003502 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003503 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003504 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003505 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003506 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003507 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3508 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003509 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003510 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3511 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003512 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003513 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003514 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003515 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003516 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3517 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003518 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003519 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003520 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003521 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003522 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003523};
3524
3525static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003526 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003527 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3528 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003529 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003530 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003531 .phy_read = mv88e6xxx_g2_smi_phy_read,
3532 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003533 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003534 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003535 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003536 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003537 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003538 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003539 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003540 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003541 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003542 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003543 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003544 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003545 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003546 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003547 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003548 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003549 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003550 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3551 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003552 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003553 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3554 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003555 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003556 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003557 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003558 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003559 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3560 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003561 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003562 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003563 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003564};
3565
3566static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003567 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003568 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3569 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003570 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003571 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3572 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003573 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003574 .phy_read = mv88e6xxx_g2_smi_phy_read,
3575 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003576 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003577 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003578 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003579 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003580 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003581 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003582 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003583 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003584 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003585 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003586 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003587 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003588 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003589 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003590 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003591 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003592 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003593 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003594 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3595 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003596 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003597 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3598 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003599 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003600 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003601 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003602 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003603 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003604 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3605 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003606 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003607 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003608 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003609 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3610 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3611 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3612 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003613 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003614 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3615 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003616 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003617 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003618};
3619
3620static const struct mv88e6xxx_ops mv88e6175_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,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003634 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003635 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003636 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003637 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003638 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003639 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003640 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003641 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003642 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003643 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003644 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003645 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3646 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003647 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003648 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3649 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003650 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003651 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003652 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003653 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003654 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3655 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003656 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003657 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003658 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003659};
3660
3661static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003662 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003663 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3664 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003665 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003666 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3667 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003668 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003669 .phy_read = mv88e6xxx_g2_smi_phy_read,
3670 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003671 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003672 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003673 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003674 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003675 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003676 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003677 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003678 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003679 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003680 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003681 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003682 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003683 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003684 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003685 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003686 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003687 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003688 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003689 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3690 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003691 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003692 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3693 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003694 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003695 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003696 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003697 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003698 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003699 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3700 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003701 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003702 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003703 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003704 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3705 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3706 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3707 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003708 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003709 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003710 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003711 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003712 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3713 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003714 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003715 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003716};
3717
3718static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003719 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003720 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3721 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003722 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003723 .phy_read = mv88e6185_phy_ppu_read,
3724 .phy_write = mv88e6185_phy_ppu_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 = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003727 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003728 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003729 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003730 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003731 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003732 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003733 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003734 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003735 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003736 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003737 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3738 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003739 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003740 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3741 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003742 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003743 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003744 .serdes_power = mv88e6185_serdes_power,
3745 .serdes_get_lane = mv88e6185_serdes_get_lane,
3746 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelot02317e62018-05-09 11:38:49 -04003747 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003748 .ppu_enable = mv88e6185_g1_ppu_enable,
3749 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003750 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003751 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003752 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003753 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003754 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003755};
3756
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003757static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003758 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003759 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003760 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003761 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3762 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003763 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3764 .phy_read = mv88e6xxx_g2_smi_phy_read,
3765 .phy_write = mv88e6xxx_g2_smi_phy_write,
3766 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003767 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003768 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003769 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003770 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003771 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003772 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003773 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003774 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003775 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003776 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003777 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003778 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003779 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003780 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003781 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003782 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003783 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003784 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003785 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3786 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003787 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003788 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3789 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003790 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003791 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003792 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003793 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003794 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003795 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3796 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003797 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3798 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003799 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003800 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003801 /* Check status register pause & lpa register */
3802 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3803 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3804 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3805 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003806 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003807 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003808 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003809 .serdes_get_strings = mv88e6390_serdes_get_strings,
3810 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003811 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3812 .serdes_get_regs = mv88e6390_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 = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003815};
3816
3817static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003818 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003819 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003820 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003821 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3822 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003823 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3824 .phy_read = mv88e6xxx_g2_smi_phy_read,
3825 .phy_write = mv88e6xxx_g2_smi_phy_write,
3826 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003827 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003828 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003829 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003830 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003831 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003832 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003833 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003834 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003835 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003836 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003837 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003838 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003839 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003840 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003841 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003842 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003843 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003844 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003845 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3846 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003847 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003848 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3849 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003850 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003851 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003852 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003853 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003854 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003855 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3856 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003857 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3858 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003859 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003860 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003861 /* Check status register pause & lpa register */
3862 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3863 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3864 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3865 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003866 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003867 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003868 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003869 .serdes_get_strings = mv88e6390_serdes_get_strings,
3870 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003871 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3872 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003873 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003874 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003875};
3876
3877static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003878 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003879 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003880 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003881 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3882 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003883 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3884 .phy_read = mv88e6xxx_g2_smi_phy_read,
3885 .phy_write = mv88e6xxx_g2_smi_phy_write,
3886 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003887 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003888 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003889 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003890 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003891 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003892 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003893 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003894 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003895 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003896 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003897 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003898 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003899 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003900 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003901 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003902 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003903 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3904 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003905 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003906 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3907 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003908 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003909 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003910 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003911 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003912 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003913 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3914 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003915 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3916 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003917 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003918 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003919 /* Check status register pause & lpa register */
3920 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3921 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3922 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3923 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003924 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003925 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003926 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003927 .serdes_get_strings = mv88e6390_serdes_get_strings,
3928 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003929 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3930 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003931 .avb_ops = &mv88e6390_avb_ops,
3932 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003933 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003934};
3935
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003936static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003937 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003938 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3939 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003940 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003941 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3942 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003943 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003944 .phy_read = mv88e6xxx_g2_smi_phy_read,
3945 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003946 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003947 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003948 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003949 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003950 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003951 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003952 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003953 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003954 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003955 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003956 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003957 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003958 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003959 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003960 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003961 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003962 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003963 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003964 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3965 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003966 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003967 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3968 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003969 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003970 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003971 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003972 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003973 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003974 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3975 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003976 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003977 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003978 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003979 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3980 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3981 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3982 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003983 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003984 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003985 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003986 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003987 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3988 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003989 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01003990 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003991 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003992 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003993};
3994
Rasmus Villemoes1f718362019-06-04 07:34:32 +00003995static const struct mv88e6xxx_ops mv88e6250_ops = {
3996 /* MV88E6XXX_FAMILY_6250 */
3997 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
3998 .ip_pri_map = mv88e6085_g1_ip_pri_map,
3999 .irl_init_all = mv88e6352_g2_irl_init_all,
4000 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4001 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4002 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4003 .phy_read = mv88e6xxx_g2_smi_phy_read,
4004 .phy_write = mv88e6xxx_g2_smi_phy_write,
4005 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004006 .port_sync_link = mv88e6xxx_port_sync_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004007 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004008 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004009 .port_tag_remap = mv88e6095_port_tag_remap,
4010 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4011 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4012 .port_set_ether_type = mv88e6351_port_set_ether_type,
4013 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4014 .port_pause_limit = mv88e6097_port_pause_limit,
4015 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004016 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4017 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4018 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4019 .stats_get_strings = mv88e6250_stats_get_strings,
4020 .stats_get_stats = mv88e6250_stats_get_stats,
4021 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4022 .set_egress_port = mv88e6095_g1_set_egress_port,
4023 .watchdog_ops = &mv88e6250_watchdog_ops,
4024 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4025 .pot_clear = mv88e6xxx_g2_pot_clear,
4026 .reset = mv88e6250_g1_reset,
4027 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4028 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004029 .avb_ops = &mv88e6352_avb_ops,
4030 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004031 .phylink_validate = mv88e6065_phylink_validate,
4032};
4033
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004034static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004035 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004036 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004037 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004038 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4039 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004040 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4041 .phy_read = mv88e6xxx_g2_smi_phy_read,
4042 .phy_write = mv88e6xxx_g2_smi_phy_write,
4043 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004044 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004045 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004046 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004047 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004048 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004049 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004050 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004051 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004052 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004053 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004054 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004055 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004056 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004057 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004058 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004059 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004060 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004061 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4062 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004063 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004064 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4065 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004066 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004067 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004068 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004069 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004070 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004071 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4072 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004073 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4074 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004075 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004076 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004077 /* Check status register pause & lpa register */
4078 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4079 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4080 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4081 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004082 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004083 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004084 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004085 .serdes_get_strings = mv88e6390_serdes_get_strings,
4086 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004087 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4088 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004089 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004090 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004091 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004092 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004093};
4094
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004095static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004096 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004097 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4098 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004099 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004100 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4101 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004102 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004103 .phy_read = mv88e6xxx_g2_smi_phy_read,
4104 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004105 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004106 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004107 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004108 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004109 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004110 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004111 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004112 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004113 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004114 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004115 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004116 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004117 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004118 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004119 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004120 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004121 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4122 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004123 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004124 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4125 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004126 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004127 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004128 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004129 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004130 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004131 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004132 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004133 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004134 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004135 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004136};
4137
4138static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004139 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004140 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4141 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004142 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004143 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4144 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004145 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004146 .phy_read = mv88e6xxx_g2_smi_phy_read,
4147 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004148 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004149 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004150 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004151 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004152 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004153 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004154 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004155 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004156 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004157 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004158 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004159 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004160 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004161 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004162 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004163 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004164 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4165 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004166 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004167 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4168 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004169 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004170 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004171 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004172 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004173 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004174 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004175 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004176 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004177};
4178
Vivien Didelot16e329a2017-03-28 13:50:33 -04004179static const struct mv88e6xxx_ops mv88e6341_ops = {
4180 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004181 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4182 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004183 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004184 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4185 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4186 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4187 .phy_read = mv88e6xxx_g2_smi_phy_read,
4188 .phy_write = mv88e6xxx_g2_smi_phy_write,
4189 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004190 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004191 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004192 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004193 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004194 .port_tag_remap = mv88e6095_port_tag_remap,
4195 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4196 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4197 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004198 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004199 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004200 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004201 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4202 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004203 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004204 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004205 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004206 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004207 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004208 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4209 .stats_get_strings = mv88e6320_stats_get_strings,
4210 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004211 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4212 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004213 .watchdog_ops = &mv88e6390_watchdog_ops,
4214 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004215 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004216 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004217 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004218 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004219 .serdes_power = mv88e6390_serdes_power,
4220 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004221 /* Check status register pause & lpa register */
4222 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4223 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4224 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4225 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004226 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004227 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004228 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004229 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004230 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004231 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004232 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004233};
4234
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004235static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004236 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004237 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4238 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004239 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004240 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004241 .phy_read = mv88e6xxx_g2_smi_phy_read,
4242 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004243 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004244 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004245 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004246 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004247 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004248 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004249 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004250 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004251 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004252 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004253 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004254 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004255 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004256 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004257 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004258 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004259 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004260 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4261 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004262 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004263 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4264 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004265 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004266 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004267 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004268 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004269 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4270 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004271 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004272 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004273 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004274};
4275
4276static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004277 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004278 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4279 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004280 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004281 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004282 .phy_read = mv88e6xxx_g2_smi_phy_read,
4283 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004284 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004285 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004286 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004287 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004288 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004289 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004290 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004291 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004292 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004293 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004294 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004295 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004296 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004297 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004298 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004299 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004300 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004301 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4302 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004303 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004304 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4305 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004306 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004307 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004308 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004309 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004310 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4311 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004312 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004313 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004314 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004315 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004316 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004317};
4318
4319static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004320 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004321 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4322 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004323 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004324 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4325 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004326 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004327 .phy_read = mv88e6xxx_g2_smi_phy_read,
4328 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004329 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004330 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004331 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004332 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004333 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004334 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004335 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004336 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004337 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004338 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004339 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004340 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004341 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004342 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004343 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004344 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004345 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004346 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004347 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4348 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004349 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004350 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4351 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004352 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004353 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004354 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004355 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004356 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004357 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4358 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004359 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004360 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004361 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004362 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4363 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4364 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4365 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004366 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004367 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004368 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004369 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004370 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004371 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004372 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004373 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4374 .serdes_get_strings = mv88e6352_serdes_get_strings,
4375 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004376 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4377 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004378 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004379};
4380
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004381static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004382 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004383 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004384 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004385 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4386 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004387 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4388 .phy_read = mv88e6xxx_g2_smi_phy_read,
4389 .phy_write = mv88e6xxx_g2_smi_phy_write,
4390 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004391 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004392 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004393 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004394 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004395 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004396 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004397 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004398 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004399 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004400 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004401 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004402 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004403 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004404 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004405 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004406 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004407 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004408 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004409 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004410 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4411 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004412 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004413 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4414 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004415 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004416 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004417 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004418 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004419 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004420 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4421 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004422 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4423 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004424 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004425 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004426 /* Check status register pause & lpa register */
4427 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4428 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4429 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4430 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004431 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004432 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004433 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004434 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004435 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004436 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004437 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4438 .serdes_get_strings = mv88e6390_serdes_get_strings,
4439 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004440 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4441 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004442 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004443};
4444
4445static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004446 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004447 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004448 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004449 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4450 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004451 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4452 .phy_read = mv88e6xxx_g2_smi_phy_read,
4453 .phy_write = mv88e6xxx_g2_smi_phy_write,
4454 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004455 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004456 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004457 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004458 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004459 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004460 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004461 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004462 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004463 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004464 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004465 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004466 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004467 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004468 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004469 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004470 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004471 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004472 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004473 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004474 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4475 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004476 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004477 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4478 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004479 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004480 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004481 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004482 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004483 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004484 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4485 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004486 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4487 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004488 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004489 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004490 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4491 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4492 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4493 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004494 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004495 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004496 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004497 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4498 .serdes_get_strings = mv88e6390_serdes_get_strings,
4499 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004500 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4501 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004502 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004503 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004504 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004505 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004506};
4507
Vivien Didelotf81ec902016-05-09 13:22:58 -04004508static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4509 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004510 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004511 .family = MV88E6XXX_FAMILY_6097,
4512 .name = "Marvell 88E6085",
4513 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004514 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004515 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004516 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004517 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004518 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004519 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004520 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004521 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004522 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004523 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004524 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004525 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004526 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004527 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004528 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004529 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004530 },
4531
4532 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004533 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004534 .family = MV88E6XXX_FAMILY_6095,
4535 .name = "Marvell 88E6095/88E6095F",
4536 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004537 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004538 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004539 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004540 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004541 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004542 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004543 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004544 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004545 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004546 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004547 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004548 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004549 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004550 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004551 },
4552
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004553 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004554 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004555 .family = MV88E6XXX_FAMILY_6097,
4556 .name = "Marvell 88E6097/88E6097F",
4557 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004558 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004559 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004560 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004561 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004562 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004563 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004564 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004565 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004566 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004567 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004568 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004569 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004570 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004571 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004572 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004573 .ops = &mv88e6097_ops,
4574 },
4575
Vivien Didelotf81ec902016-05-09 13:22:58 -04004576 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004577 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004578 .family = MV88E6XXX_FAMILY_6165,
4579 .name = "Marvell 88E6123",
4580 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004581 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004582 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004583 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004584 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004585 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004586 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004587 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004588 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004589 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004590 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004591 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004592 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004593 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004594 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004595 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004596 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004597 },
4598
4599 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004600 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004601 .family = MV88E6XXX_FAMILY_6185,
4602 .name = "Marvell 88E6131",
4603 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004604 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004605 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004606 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004607 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004608 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004609 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004610 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004611 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004612 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004613 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004614 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004615 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004616 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004617 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004618 },
4619
Vivien Didelot990e27b2017-03-28 13:50:32 -04004620 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004621 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004622 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004623 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004624 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004625 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004626 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004627 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004628 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004629 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004630 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004631 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004632 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004633 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004634 .age_time_coeff = 3750,
4635 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004636 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004637 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004638 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004639 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004640 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004641 .ops = &mv88e6141_ops,
4642 },
4643
Vivien Didelotf81ec902016-05-09 13:22:58 -04004644 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004645 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004646 .family = MV88E6XXX_FAMILY_6165,
4647 .name = "Marvell 88E6161",
4648 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004649 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004650 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004651 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004652 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004653 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004654 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004655 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004656 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004657 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004658 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004659 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004660 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004661 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004662 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004663 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004664 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004665 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004666 },
4667
4668 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004669 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004670 .family = MV88E6XXX_FAMILY_6165,
4671 .name = "Marvell 88E6165",
4672 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004673 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004674 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004675 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004676 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004677 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004678 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004679 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004680 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004681 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004682 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004683 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004684 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004685 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004686 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004687 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004688 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004689 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004690 },
4691
4692 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004693 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004694 .family = MV88E6XXX_FAMILY_6351,
4695 .name = "Marvell 88E6171",
4696 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004697 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004698 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004699 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004700 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004701 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004702 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004703 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004704 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004705 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004706 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004707 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004708 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004709 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004710 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004711 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004712 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004713 },
4714
4715 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004716 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004717 .family = MV88E6XXX_FAMILY_6352,
4718 .name = "Marvell 88E6172",
4719 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004720 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004721 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004722 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004723 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004724 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004725 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004726 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004727 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004728 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004729 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004730 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004731 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004732 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004733 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004734 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004735 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004736 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004737 },
4738
4739 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004740 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004741 .family = MV88E6XXX_FAMILY_6351,
4742 .name = "Marvell 88E6175",
4743 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004744 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004745 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004746 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004747 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004748 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004749 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004750 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004751 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004752 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004753 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004754 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004755 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004756 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004757 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004758 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004759 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004760 },
4761
4762 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004763 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004764 .family = MV88E6XXX_FAMILY_6352,
4765 .name = "Marvell 88E6176",
4766 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004767 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004768 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004769 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004770 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004771 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004772 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004773 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004774 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004775 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004776 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004777 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004778 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004779 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004780 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004781 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004782 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004783 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004784 },
4785
4786 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004787 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004788 .family = MV88E6XXX_FAMILY_6185,
4789 .name = "Marvell 88E6185",
4790 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004791 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004792 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004793 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004794 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004795 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004796 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004797 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004798 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004799 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004800 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004801 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004802 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004803 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004804 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004805 },
4806
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004807 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004808 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004809 .family = MV88E6XXX_FAMILY_6390,
4810 .name = "Marvell 88E6190",
4811 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004812 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004813 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004814 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004815 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004816 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004817 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004818 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004819 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004820 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004821 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004822 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004823 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004824 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004825 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004826 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004827 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004828 .ops = &mv88e6190_ops,
4829 },
4830
4831 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004832 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004833 .family = MV88E6XXX_FAMILY_6390,
4834 .name = "Marvell 88E6190X",
4835 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004836 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004837 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004838 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004839 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004840 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004841 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004842 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004843 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004844 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004845 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004846 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004847 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004848 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004849 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004850 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004851 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004852 .ops = &mv88e6190x_ops,
4853 },
4854
4855 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004856 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004857 .family = MV88E6XXX_FAMILY_6390,
4858 .name = "Marvell 88E6191",
4859 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004860 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004861 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004862 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004863 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004864 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004865 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004866 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004867 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004868 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004869 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004870 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004871 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004872 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004873 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004874 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004875 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004876 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004877 },
4878
Hubert Feurstein49022642019-07-31 10:23:46 +02004879 [MV88E6220] = {
4880 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4881 .family = MV88E6XXX_FAMILY_6250,
4882 .name = "Marvell 88E6220",
4883 .num_databases = 64,
4884
4885 /* Ports 2-4 are not routed to pins
4886 * => usable ports 0, 1, 5, 6
4887 */
4888 .num_ports = 7,
4889 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004890 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004891 .max_vid = 4095,
4892 .port_base_addr = 0x08,
4893 .phy_base_addr = 0x00,
4894 .global1_addr = 0x0f,
4895 .global2_addr = 0x07,
4896 .age_time_coeff = 15000,
4897 .g1_irqs = 9,
4898 .g2_irqs = 10,
4899 .atu_move_port_mask = 0xf,
4900 .dual_chip = true,
4901 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004902 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004903 .ops = &mv88e6250_ops,
4904 },
4905
Vivien Didelotf81ec902016-05-09 13:22:58 -04004906 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004907 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004908 .family = MV88E6XXX_FAMILY_6352,
4909 .name = "Marvell 88E6240",
4910 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004911 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004912 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004913 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004914 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004915 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004916 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004917 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004918 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004919 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004920 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004921 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004922 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004923 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004924 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004925 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004926 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004927 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004928 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004929 },
4930
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004931 [MV88E6250] = {
4932 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4933 .family = MV88E6XXX_FAMILY_6250,
4934 .name = "Marvell 88E6250",
4935 .num_databases = 64,
4936 .num_ports = 7,
4937 .num_internal_phys = 5,
4938 .max_vid = 4095,
4939 .port_base_addr = 0x08,
4940 .phy_base_addr = 0x00,
4941 .global1_addr = 0x0f,
4942 .global2_addr = 0x07,
4943 .age_time_coeff = 15000,
4944 .g1_irqs = 9,
4945 .g2_irqs = 10,
4946 .atu_move_port_mask = 0xf,
4947 .dual_chip = true,
4948 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004949 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004950 .ops = &mv88e6250_ops,
4951 },
4952
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004953 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004954 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004955 .family = MV88E6XXX_FAMILY_6390,
4956 .name = "Marvell 88E6290",
4957 .num_databases = 4096,
4958 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004959 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004960 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004961 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004962 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004963 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004964 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004965 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004966 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004967 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004968 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004969 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004970 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004971 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004972 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004973 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004974 .ops = &mv88e6290_ops,
4975 },
4976
Vivien Didelotf81ec902016-05-09 13:22:58 -04004977 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004978 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004979 .family = MV88E6XXX_FAMILY_6320,
4980 .name = "Marvell 88E6320",
4981 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004982 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004983 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004984 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004985 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004986 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004987 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004988 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004989 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004990 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004991 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004992 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004993 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004994 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004995 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004996 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004997 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004998 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004999 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005000 },
5001
5002 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005003 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005004 .family = MV88E6XXX_FAMILY_6320,
5005 .name = "Marvell 88E6321",
5006 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005007 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005008 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005009 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005010 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005011 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005012 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005013 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005014 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005015 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005016 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005017 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005018 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005019 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005020 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005021 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005022 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005023 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005024 },
5025
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005026 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005027 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005028 .family = MV88E6XXX_FAMILY_6341,
5029 .name = "Marvell 88E6341",
5030 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005031 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005032 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005033 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005034 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005035 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005036 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005037 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005038 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005039 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005040 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005041 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005042 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005043 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005044 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005045 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005046 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005047 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005048 .ops = &mv88e6341_ops,
5049 },
5050
Vivien Didelotf81ec902016-05-09 13:22:58 -04005051 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005052 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005053 .family = MV88E6XXX_FAMILY_6351,
5054 .name = "Marvell 88E6350",
5055 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005056 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005057 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005058 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005059 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005060 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005061 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005062 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005063 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005064 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005065 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005066 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005067 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005068 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005069 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005070 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005071 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005072 },
5073
5074 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005075 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005076 .family = MV88E6XXX_FAMILY_6351,
5077 .name = "Marvell 88E6351",
5078 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005079 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005080 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005081 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005082 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005083 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005084 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005085 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005086 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005087 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005088 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005089 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005090 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005091 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005092 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005093 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005094 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005095 },
5096
5097 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005098 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005099 .family = MV88E6XXX_FAMILY_6352,
5100 .name = "Marvell 88E6352",
5101 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005102 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005103 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005104 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005105 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005106 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005107 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005108 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005109 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005110 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005111 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005112 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005113 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005114 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005115 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005116 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005117 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005118 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005119 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005120 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005121 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005122 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005123 .family = MV88E6XXX_FAMILY_6390,
5124 .name = "Marvell 88E6390",
5125 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005126 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005127 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005128 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005129 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005130 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005131 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005132 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005133 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005134 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005135 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005136 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005137 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005138 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005139 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005140 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005141 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005142 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005143 .ops = &mv88e6390_ops,
5144 },
5145 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005146 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005147 .family = MV88E6XXX_FAMILY_6390,
5148 .name = "Marvell 88E6390X",
5149 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005150 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005151 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005152 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005153 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005154 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005155 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005156 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005157 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005158 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005159 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005160 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005161 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005162 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005163 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005164 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005165 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005166 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005167 .ops = &mv88e6390x_ops,
5168 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005169};
5170
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005171static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005172{
Vivien Didelota439c062016-04-17 13:23:58 -04005173 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005174
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005175 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5176 if (mv88e6xxx_table[i].prod_num == prod_num)
5177 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005178
Vivien Didelotb9b37712015-10-30 19:39:48 -04005179 return NULL;
5180}
5181
Vivien Didelotfad09c72016-06-21 12:28:20 -04005182static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005183{
5184 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005185 unsigned int prod_num, rev;
5186 u16 id;
5187 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005188
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005189 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005190 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005191 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005192 if (err)
5193 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005194
Vivien Didelot107fcc12017-06-12 12:37:36 -04005195 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5196 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005197
5198 info = mv88e6xxx_lookup_info(prod_num);
5199 if (!info)
5200 return -ENODEV;
5201
Vivien Didelotcaac8542016-06-20 13:14:09 -04005202 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005203 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005204
Vivien Didelotca070c12016-09-02 14:45:34 -04005205 err = mv88e6xxx_g2_require(chip);
5206 if (err)
5207 return err;
5208
Vivien Didelotfad09c72016-06-21 12:28:20 -04005209 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5210 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005211
5212 return 0;
5213}
5214
Vivien Didelotfad09c72016-06-21 12:28:20 -04005215static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005216{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005217 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005218
Vivien Didelotfad09c72016-06-21 12:28:20 -04005219 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5220 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005221 return NULL;
5222
Vivien Didelotfad09c72016-06-21 12:28:20 -04005223 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005224
Vivien Didelotfad09c72016-06-21 12:28:20 -04005225 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005226 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005227 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005228
Vivien Didelotfad09c72016-06-21 12:28:20 -04005229 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005230}
5231
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005232static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005233 int port,
5234 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005235{
Vivien Didelot04bed142016-08-31 18:06:13 -04005236 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005237
Andrew Lunn443d5a12016-12-03 04:35:18 +01005238 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005239}
5240
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005241static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
5242 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005243{
Vivien Didelot04bed142016-08-31 18:06:13 -04005244 struct mv88e6xxx_chip *chip = ds->priv;
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005245 int err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005246
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005247 mv88e6xxx_reg_lock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005248 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
5249 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005250 mv88e6xxx_reg_unlock(chip);
Vladimir Olteana52b2da2021-01-09 02:01:52 +02005251
5252 return err;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005253}
5254
5255static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5256 const struct switchdev_obj_port_mdb *mdb)
5257{
Vivien Didelot04bed142016-08-31 18:06:13 -04005258 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005259 int err;
5260
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005261 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005262 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005263 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005264
5265 return err;
5266}
5267
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005268static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5269 struct dsa_mall_mirror_tc_entry *mirror,
5270 bool ingress)
5271{
5272 enum mv88e6xxx_egress_direction direction = ingress ?
5273 MV88E6XXX_EGRESS_DIR_INGRESS :
5274 MV88E6XXX_EGRESS_DIR_EGRESS;
5275 struct mv88e6xxx_chip *chip = ds->priv;
5276 bool other_mirrors = false;
5277 int i;
5278 int err;
5279
5280 if (!chip->info->ops->set_egress_port)
5281 return -EOPNOTSUPP;
5282
5283 mutex_lock(&chip->reg_lock);
5284 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5285 mirror->to_local_port) {
5286 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5287 other_mirrors |= ingress ?
5288 chip->ports[i].mirror_ingress :
5289 chip->ports[i].mirror_egress;
5290
5291 /* Can't change egress port when other mirror is active */
5292 if (other_mirrors) {
5293 err = -EBUSY;
5294 goto out;
5295 }
5296
5297 err = chip->info->ops->set_egress_port(chip,
5298 direction,
5299 mirror->to_local_port);
5300 if (err)
5301 goto out;
5302 }
5303
5304 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5305out:
5306 mutex_unlock(&chip->reg_lock);
5307
5308 return err;
5309}
5310
5311static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5312 struct dsa_mall_mirror_tc_entry *mirror)
5313{
5314 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5315 MV88E6XXX_EGRESS_DIR_INGRESS :
5316 MV88E6XXX_EGRESS_DIR_EGRESS;
5317 struct mv88e6xxx_chip *chip = ds->priv;
5318 bool other_mirrors = false;
5319 int i;
5320
5321 mutex_lock(&chip->reg_lock);
5322 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5323 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5324
5325 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5326 other_mirrors |= mirror->ingress ?
5327 chip->ports[i].mirror_ingress :
5328 chip->ports[i].mirror_egress;
5329
5330 /* Reset egress port when no other mirror is active */
5331 if (!other_mirrors) {
5332 if (chip->info->ops->set_egress_port(chip,
5333 direction,
5334 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005335 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005336 dev_err(ds->dev, "failed to set egress port\n");
5337 }
5338
5339 mutex_unlock(&chip->reg_lock);
5340}
5341
Russell King4f859012019-02-20 15:35:05 -08005342static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5343 bool unicast, bool multicast)
5344{
5345 struct mv88e6xxx_chip *chip = ds->priv;
5346 int err = -EOPNOTSUPP;
5347
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005348 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005349 if (chip->info->ops->port_set_egress_floods)
5350 err = chip->info->ops->port_set_egress_floods(chip, port,
5351 unicast,
5352 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005353 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005354
5355 return err;
5356}
5357
Florian Fainellia82f67a2017-01-08 14:52:08 -08005358static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005359 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005360 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005361 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005362 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005363 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005364 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005365 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005366 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5367 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005368 .get_strings = mv88e6xxx_get_strings,
5369 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5370 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005371 .port_enable = mv88e6xxx_port_enable,
5372 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02005373 .port_max_mtu = mv88e6xxx_get_max_mtu,
5374 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04005375 .get_mac_eee = mv88e6xxx_get_mac_eee,
5376 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005377 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005378 .get_eeprom = mv88e6xxx_get_eeprom,
5379 .set_eeprom = mv88e6xxx_set_eeprom,
5380 .get_regs_len = mv88e6xxx_get_regs_len,
5381 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005382 .get_rxnfc = mv88e6xxx_get_rxnfc,
5383 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005384 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005385 .port_bridge_join = mv88e6xxx_port_bridge_join,
5386 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005387 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005388 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005389 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005390 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5391 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5392 .port_vlan_add = mv88e6xxx_port_vlan_add,
5393 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005394 .port_fdb_add = mv88e6xxx_port_fdb_add,
5395 .port_fdb_del = mv88e6xxx_port_fdb_del,
5396 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005397 .port_mdb_add = mv88e6xxx_port_mdb_add,
5398 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005399 .port_mirror_add = mv88e6xxx_port_mirror_add,
5400 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005401 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5402 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005403 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5404 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5405 .port_txtstamp = mv88e6xxx_port_txtstamp,
5406 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5407 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005408 .devlink_param_get = mv88e6xxx_devlink_param_get,
5409 .devlink_param_set = mv88e6xxx_devlink_param_set,
Andrew Lunn93157302020-09-18 21:11:09 +02005410 .devlink_info_get = mv88e6xxx_devlink_info_get,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005411};
5412
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005413static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005414{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005415 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005416 struct dsa_switch *ds;
5417
Vivien Didelot7e99e342019-10-21 16:51:30 -04005418 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005419 if (!ds)
5420 return -ENOMEM;
5421
Vivien Didelot7e99e342019-10-21 16:51:30 -04005422 ds->dev = dev;
5423 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005424 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005425 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005426 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005427 ds->ageing_time_min = chip->info->age_time_coeff;
5428 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005429
5430 dev_set_drvdata(dev, ds);
5431
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005432 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005433}
5434
Vivien Didelotfad09c72016-06-21 12:28:20 -04005435static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005436{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005437 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005438}
5439
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005440static const void *pdata_device_get_match_data(struct device *dev)
5441{
5442 const struct of_device_id *matches = dev->driver->of_match_table;
5443 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5444
5445 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5446 matches++) {
5447 if (!strcmp(pdata->compatible, matches->compatible))
5448 return matches->data;
5449 }
5450 return NULL;
5451}
5452
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005453/* There is no suspend to RAM support at DSA level yet, the switch configuration
5454 * would be lost after a power cycle so prevent it to be suspended.
5455 */
5456static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5457{
5458 return -EOPNOTSUPP;
5459}
5460
5461static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5462{
5463 return 0;
5464}
5465
5466static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5467
Vivien Didelot57d32312016-06-20 13:13:58 -04005468static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005469{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005470 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005471 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005472 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005473 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005474 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005475 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005476 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005477
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005478 if (!np && !pdata)
5479 return -EINVAL;
5480
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005481 if (np)
5482 compat_info = of_device_get_match_data(dev);
5483
5484 if (pdata) {
5485 compat_info = pdata_device_get_match_data(dev);
5486
5487 if (!pdata->netdev)
5488 return -EINVAL;
5489
5490 for (port = 0; port < DSA_MAX_PORTS; port++) {
5491 if (!(pdata->enabled_ports & (1 << port)))
5492 continue;
5493 if (strcmp(pdata->cd.port_names[port], "cpu"))
5494 continue;
5495 pdata->cd.netdev[port] = &pdata->netdev->dev;
5496 break;
5497 }
5498 }
5499
Vivien Didelotcaac8542016-06-20 13:14:09 -04005500 if (!compat_info)
5501 return -EINVAL;
5502
Vivien Didelotfad09c72016-06-21 12:28:20 -04005503 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005504 if (!chip) {
5505 err = -ENOMEM;
5506 goto out;
5507 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005508
Vivien Didelotfad09c72016-06-21 12:28:20 -04005509 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005510
Vivien Didelotfad09c72016-06-21 12:28:20 -04005511 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005512 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005513 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005514
Andrew Lunnb4308f02016-11-21 23:26:55 +01005515 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005516 if (IS_ERR(chip->reset)) {
5517 err = PTR_ERR(chip->reset);
5518 goto out;
5519 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005520 if (chip->reset)
5521 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005522
Vivien Didelotfad09c72016-06-21 12:28:20 -04005523 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005524 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005525 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005526
Vivien Didelote57e5e72016-08-15 17:19:00 -04005527 mv88e6xxx_phy_init(chip);
5528
Andrew Lunn00baabe2018-05-19 22:31:35 +02005529 if (chip->info->ops->get_eeprom) {
5530 if (np)
5531 of_property_read_u32(np, "eeprom-length",
5532 &chip->eeprom_len);
5533 else
5534 chip->eeprom_len = pdata->eeprom_len;
5535 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005536
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005537 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005538 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005539 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005540 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005541 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005542
Andrew Lunna27415d2019-05-01 00:10:50 +02005543 if (np) {
5544 chip->irq = of_irq_get(np, 0);
5545 if (chip->irq == -EPROBE_DEFER) {
5546 err = chip->irq;
5547 goto out;
5548 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005549 }
5550
Andrew Lunna27415d2019-05-01 00:10:50 +02005551 if (pdata)
5552 chip->irq = pdata->irq;
5553
Andrew Lunn294d7112018-02-22 22:58:32 +01005554 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005555 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005556 * controllers
5557 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005558 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005559 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005560 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005561 else
5562 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005563 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005564
Andrew Lunn294d7112018-02-22 22:58:32 +01005565 if (err)
5566 goto out;
5567
5568 if (chip->info->g2_irqs > 0) {
5569 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005570 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005571 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005572 }
5573
Andrew Lunn294d7112018-02-22 22:58:32 +01005574 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5575 if (err)
5576 goto out_g2_irq;
5577
5578 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5579 if (err)
5580 goto out_g1_atu_prob_irq;
5581
Andrew Lunna3c53be52017-01-24 14:53:50 +01005582 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005583 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005584 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005585
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005586 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005587 if (err)
5588 goto out_mdio;
5589
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005590 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005591
5592out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005593 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005594out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005595 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005596out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005597 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005598out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005599 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005600 mv88e6xxx_g2_irq_free(chip);
5601out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005602 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005603 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005604 else
5605 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005606out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005607 if (pdata)
5608 dev_put(pdata->netdev);
5609
Andrew Lunndc30c352016-10-16 19:56:49 +02005610 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005611}
5612
5613static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5614{
5615 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005616 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005617
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005618 if (chip->info->ptp_support) {
5619 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005620 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005621 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005622
Andrew Lunn930188c2016-08-22 16:01:03 +02005623 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005624 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005625 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005626
Andrew Lunn76f38f12018-03-17 20:21:09 +01005627 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5628 mv88e6xxx_g1_atu_prob_irq_free(chip);
5629
5630 if (chip->info->g2_irqs > 0)
5631 mv88e6xxx_g2_irq_free(chip);
5632
Andrew Lunn76f38f12018-03-17 20:21:09 +01005633 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005634 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005635 else
5636 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005637}
5638
5639static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005640 {
5641 .compatible = "marvell,mv88e6085",
5642 .data = &mv88e6xxx_table[MV88E6085],
5643 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005644 {
5645 .compatible = "marvell,mv88e6190",
5646 .data = &mv88e6xxx_table[MV88E6190],
5647 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005648 {
5649 .compatible = "marvell,mv88e6250",
5650 .data = &mv88e6xxx_table[MV88E6250],
5651 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005652 { /* sentinel */ },
5653};
5654
5655MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5656
5657static struct mdio_driver mv88e6xxx_driver = {
5658 .probe = mv88e6xxx_probe,
5659 .remove = mv88e6xxx_remove,
5660 .mdiodrv.driver = {
5661 .name = "mv88e6085",
5662 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005663 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005664 },
5665};
5666
Andrew Lunn7324d502019-04-27 19:19:10 +02005667mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005668
5669MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5670MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5671MODULE_LICENSE("GPL");