blob: 54aa942eedaa6c28d15db3acb95b59520726ee40 [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,
1532 u16 vid_begin, u16 vid_end)
1533{
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
Andrew Lunndb06ae412017-09-25 23:32:20 +02001538 /* DSA and CPU ports have to be members of multiple vlans */
1539 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1540 return 0;
1541
Vivien Didelotda9c3592016-02-12 12:09:40 -05001542 if (!vid_begin)
1543 return -EOPNOTSUPP;
1544
Vivien Didelot425d2d32019-08-01 14:36:34 -04001545 vlan.vid = vid_begin - 1;
1546 vlan.valid = false;
1547
Vivien Didelotda9c3592016-02-12 12:09:40 -05001548 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001549 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001550 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001551 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001552
1553 if (!vlan.valid)
1554 break;
1555
1556 if (vlan.vid > vid_end)
1557 break;
1558
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001559 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001560 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1561 continue;
1562
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001563 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001564 continue;
1565
Vivien Didelotbd00e052017-05-01 14:05:11 -04001566 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001567 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001568 continue;
1569
Vivien Didelotc8652c82017-10-16 11:12:19 -04001570 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001571 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001572 break; /* same bridge, check next VLAN */
1573
Vivien Didelotc8652c82017-10-16 11:12:19 -04001574 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001575 continue;
1576
Andrew Lunn743fcc22017-11-09 22:29:54 +01001577 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1578 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001579 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001580 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001581 }
1582 } while (vlan.vid < vid_end);
1583
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001584 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001585}
1586
Vivien Didelotf81ec902016-05-09 13:22:58 -04001587static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
Vladimir Oltean2e554a72020-10-03 01:06:46 +03001588 bool vlan_filtering,
1589 struct switchdev_trans *trans)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001590{
Vivien Didelot04bed142016-08-31 18:06:13 -04001591 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001592 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1593 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001594 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001595
Vladimir Oltean2e554a72020-10-03 01:06:46 +03001596 if (switchdev_trans_ph_prepare(trans))
Tobias Waldekranze545f862020-11-10 19:57:20 +01001597 return mv88e6xxx_max_vid(chip) ? 0 : -EOPNOTSUPP;
Vivien Didelot54d77b52016-05-09 13:22:47 -04001598
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001599 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001600 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001601 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001602
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001603 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001604}
1605
Vivien Didelot57d32312016-06-20 13:13:58 -04001606static int
1607mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001608 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001609{
Vivien Didelot04bed142016-08-31 18:06:13 -04001610 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001611 int err;
1612
Tobias Waldekranze545f862020-11-10 19:57:20 +01001613 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001614 return -EOPNOTSUPP;
1615
Vivien Didelotda9c3592016-02-12 12:09:40 -05001616 /* If the requested port doesn't belong to the same bridge as the VLAN
1617 * members, do not support it (yet) and fallback to software VLAN.
1618 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001619 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001620 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1621 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001622 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001623
Vivien Didelot76e398a2015-11-01 12:33:55 -05001624 /* We don't need any dynamic resource from the kernel (yet),
1625 * so skip the prepare phase.
1626 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001627 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001628}
1629
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001630static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1631 const unsigned char *addr, u16 vid,
1632 u8 state)
1633{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001634 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001635 struct mv88e6xxx_vtu_entry vlan;
1636 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001637 int err;
1638
1639 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001640 if (vid == 0) {
1641 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1642 if (err)
1643 return err;
1644 } else {
1645 vlan.vid = vid - 1;
1646 vlan.valid = false;
1647
1648 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1649 if (err)
1650 return err;
1651
1652 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1653 if (vlan.vid != vid || !vlan.valid)
1654 return -EOPNOTSUPP;
1655
1656 fid = vlan.fid;
1657 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001658
Vivien Didelotd8291a92019-09-07 16:00:47 -04001659 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001660 ether_addr_copy(entry.mac, addr);
1661 eth_addr_dec(entry.mac);
1662
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001663 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001664 if (err)
1665 return err;
1666
1667 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001668 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001669 memset(&entry, 0, sizeof(entry));
1670 ether_addr_copy(entry.mac, addr);
1671 }
1672
1673 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001674 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001675 entry.portvec &= ~BIT(port);
1676 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001677 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001678 } else {
DENG Qingfangf72f2fb2021-01-30 21:43:34 +08001679 if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
1680 entry.portvec = BIT(port);
1681 else
1682 entry.portvec |= BIT(port);
1683
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001684 entry.state = state;
1685 }
1686
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001687 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001688}
1689
Vivien Didelotda7dc872019-09-07 16:00:49 -04001690static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1691 const struct mv88e6xxx_policy *policy)
1692{
1693 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1694 enum mv88e6xxx_policy_action action = policy->action;
1695 const u8 *addr = policy->addr;
1696 u16 vid = policy->vid;
1697 u8 state;
1698 int err;
1699 int id;
1700
1701 if (!chip->info->ops->port_set_policy)
1702 return -EOPNOTSUPP;
1703
1704 switch (mapping) {
1705 case MV88E6XXX_POLICY_MAPPING_DA:
1706 case MV88E6XXX_POLICY_MAPPING_SA:
1707 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1708 state = 0; /* Dissociate the port and address */
1709 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1710 is_multicast_ether_addr(addr))
1711 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1712 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1713 is_unicast_ether_addr(addr))
1714 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1715 else
1716 return -EOPNOTSUPP;
1717
1718 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1719 state);
1720 if (err)
1721 return err;
1722 break;
1723 default:
1724 return -EOPNOTSUPP;
1725 }
1726
1727 /* Skip the port's policy clearing if the mapping is still in use */
1728 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1729 idr_for_each_entry(&chip->policies, policy, id)
1730 if (policy->port == port &&
1731 policy->mapping == mapping &&
1732 policy->action != action)
1733 return 0;
1734
1735 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1736}
1737
1738static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1739 struct ethtool_rx_flow_spec *fs)
1740{
1741 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1742 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1743 enum mv88e6xxx_policy_mapping mapping;
1744 enum mv88e6xxx_policy_action action;
1745 struct mv88e6xxx_policy *policy;
1746 u16 vid = 0;
1747 u8 *addr;
1748 int err;
1749 int id;
1750
1751 if (fs->location != RX_CLS_LOC_ANY)
1752 return -EINVAL;
1753
1754 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1755 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1756 else
1757 return -EOPNOTSUPP;
1758
1759 switch (fs->flow_type & ~FLOW_EXT) {
1760 case ETHER_FLOW:
1761 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1762 is_zero_ether_addr(mac_mask->h_source)) {
1763 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1764 addr = mac_entry->h_dest;
1765 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1766 !is_zero_ether_addr(mac_mask->h_source)) {
1767 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1768 addr = mac_entry->h_source;
1769 } else {
1770 /* Cannot support DA and SA mapping in the same rule */
1771 return -EOPNOTSUPP;
1772 }
1773 break;
1774 default:
1775 return -EOPNOTSUPP;
1776 }
1777
1778 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
Andrew Lunn04844282020-07-05 21:38:08 +02001779 if (fs->m_ext.vlan_tci != htons(0xffff))
Vivien Didelotda7dc872019-09-07 16:00:49 -04001780 return -EOPNOTSUPP;
1781 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1782 }
1783
1784 idr_for_each_entry(&chip->policies, policy, id) {
1785 if (policy->port == port && policy->mapping == mapping &&
1786 policy->action == action && policy->vid == vid &&
1787 ether_addr_equal(policy->addr, addr))
1788 return -EEXIST;
1789 }
1790
1791 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1792 if (!policy)
1793 return -ENOMEM;
1794
1795 fs->location = 0;
1796 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1797 GFP_KERNEL);
1798 if (err) {
1799 devm_kfree(chip->dev, policy);
1800 return err;
1801 }
1802
1803 memcpy(&policy->fs, fs, sizeof(*fs));
1804 ether_addr_copy(policy->addr, addr);
1805 policy->mapping = mapping;
1806 policy->action = action;
1807 policy->port = port;
1808 policy->vid = vid;
1809
1810 err = mv88e6xxx_policy_apply(chip, port, policy);
1811 if (err) {
1812 idr_remove(&chip->policies, fs->location);
1813 devm_kfree(chip->dev, policy);
1814 return err;
1815 }
1816
1817 return 0;
1818}
1819
1820static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1821 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1822{
1823 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1824 struct mv88e6xxx_chip *chip = ds->priv;
1825 struct mv88e6xxx_policy *policy;
1826 int err;
1827 int id;
1828
1829 mv88e6xxx_reg_lock(chip);
1830
1831 switch (rxnfc->cmd) {
1832 case ETHTOOL_GRXCLSRLCNT:
1833 rxnfc->data = 0;
1834 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1835 rxnfc->rule_cnt = 0;
1836 idr_for_each_entry(&chip->policies, policy, id)
1837 if (policy->port == port)
1838 rxnfc->rule_cnt++;
1839 err = 0;
1840 break;
1841 case ETHTOOL_GRXCLSRULE:
1842 err = -ENOENT;
1843 policy = idr_find(&chip->policies, fs->location);
1844 if (policy) {
1845 memcpy(fs, &policy->fs, sizeof(*fs));
1846 err = 0;
1847 }
1848 break;
1849 case ETHTOOL_GRXCLSRLALL:
1850 rxnfc->data = 0;
1851 rxnfc->rule_cnt = 0;
1852 idr_for_each_entry(&chip->policies, policy, id)
1853 if (policy->port == port)
1854 rule_locs[rxnfc->rule_cnt++] = id;
1855 err = 0;
1856 break;
1857 default:
1858 err = -EOPNOTSUPP;
1859 break;
1860 }
1861
1862 mv88e6xxx_reg_unlock(chip);
1863
1864 return err;
1865}
1866
1867static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1868 struct ethtool_rxnfc *rxnfc)
1869{
1870 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1871 struct mv88e6xxx_chip *chip = ds->priv;
1872 struct mv88e6xxx_policy *policy;
1873 int err;
1874
1875 mv88e6xxx_reg_lock(chip);
1876
1877 switch (rxnfc->cmd) {
1878 case ETHTOOL_SRXCLSRLINS:
1879 err = mv88e6xxx_policy_insert(chip, port, fs);
1880 break;
1881 case ETHTOOL_SRXCLSRLDEL:
1882 err = -ENOENT;
1883 policy = idr_remove(&chip->policies, fs->location);
1884 if (policy) {
1885 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1886 err = mv88e6xxx_policy_apply(chip, port, policy);
1887 devm_kfree(chip->dev, policy);
1888 }
1889 break;
1890 default:
1891 err = -EOPNOTSUPP;
1892 break;
1893 }
1894
1895 mv88e6xxx_reg_unlock(chip);
1896
1897 return err;
1898}
1899
Andrew Lunn87fa8862017-11-09 22:29:56 +01001900static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1901 u16 vid)
1902{
1903 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1904 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1905
1906 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1907}
1908
1909static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1910{
1911 int port;
1912 int err;
1913
1914 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1915 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1916 if (err)
1917 return err;
1918 }
1919
1920 return 0;
1921}
1922
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001923static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001924 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001925{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001926 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001927 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001928 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001929
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001930 if (!vid)
1931 return -EOPNOTSUPP;
1932
1933 vlan.vid = vid - 1;
1934 vlan.valid = false;
1935
1936 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001937 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001938 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001939
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001940 if (vlan.vid != vid || !vlan.valid) {
1941 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001942
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001943 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1944 if (err)
1945 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001946
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001947 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1948 if (i == port)
1949 vlan.member[i] = member;
1950 else
1951 vlan.member[i] = non_member;
1952
1953 vlan.vid = vid;
1954 vlan.valid = true;
1955
1956 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1957 if (err)
1958 return err;
1959
1960 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1961 if (err)
1962 return err;
1963 } else if (vlan.member[port] != member) {
1964 vlan.member[port] = member;
1965
1966 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1967 if (err)
1968 return err;
Russell King933b4422020-02-26 17:14:26 +00001969 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001970 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1971 port, vid);
1972 }
1973
1974 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001975}
1976
Vivien Didelotf81ec902016-05-09 13:22:58 -04001977static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001978 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001979{
Vivien Didelot04bed142016-08-31 18:06:13 -04001980 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001981 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1982 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001983 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001984 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001985 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001986
Tobias Waldekranze545f862020-11-10 19:57:20 +01001987 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04001988 return;
1989
Vivien Didelotc91498e2017-06-07 18:12:13 -04001990 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001991 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001992 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001993 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001994 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001995 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001996
Russell King933b4422020-02-26 17:14:26 +00001997 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1998 * and then the CPU port. Do not warn for duplicates for the CPU port.
1999 */
2000 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
2001
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002002 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002003
Vivien Didelot4d5770b2016-04-06 11:55:05 -04002004 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00002005 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04002006 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
2007 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05002008
Vivien Didelot77064f32016-11-04 03:23:30 +01002009 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04002010 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
2011 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04002012
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002013 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04002014}
2015
Vivien Didelot521098922019-08-01 14:36:36 -04002016static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
2017 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002018{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04002019 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002020 int i, err;
2021
Vivien Didelot521098922019-08-01 14:36:36 -04002022 if (!vid)
2023 return -EOPNOTSUPP;
2024
2025 vlan.vid = vid - 1;
2026 vlan.valid = false;
2027
2028 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002029 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002030 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002031
Vivien Didelot521098922019-08-01 14:36:36 -04002032 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2033 * tell switchdev that this VLAN is likely handled in software.
2034 */
2035 if (vlan.vid != vid || !vlan.valid ||
2036 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002037 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002038
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002039 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002040
2041 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002042 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002043 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002044 if (vlan.member[i] !=
2045 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002046 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002047 break;
2048 }
2049 }
2050
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002051 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002052 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002053 return err;
2054
Vivien Didelote606ca32017-03-11 16:12:55 -05002055 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002056}
2057
Vivien Didelotf81ec902016-05-09 13:22:58 -04002058static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2059 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002060{
Vivien Didelot04bed142016-08-31 18:06:13 -04002061 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002062 u16 pvid, vid;
2063 int err = 0;
2064
Tobias Waldekranze545f862020-11-10 19:57:20 +01002065 if (!mv88e6xxx_max_vid(chip))
Vivien Didelot54d77b52016-05-09 13:22:47 -04002066 return -EOPNOTSUPP;
2067
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002068 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002069
Vivien Didelot77064f32016-11-04 03:23:30 +01002070 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002071 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002072 goto unlock;
2073
Vivien Didelot76e398a2015-11-01 12:33:55 -05002074 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04002075 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002076 if (err)
2077 goto unlock;
2078
2079 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002080 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002081 if (err)
2082 goto unlock;
2083 }
2084 }
2085
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002086unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002087 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002088
2089 return err;
2090}
2091
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002092static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2093 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002094{
Vivien Didelot04bed142016-08-31 18:06:13 -04002095 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002096 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002097
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002098 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002099 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2100 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002101 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002102
2103 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002104}
2105
Vivien Didelotf81ec902016-05-09 13:22:58 -04002106static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002107 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002108{
Vivien Didelot04bed142016-08-31 18:06:13 -04002109 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002110 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002111
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002112 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002113 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002114 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002115
Vivien Didelot83dabd12016-08-31 11:50:04 -04002116 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002117}
2118
Vivien Didelot83dabd12016-08-31 11:50:04 -04002119static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2120 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002121 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002122{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002123 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002124 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002125 int err;
2126
Vivien Didelotd8291a92019-09-07 16:00:47 -04002127 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002128 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002129
2130 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002131 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002132 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002133 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002134
Vivien Didelotd8291a92019-09-07 16:00:47 -04002135 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002136 break;
2137
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002138 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002139 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002140
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002141 if (!is_unicast_ether_addr(addr.mac))
2142 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002143
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002144 is_static = (addr.state ==
2145 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2146 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002147 if (err)
2148 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002149 } while (!is_broadcast_ether_addr(addr.mac));
2150
2151 return err;
2152}
2153
Vivien Didelot83dabd12016-08-31 11:50:04 -04002154static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002155 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002156{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002157 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002158 u16 fid;
2159 int err;
2160
2161 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002162 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002163 if (err)
2164 return err;
2165
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002166 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002167 if (err)
2168 return err;
2169
2170 /* Dump VLANs' Filtering Information Databases */
Tobias Waldekranze545f862020-11-10 19:57:20 +01002171 vlan.vid = mv88e6xxx_max_vid(chip);
Vivien Didelot425d2d32019-08-01 14:36:34 -04002172 vlan.valid = false;
2173
Vivien Didelot83dabd12016-08-31 11:50:04 -04002174 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002175 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002176 if (err)
2177 return err;
2178
2179 if (!vlan.valid)
2180 break;
2181
2182 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002183 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002184 if (err)
2185 return err;
Tobias Waldekranze545f862020-11-10 19:57:20 +01002186 } while (vlan.vid < mv88e6xxx_max_vid(chip));
Vivien Didelot83dabd12016-08-31 11:50:04 -04002187
2188 return err;
2189}
2190
Vivien Didelotf81ec902016-05-09 13:22:58 -04002191static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002192 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002193{
Vivien Didelot04bed142016-08-31 18:06:13 -04002194 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002195 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002196
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002197 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002198 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002199 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002200
2201 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002202}
2203
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002204static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2205 struct net_device *br)
2206{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002207 struct dsa_switch *ds = chip->ds;
2208 struct dsa_switch_tree *dst = ds->dst;
2209 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002210 int err;
2211
Vivien Didelotef2025e2019-10-21 16:51:27 -04002212 list_for_each_entry(dp, &dst->ports, list) {
2213 if (dp->bridge_dev == br) {
2214 if (dp->ds == ds) {
2215 /* This is a local bridge group member,
2216 * remap its Port VLAN Map.
2217 */
2218 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2219 if (err)
2220 return err;
2221 } else {
2222 /* This is an external bridge group member,
2223 * remap its cross-chip Port VLAN Table entry.
2224 */
2225 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2226 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002227 if (err)
2228 return err;
2229 }
2230 }
2231 }
2232
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002233 return 0;
2234}
2235
Vivien Didelotf81ec902016-05-09 13:22:58 -04002236static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002237 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002238{
Vivien Didelot04bed142016-08-31 18:06:13 -04002239 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002240 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002241
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002242 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002243 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002244 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002245
Vivien Didelot466dfa02016-02-26 13:16:05 -05002246 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002247}
2248
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002249static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2250 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002251{
Vivien Didelot04bed142016-08-31 18:06:13 -04002252 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002253
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002254 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002255 if (mv88e6xxx_bridge_map(chip, br) ||
2256 mv88e6xxx_port_vlan_map(chip, port))
2257 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002258 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002259}
2260
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002261static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds,
2262 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002263 int port, struct net_device *br)
2264{
2265 struct mv88e6xxx_chip *chip = ds->priv;
2266 int err;
2267
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002268 if (tree_index != ds->dst->index)
2269 return 0;
2270
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002271 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002272 err = mv88e6xxx_pvt_map(chip, sw_index, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002273 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002274
2275 return err;
2276}
2277
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002278static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds,
2279 int tree_index, int sw_index,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002280 int port, struct net_device *br)
2281{
2282 struct mv88e6xxx_chip *chip = ds->priv;
2283
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002284 if (tree_index != ds->dst->index)
2285 return;
2286
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002287 mv88e6xxx_reg_lock(chip);
Vladimir Olteanf66a6a62020-05-10 19:37:41 +03002288 if (mv88e6xxx_pvt_map(chip, sw_index, port))
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002289 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002290 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002291}
2292
Vivien Didelot17e708b2016-12-05 17:30:27 -05002293static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2294{
2295 if (chip->info->ops->reset)
2296 return chip->info->ops->reset(chip);
2297
2298 return 0;
2299}
2300
Vivien Didelot309eca62016-12-05 17:30:26 -05002301static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2302{
2303 struct gpio_desc *gpiod = chip->reset;
2304
2305 /* If there is a GPIO connected to the reset pin, toggle it */
2306 if (gpiod) {
2307 gpiod_set_value_cansleep(gpiod, 1);
2308 usleep_range(10000, 20000);
2309 gpiod_set_value_cansleep(gpiod, 0);
2310 usleep_range(10000, 20000);
Andrew Lunna3dcb3e2020-11-16 08:43:01 -08002311
2312 mv88e6xxx_g1_wait_eeprom_done(chip);
Vivien Didelot309eca62016-12-05 17:30:26 -05002313 }
2314}
2315
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002316static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2317{
2318 int i, err;
2319
2320 /* Set all ports to the Disabled state */
2321 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002322 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002323 if (err)
2324 return err;
2325 }
2326
2327 /* Wait for transmit queues to drain,
2328 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2329 */
2330 usleep_range(2000, 4000);
2331
2332 return 0;
2333}
2334
Vivien Didelotfad09c72016-06-21 12:28:20 -04002335static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002336{
Vivien Didelota935c052016-09-29 12:21:53 -04002337 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002338
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002339 err = mv88e6xxx_disable_ports(chip);
2340 if (err)
2341 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002342
Vivien Didelot309eca62016-12-05 17:30:26 -05002343 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002344
Vivien Didelot17e708b2016-12-05 17:30:27 -05002345 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002346}
2347
Vivien Didelot43145572017-03-11 16:12:59 -05002348static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002349 enum mv88e6xxx_frame_mode frame,
2350 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002351{
2352 int err;
2353
Vivien Didelot43145572017-03-11 16:12:59 -05002354 if (!chip->info->ops->port_set_frame_mode)
2355 return -EOPNOTSUPP;
2356
2357 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002358 if (err)
2359 return err;
2360
Vivien Didelot43145572017-03-11 16:12:59 -05002361 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2362 if (err)
2363 return err;
2364
2365 if (chip->info->ops->port_set_ether_type)
2366 return chip->info->ops->port_set_ether_type(chip, port, etype);
2367
2368 return 0;
2369}
2370
2371static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2372{
2373 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002374 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002375 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002376}
2377
2378static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2379{
2380 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002381 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002382 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002383}
2384
2385static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2386{
2387 return mv88e6xxx_set_port_mode(chip, port,
2388 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002389 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2390 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002391}
2392
2393static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2394{
2395 if (dsa_is_dsa_port(chip->ds, port))
2396 return mv88e6xxx_set_port_mode_dsa(chip, port);
2397
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002398 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002399 return mv88e6xxx_set_port_mode_normal(chip, port);
2400
2401 /* Setup CPU port mode depending on its supported tag format */
2402 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2403 return mv88e6xxx_set_port_mode_dsa(chip, port);
2404
2405 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2406 return mv88e6xxx_set_port_mode_edsa(chip, port);
2407
2408 return -EINVAL;
2409}
2410
Vivien Didelotea698f42017-03-11 16:12:50 -05002411static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2412{
2413 bool message = dsa_is_dsa_port(chip->ds, port);
2414
2415 return mv88e6xxx_port_set_message_port(chip, port, message);
2416}
2417
Vivien Didelot601aeed2017-03-11 16:13:00 -05002418static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2419{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002420 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002421 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002422
David S. Miller407308f2019-06-15 13:35:29 -07002423 /* Upstream ports flood frames with unknown unicast or multicast DA */
2424 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2425 if (chip->info->ops->port_set_egress_floods)
2426 return chip->info->ops->port_set_egress_floods(chip, port,
2427 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002428
David S. Miller407308f2019-06-15 13:35:29 -07002429 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002430}
2431
Vivien Didelot45de77f2019-08-31 16:18:36 -04002432static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2433{
2434 struct mv88e6xxx_port *mvp = dev_id;
2435 struct mv88e6xxx_chip *chip = mvp->chip;
2436 irqreturn_t ret = IRQ_NONE;
2437 int port = mvp->port;
2438 u8 lane;
2439
2440 mv88e6xxx_reg_lock(chip);
2441 lane = mv88e6xxx_serdes_get_lane(chip, port);
2442 if (lane)
2443 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2444 mv88e6xxx_reg_unlock(chip);
2445
2446 return ret;
2447}
2448
2449static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2450 u8 lane)
2451{
2452 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2453 unsigned int irq;
2454 int err;
2455
2456 /* Nothing to request if this SERDES port has no IRQ */
2457 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2458 if (!irq)
2459 return 0;
2460
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002461 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2462 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2463
Vivien Didelot45de77f2019-08-31 16:18:36 -04002464 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2465 mv88e6xxx_reg_unlock(chip);
2466 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002467 IRQF_ONESHOT, dev_id->serdes_irq_name,
2468 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002469 mv88e6xxx_reg_lock(chip);
2470 if (err)
2471 return err;
2472
2473 dev_id->serdes_irq = irq;
2474
2475 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2476}
2477
2478static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2479 u8 lane)
2480{
2481 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2482 unsigned int irq = dev_id->serdes_irq;
2483 int err;
2484
2485 /* Nothing to free if no IRQ has been requested */
2486 if (!irq)
2487 return 0;
2488
2489 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2490
2491 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2492 mv88e6xxx_reg_unlock(chip);
2493 free_irq(irq, dev_id);
2494 mv88e6xxx_reg_lock(chip);
2495
2496 dev_id->serdes_irq = 0;
2497
2498 return err;
2499}
2500
Andrew Lunn6d917822017-05-26 01:03:21 +02002501static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2502 bool on)
2503{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002504 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002505 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002506
Vivien Didelotdc272f62019-08-31 16:18:33 -04002507 lane = mv88e6xxx_serdes_get_lane(chip, port);
2508 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002509 return 0;
2510
2511 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002512 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002513 if (err)
2514 return err;
2515
Vivien Didelot45de77f2019-08-31 16:18:36 -04002516 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002517 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002518 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2519 if (err)
2520 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002521
Vivien Didelotdc272f62019-08-31 16:18:33 -04002522 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002523 }
2524
2525 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002526}
2527
Vivien Didelotfa371c82017-12-05 15:34:10 -05002528static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2529{
2530 struct dsa_switch *ds = chip->ds;
2531 int upstream_port;
2532 int err;
2533
Vivien Didelot07073c72017-12-05 15:34:13 -05002534 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002535 if (chip->info->ops->port_set_upstream_port) {
2536 err = chip->info->ops->port_set_upstream_port(chip, port,
2537 upstream_port);
2538 if (err)
2539 return err;
2540 }
2541
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002542 if (port == upstream_port) {
2543 if (chip->info->ops->set_cpu_port) {
2544 err = chip->info->ops->set_cpu_port(chip,
2545 upstream_port);
2546 if (err)
2547 return err;
2548 }
2549
2550 if (chip->info->ops->set_egress_port) {
2551 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002552 MV88E6XXX_EGRESS_DIR_INGRESS,
2553 upstream_port);
2554 if (err)
2555 return err;
2556
2557 err = chip->info->ops->set_egress_port(chip,
2558 MV88E6XXX_EGRESS_DIR_EGRESS,
2559 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002560 if (err)
2561 return err;
2562 }
2563 }
2564
Vivien Didelotfa371c82017-12-05 15:34:10 -05002565 return 0;
2566}
2567
Vivien Didelotfad09c72016-06-21 12:28:20 -04002568static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002569{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002570 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002571 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002572 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002573
Andrew Lunn7b898462018-08-09 15:38:47 +02002574 chip->ports[port].chip = chip;
2575 chip->ports[port].port = port;
2576
Vivien Didelotd78343d2016-11-04 03:23:36 +01002577 /* MAC Forcing register: don't force link, speed, duplex or flow control
2578 * state to any particular values on physical ports, but force the CPU
2579 * port and all DSA ports to their maximum bandwidth and full duplex.
2580 */
2581 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2582 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2583 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002584 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002585 PHY_INTERFACE_MODE_NA);
2586 else
2587 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2588 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002589 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002590 PHY_INTERFACE_MODE_NA);
2591 if (err)
2592 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002593
2594 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2595 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2596 * tunneling, determine priority by looking at 802.1p and IP
2597 * priority fields (IP prio has precedence), and set STP state
2598 * to Forwarding.
2599 *
2600 * If this is the CPU link, use DSA or EDSA tagging depending
2601 * on which tagging mode was configured.
2602 *
2603 * If this is a link to another switch, use DSA tagging mode.
2604 *
2605 * If this is the upstream port for this switch, enable
2606 * forwarding of unknown unicasts and multicasts.
2607 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002608 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2609 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2610 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2611 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002612 if (err)
2613 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002614
Vivien Didelot601aeed2017-03-11 16:13:00 -05002615 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002616 if (err)
2617 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002618
Vivien Didelot601aeed2017-03-11 16:13:00 -05002619 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002620 if (err)
2621 return err;
2622
Vivien Didelot8efdda42015-08-13 12:52:23 -04002623 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002624 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002625 * untagged frames on this port, do a destination address lookup on all
2626 * received packets as usual, disable ARP mirroring and don't send a
2627 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002628 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002629 err = mv88e6xxx_port_set_map_da(chip, port);
2630 if (err)
2631 return err;
2632
Vivien Didelotfa371c82017-12-05 15:34:10 -05002633 err = mv88e6xxx_setup_upstream_port(chip, port);
2634 if (err)
2635 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002636
Andrew Lunna23b2962017-02-04 20:15:28 +01002637 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002638 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002639 if (err)
2640 return err;
2641
Vivien Didelotcd782652017-06-08 18:34:13 -04002642 if (chip->info->ops->port_set_jumbo_size) {
2643 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002644 if (err)
2645 return err;
2646 }
2647
Andrew Lunn54d792f2015-05-06 01:09:47 +02002648 /* Port Association Vector: when learning source addresses
2649 * of packets, add the address to the address database using
2650 * a port bitmap that has only the bit for this port set and
2651 * the other bits clear.
2652 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002653 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002654 /* Disable learning for CPU port */
2655 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002656 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002657
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002658 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2659 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002660 if (err)
2661 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002662
2663 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002664 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2665 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002666 if (err)
2667 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002668
Vivien Didelot08984322017-06-08 18:34:12 -04002669 if (chip->info->ops->port_pause_limit) {
2670 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002671 if (err)
2672 return err;
2673 }
2674
Vivien Didelotc8c94892017-03-11 16:13:01 -05002675 if (chip->info->ops->port_disable_learn_limit) {
2676 err = chip->info->ops->port_disable_learn_limit(chip, port);
2677 if (err)
2678 return err;
2679 }
2680
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002681 if (chip->info->ops->port_disable_pri_override) {
2682 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002683 if (err)
2684 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002685 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002686
Andrew Lunnef0a7312016-12-03 04:35:16 +01002687 if (chip->info->ops->port_tag_remap) {
2688 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002689 if (err)
2690 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002691 }
2692
Andrew Lunnef70b112016-12-03 04:45:18 +01002693 if (chip->info->ops->port_egress_rate_limiting) {
2694 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002695 if (err)
2696 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002697 }
2698
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002699 if (chip->info->ops->port_setup_message_port) {
2700 err = chip->info->ops->port_setup_message_port(chip, port);
2701 if (err)
2702 return err;
2703 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002704
Vivien Didelot207afda2016-04-14 14:42:09 -04002705 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002706 * database, and allow bidirectional communication between the
2707 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002708 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002709 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002710 if (err)
2711 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002712
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002713 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002714 if (err)
2715 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002716
2717 /* Default VLAN ID and priority: don't set a default VLAN
2718 * ID, and set the default packet priority to zero.
2719 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002720 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002721}
2722
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002723static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
2724{
2725 struct mv88e6xxx_chip *chip = ds->priv;
2726
2727 if (chip->info->ops->port_set_jumbo_size)
2728 return 10240;
Chris Packham1baf0fa2020-07-24 11:21:22 +12002729 else if (chip->info->ops->set_max_frame_size)
2730 return 1632;
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002731 return 1522;
2732}
2733
2734static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
2735{
2736 struct mv88e6xxx_chip *chip = ds->priv;
2737 int ret = 0;
2738
2739 mv88e6xxx_reg_lock(chip);
2740 if (chip->info->ops->port_set_jumbo_size)
2741 ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
Chris Packham1baf0fa2020-07-24 11:21:22 +12002742 else if (chip->info->ops->set_max_frame_size)
2743 ret = chip->info->ops->set_max_frame_size(chip, new_mtu);
Andrew Lunn2a550ae2020-07-11 22:32:05 +02002744 else
2745 if (new_mtu > 1522)
2746 ret = -EINVAL;
2747 mv88e6xxx_reg_unlock(chip);
2748
2749 return ret;
2750}
2751
Andrew Lunn04aca992017-05-26 01:03:24 +02002752static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2753 struct phy_device *phydev)
2754{
2755 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002756 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002757
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002758 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002759 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002760 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002761
2762 return err;
2763}
2764
Andrew Lunn75104db2019-02-24 20:44:43 +01002765static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002766{
2767 struct mv88e6xxx_chip *chip = ds->priv;
2768
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002769 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002770 if (mv88e6xxx_serdes_power(chip, port, false))
2771 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002772 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002773}
2774
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002775static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2776 unsigned int ageing_time)
2777{
Vivien Didelot04bed142016-08-31 18:06:13 -04002778 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002779 int err;
2780
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002781 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002782 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002783 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002784
2785 return err;
2786}
2787
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002788static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002789{
2790 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002791
Andrew Lunnde2273872016-11-21 23:27:01 +01002792 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002793 if (chip->info->ops->stats_set_histogram) {
2794 err = chip->info->ops->stats_set_histogram(chip);
2795 if (err)
2796 return err;
2797 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002798
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002799 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002800}
2801
Andrew Lunnea890982019-01-09 00:24:03 +01002802/* Check if the errata has already been applied. */
2803static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2804{
2805 int port;
2806 int err;
2807 u16 val;
2808
2809 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002810 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002811 if (err) {
2812 dev_err(chip->dev,
2813 "Error reading hidden register: %d\n", err);
2814 return false;
2815 }
2816 if (val != 0x01c0)
2817 return false;
2818 }
2819
2820 return true;
2821}
2822
2823/* The 6390 copper ports have an errata which require poking magic
2824 * values into undocumented hidden registers and then performing a
2825 * software reset.
2826 */
2827static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2828{
2829 int port;
2830 int err;
2831
2832 if (mv88e6390_setup_errata_applied(chip))
2833 return 0;
2834
2835 /* Set the ports into blocking mode */
2836 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2837 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2838 if (err)
2839 return err;
2840 }
2841
2842 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002843 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002844 if (err)
2845 return err;
2846 }
2847
2848 return mv88e6xxx_software_reset(chip);
2849}
2850
Andrew Lunn23e8b472019-10-25 01:03:52 +02002851static void mv88e6xxx_teardown(struct dsa_switch *ds)
2852{
2853 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002854 dsa_devlink_resources_unregister(ds);
Andrew Lunnbfb25542020-09-18 21:11:07 +02002855 mv88e6xxx_teardown_devlink_regions(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02002856}
2857
Vivien Didelotf81ec902016-05-09 13:22:58 -04002858static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07002859{
Vivien Didelot04bed142016-08-31 18:06:13 -04002860 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002861 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04002862 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04002863 int i;
2864
Vivien Didelotfad09c72016-06-21 12:28:20 -04002865 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01002866 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Russell King1fb74192020-10-29 16:09:03 +00002867 ds->configure_vlan_while_not_filtering = true;
Vivien Didelot552238b2016-05-09 13:22:49 -04002868
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002869 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002870
Andrew Lunnea890982019-01-09 00:24:03 +01002871 if (chip->info->ops->setup_errata) {
2872 err = chip->info->ops->setup_errata(chip);
2873 if (err)
2874 goto unlock;
2875 }
2876
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002877 /* Cache the cmode of each port. */
2878 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
2879 if (chip->info->ops->port_get_cmode) {
2880 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
2881 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03002882 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02002883
2884 chip->ports[i].cmode = cmode;
2885 }
2886 }
2887
Vivien Didelot97299342016-07-18 20:45:30 -04002888 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002889 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04002890 if (dsa_is_unused_port(ds, i))
2891 continue;
2892
Hubert Feursteinc8574862019-07-31 10:23:48 +02002893 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04002894 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02002895 dev_err(chip->dev, "port %d is invalid\n", i);
2896 err = -EINVAL;
2897 goto unlock;
2898 }
2899
Vivien Didelot97299342016-07-18 20:45:30 -04002900 err = mv88e6xxx_setup_port(chip, i);
2901 if (err)
2902 goto unlock;
2903 }
2904
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04002905 err = mv88e6xxx_irl_setup(chip);
2906 if (err)
2907 goto unlock;
2908
Vivien Didelot04a69a12017-10-13 14:18:05 -04002909 err = mv88e6xxx_mac_setup(chip);
2910 if (err)
2911 goto unlock;
2912
Vivien Didelot1b17aed2017-05-26 18:03:05 -04002913 err = mv88e6xxx_phy_setup(chip);
2914 if (err)
2915 goto unlock;
2916
Vivien Didelotb486d7c2017-05-01 14:05:13 -04002917 err = mv88e6xxx_vtu_setup(chip);
2918 if (err)
2919 goto unlock;
2920
Vivien Didelot81228992017-03-30 17:37:08 -04002921 err = mv88e6xxx_pvt_setup(chip);
2922 if (err)
2923 goto unlock;
2924
Vivien Didelota2ac29d2017-03-11 16:12:49 -05002925 err = mv88e6xxx_atu_setup(chip);
2926 if (err)
2927 goto unlock;
2928
Andrew Lunn87fa8862017-11-09 22:29:56 +01002929 err = mv88e6xxx_broadcast_setup(chip, 0);
2930 if (err)
2931 goto unlock;
2932
Vivien Didelot9e907d72017-07-17 13:03:43 -04002933 err = mv88e6xxx_pot_setup(chip);
2934 if (err)
2935 goto unlock;
2936
Vivien Didelot9e5baf92018-05-09 11:38:51 -04002937 err = mv88e6xxx_rmu_setup(chip);
2938 if (err)
2939 goto unlock;
2940
Vivien Didelot51c901a2017-07-17 13:03:41 -04002941 err = mv88e6xxx_rsvd2cpu_setup(chip);
2942 if (err)
2943 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01002944
Vivien Didelotb28f8722018-04-26 21:56:44 -04002945 err = mv88e6xxx_trunk_setup(chip);
2946 if (err)
2947 goto unlock;
2948
Vivien Didelotc7f047b2018-04-26 21:56:45 -04002949 err = mv88e6xxx_devmap_setup(chip);
2950 if (err)
2951 goto unlock;
2952
Vivien Didelot93e18d62018-05-11 17:16:35 -04002953 err = mv88e6xxx_pri_setup(chip);
2954 if (err)
2955 goto unlock;
2956
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002957 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002958 if (chip->info->ptp_support) {
2959 err = mv88e6xxx_ptp_setup(chip);
2960 if (err)
2961 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01002962
2963 err = mv88e6xxx_hwtstamp_setup(chip);
2964 if (err)
2965 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01002966 }
2967
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002968 err = mv88e6xxx_stats_setup(chip);
2969 if (err)
2970 goto unlock;
2971
Vivien Didelot6b17e862015-08-13 12:52:18 -04002972unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002973 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02002974
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002975 if (err)
2976 return err;
2977
2978 /* Have to be called without holding the register lock, since
2979 * they take the devlink lock, and we later take the locks in
2980 * the reverse order when getting/setting parameters or
2981 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02002982 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002983 err = mv88e6xxx_setup_devlink_resources(ds);
2984 if (err)
2985 return err;
2986
2987 err = mv88e6xxx_setup_devlink_params(ds);
2988 if (err)
Andrew Lunnbfb25542020-09-18 21:11:07 +02002989 goto out_resources;
2990
2991 err = mv88e6xxx_setup_devlink_regions(ds);
2992 if (err)
2993 goto out_params;
2994
2995 return 0;
2996
2997out_params:
2998 mv88e6xxx_teardown_devlink_params(ds);
2999out_resources:
3000 dsa_devlink_resources_unregister(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003001
3002 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003003}
3004
Vivien Didelote57e5e72016-08-15 17:19:00 -04003005static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003006{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003007 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3008 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003009 u16 val;
3010 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003011
Andrew Lunnee26a222017-01-24 14:53:48 +01003012 if (!chip->info->ops->phy_read)
3013 return -EOPNOTSUPP;
3014
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003015 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003016 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003017 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003018
Andrew Lunnda9f3302017-02-01 03:40:05 +01003019 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003020 /* Some internal PHYs don't have a model number. */
3021 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3022 /* Then there is the 6165 family. It gets is
3023 * PHYs correct. But it can also have two
3024 * SERDES interfaces in the PHY address
3025 * space. And these don't have a model
3026 * number. But they are not PHYs, so we don't
3027 * want to give them something a PHY driver
3028 * will recognise.
3029 *
3030 * Use the mv88e6390 family model number
3031 * instead, for anything which really could be
3032 * a PHY,
3033 */
3034 if (!(val & 0x3f0))
3035 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003036 }
3037
Vivien Didelote57e5e72016-08-15 17:19:00 -04003038 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003039}
3040
Vivien Didelote57e5e72016-08-15 17:19:00 -04003041static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003042{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003043 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3044 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003045 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003046
Andrew Lunnee26a222017-01-24 14:53:48 +01003047 if (!chip->info->ops->phy_write)
3048 return -EOPNOTSUPP;
3049
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003050 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003051 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003052 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003053
3054 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003055}
3056
Vivien Didelotfad09c72016-06-21 12:28:20 -04003057static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003058 struct device_node *np,
3059 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003060{
3061 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003062 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003063 struct mii_bus *bus;
3064 int err;
3065
Andrew Lunn2510bab2018-02-22 01:51:49 +01003066 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003067 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003068 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003069 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003070
3071 if (err)
3072 return err;
3073 }
3074
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003075 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003076 if (!bus)
3077 return -ENOMEM;
3078
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003079 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003080 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003081 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003082 INIT_LIST_HEAD(&mdio_bus->list);
3083 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003084
Andrew Lunnb516d452016-06-04 21:17:06 +02003085 if (np) {
3086 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003087 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003088 } else {
3089 bus->name = "mv88e6xxx SMI";
3090 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3091 }
3092
3093 bus->read = mv88e6xxx_mdio_read;
3094 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003095 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003096
Andrew Lunn6f882842018-03-17 20:32:05 +01003097 if (!external) {
3098 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3099 if (err)
3100 return err;
3101 }
3102
Florian Fainelli00e798c2018-05-15 16:56:19 -07003103 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003104 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003105 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003106 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003107 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003108 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003109
3110 if (external)
3111 list_add_tail(&mdio_bus->list, &chip->mdios);
3112 else
3113 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003114
3115 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003116}
3117
Andrew Lunn3126aee2017-12-07 01:05:57 +01003118static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3119
3120{
3121 struct mv88e6xxx_mdio_bus *mdio_bus;
3122 struct mii_bus *bus;
3123
3124 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3125 bus = mdio_bus->bus;
3126
Andrew Lunn6f882842018-03-17 20:32:05 +01003127 if (!mdio_bus->external)
3128 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3129
Andrew Lunn3126aee2017-12-07 01:05:57 +01003130 mdiobus_unregister(bus);
3131 }
3132}
3133
Andrew Lunna3c53be52017-01-24 14:53:50 +01003134static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3135 struct device_node *np)
3136{
Andrew Lunna3c53be52017-01-24 14:53:50 +01003137 struct device_node *child;
3138 int err;
3139
3140 /* Always register one mdio bus for the internal/default mdio
3141 * bus. This maybe represented in the device tree, but is
3142 * optional.
3143 */
3144 child = of_get_child_by_name(np, "mdio");
3145 err = mv88e6xxx_mdio_register(chip, child, false);
3146 if (err)
3147 return err;
3148
3149 /* Walk the device tree, and see if there are any other nodes
3150 * which say they are compatible with the external mdio
3151 * bus.
3152 */
3153 for_each_available_child_of_node(np, child) {
Andrew Lunnceb96fa2020-09-01 04:32:57 +02003154 if (of_device_is_compatible(
3155 child, "marvell,mv88e6xxx-mdio-external")) {
Andrew Lunna3c53be52017-01-24 14:53:50 +01003156 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003157 if (err) {
3158 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303159 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003160 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003161 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003162 }
3163 }
3164
3165 return 0;
3166}
3167
Vivien Didelot855b1932016-07-20 18:18:35 -04003168static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3169{
Vivien Didelot04bed142016-08-31 18:06:13 -04003170 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003171
3172 return chip->eeprom_len;
3173}
3174
Vivien Didelot855b1932016-07-20 18:18:35 -04003175static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3176 struct ethtool_eeprom *eeprom, u8 *data)
3177{
Vivien Didelot04bed142016-08-31 18:06:13 -04003178 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003179 int err;
3180
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003181 if (!chip->info->ops->get_eeprom)
3182 return -EOPNOTSUPP;
3183
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003184 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003185 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003186 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003187
3188 if (err)
3189 return err;
3190
3191 eeprom->magic = 0xc3ec4951;
3192
3193 return 0;
3194}
3195
Vivien Didelot855b1932016-07-20 18:18:35 -04003196static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3197 struct ethtool_eeprom *eeprom, u8 *data)
3198{
Vivien Didelot04bed142016-08-31 18:06:13 -04003199 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003200 int err;
3201
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003202 if (!chip->info->ops->set_eeprom)
3203 return -EOPNOTSUPP;
3204
Vivien Didelot855b1932016-07-20 18:18:35 -04003205 if (eeprom->magic != 0xc3ec4951)
3206 return -EINVAL;
3207
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003208 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003209 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003210 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003211
3212 return err;
3213}
3214
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003215static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003216 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003217 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3218 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003219 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003220 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003221 .phy_read = mv88e6185_phy_ppu_read,
3222 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003223 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003224 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003225 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003226 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003227 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003228 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003229 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003230 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003231 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003232 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003233 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003234 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003235 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003236 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003237 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003238 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3239 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003240 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003241 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3242 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003243 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003244 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003245 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003246 .ppu_enable = mv88e6185_g1_ppu_enable,
3247 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003248 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003249 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003250 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003251 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003252 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003253 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003254};
3255
3256static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003257 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003258 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3259 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003260 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003261 .phy_read = mv88e6185_phy_ppu_read,
3262 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003263 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003264 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003265 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003266 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003267 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003268 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003269 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003270 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003271 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003272 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003273 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3274 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003275 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003276 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003277 .serdes_power = mv88e6185_serdes_power,
3278 .serdes_get_lane = mv88e6185_serdes_get_lane,
3279 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003280 .ppu_enable = mv88e6185_g1_ppu_enable,
3281 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003282 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003283 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003284 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003285 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003286 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003287};
3288
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003289static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003290 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003291 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3292 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003293 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003294 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3295 .phy_read = mv88e6xxx_g2_smi_phy_read,
3296 .phy_write = mv88e6xxx_g2_smi_phy_write,
3297 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003298 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003299 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003300 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003301 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003302 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003303 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003304 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003305 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003306 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003307 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003308 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003309 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003310 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003311 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003312 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3313 .stats_get_strings = mv88e6095_stats_get_strings,
3314 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003315 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3316 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003317 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003318 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003319 .serdes_power = mv88e6185_serdes_power,
3320 .serdes_get_lane = mv88e6185_serdes_get_lane,
3321 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Chris Packham5c19bc82020-11-24 17:34:39 +13003322 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
3323 .serdes_irq_enable = mv88e6097_serdes_irq_enable,
3324 .serdes_irq_status = mv88e6097_serdes_irq_status,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003325 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003326 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003327 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003328 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003329 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003330 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003331 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003332};
3333
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003334static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003335 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003336 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3337 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003338 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003339 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003340 .phy_read = mv88e6xxx_g2_smi_phy_read,
3341 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003342 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003343 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003344 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003345 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003346 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003347 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003348 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003349 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003350 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003351 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003352 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003353 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3354 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003355 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003356 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3357 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003358 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003359 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003360 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003361 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003362 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3363 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003364 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003365 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003366 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003367 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003368};
3369
3370static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003371 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003372 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3373 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003374 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003375 .phy_read = mv88e6185_phy_ppu_read,
3376 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003377 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003378 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003379 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003380 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003381 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003382 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003383 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003384 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003385 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003386 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003387 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003388 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003389 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003390 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003391 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003392 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003393 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3394 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003395 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003396 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3397 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003398 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003399 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003400 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003401 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003402 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003403 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003404 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003405 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003406 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003407};
3408
Vivien Didelot990e27b2017-03-28 13:50:32 -04003409static const struct mv88e6xxx_ops mv88e6141_ops = {
3410 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003411 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3412 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003413 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003414 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3415 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3416 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3417 .phy_read = mv88e6xxx_g2_smi_phy_read,
3418 .phy_write = mv88e6xxx_g2_smi_phy_write,
3419 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003420 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003421 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003422 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003423 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003424 .port_tag_remap = mv88e6095_port_tag_remap,
3425 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3426 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3427 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003428 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003429 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003430 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003431 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3432 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003433 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003434 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003435 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003436 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003437 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003438 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3439 .stats_get_strings = mv88e6320_stats_get_strings,
3440 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003441 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3442 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003443 .watchdog_ops = &mv88e6390_watchdog_ops,
3444 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003445 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003446 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003447 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003448 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003449 .serdes_power = mv88e6390_serdes_power,
3450 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003451 /* Check status register pause & lpa register */
3452 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3453 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3454 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3455 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003456 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003457 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003458 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003459 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003460 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003461};
3462
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003463static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003464 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003465 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3466 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003467 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003468 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003469 .phy_read = mv88e6xxx_g2_smi_phy_read,
3470 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003471 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003472 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003473 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003474 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003475 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003476 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003477 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003478 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003479 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003480 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003481 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003482 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003483 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003484 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003485 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003486 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003487 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3488 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003489 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003490 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3491 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003492 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003493 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003494 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003495 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003496 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3497 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003498 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003499 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003500 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003501 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003502 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003503};
3504
3505static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003506 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003507 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3508 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003509 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003510 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003511 .phy_read = mv88e6165_phy_read,
3512 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003513 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003514 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003515 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003516 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003517 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003518 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003519 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003520 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003521 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003522 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3523 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003524 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003525 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3526 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003527 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003528 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003529 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003530 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003531 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3532 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003533 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003534 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003535 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003536 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003537 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003538};
3539
3540static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003541 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003542 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3543 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003544 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003545 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003546 .phy_read = mv88e6xxx_g2_smi_phy_read,
3547 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003548 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003549 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003550 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003551 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003552 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003553 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003554 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003555 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003556 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003557 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003558 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003559 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003560 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003561 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003562 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003563 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003564 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003565 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3566 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003567 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003568 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3569 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003570 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003571 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003572 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003573 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003574 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3575 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003576 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003577 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003578 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003579};
3580
3581static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003582 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003583 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3584 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003585 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003586 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3587 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003588 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003589 .phy_read = mv88e6xxx_g2_smi_phy_read,
3590 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003591 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003592 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003593 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003594 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003595 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003596 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003597 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003598 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003599 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003600 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003601 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003602 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003603 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003604 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003605 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003606 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003607 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003608 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003609 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3610 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003611 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003612 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3613 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003614 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003615 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003616 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003617 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003618 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003619 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3620 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003621 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003622 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003623 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003624 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3625 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3626 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3627 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003628 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003629 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3630 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003631 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003632 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003633};
3634
3635static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003636 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003637 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3638 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003639 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003640 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003641 .phy_read = mv88e6xxx_g2_smi_phy_read,
3642 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003643 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003644 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003645 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003646 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003647 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003648 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003649 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003650 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003651 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003652 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003653 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003654 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003655 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003656 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003657 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003658 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003659 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003660 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3661 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003662 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003663 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3664 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003665 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003666 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003667 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003668 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003669 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3670 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003671 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003672 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003673 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003674};
3675
3676static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003677 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003678 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3679 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003680 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003681 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3682 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003683 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003684 .phy_read = mv88e6xxx_g2_smi_phy_read,
3685 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003686 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003687 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003688 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003689 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003690 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003691 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003692 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003693 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003694 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003695 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003696 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003697 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003698 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003699 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003700 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003701 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003702 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003703 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003704 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3705 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003706 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003707 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3708 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003709 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003710 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003711 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003712 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003713 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003714 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3715 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003716 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003717 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003718 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003719 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3720 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3721 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3722 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003723 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003724 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003725 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003726 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003727 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3728 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003729 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003730 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003731};
3732
3733static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003734 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003735 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3736 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003737 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003738 .phy_read = mv88e6185_phy_ppu_read,
3739 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003740 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003741 .port_sync_link = mv88e6185_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003742 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003743 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003744 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003745 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003746 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003747 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003748 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003749 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003750 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003751 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003752 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3753 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003754 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003755 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3756 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003757 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003758 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Chris Packhamf5be1072020-11-24 17:34:38 +13003759 .serdes_power = mv88e6185_serdes_power,
3760 .serdes_get_lane = mv88e6185_serdes_get_lane,
3761 .serdes_pcs_get_state = mv88e6185_serdes_pcs_get_state,
Vivien Didelot02317e62018-05-09 11:38:49 -04003762 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003763 .ppu_enable = mv88e6185_g1_ppu_enable,
3764 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003765 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003766 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003767 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003768 .phylink_validate = mv88e6185_phylink_validate,
Chris Packham1baf0fa2020-07-24 11:21:22 +12003769 .set_max_frame_size = mv88e6185_g1_set_max_frame_size,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003770};
3771
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003772static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003773 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003774 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003775 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003776 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3777 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003778 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3779 .phy_read = mv88e6xxx_g2_smi_phy_read,
3780 .phy_write = mv88e6xxx_g2_smi_phy_write,
3781 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003782 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003783 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003784 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003785 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003786 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003787 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003788 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003789 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003790 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003791 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003792 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003793 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003794 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003795 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003796 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003797 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003798 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003799 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003800 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3801 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003802 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003803 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3804 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003805 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003806 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003807 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003808 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003809 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003810 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3811 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003812 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3813 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003814 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003815 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003816 /* Check status register pause & lpa register */
3817 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3818 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3819 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3820 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003821 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003822 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003823 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003824 .serdes_get_strings = mv88e6390_serdes_get_strings,
3825 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003826 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3827 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003828 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003829 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003830};
3831
3832static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003833 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003834 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003835 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003836 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3837 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003838 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3839 .phy_read = mv88e6xxx_g2_smi_phy_read,
3840 .phy_write = mv88e6xxx_g2_smi_phy_write,
3841 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003842 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003843 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003844 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003845 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003846 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003847 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003848 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003849 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003850 .port_set_ether_type = mv88e6351_port_set_ether_type,
Chris Packhame8b34c62020-07-24 11:21:21 +12003851 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot08984322017-06-08 18:34:12 -04003852 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003853 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003854 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003855 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003856 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003857 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003858 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003859 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003860 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3861 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003862 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003863 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3864 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003865 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003866 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003867 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003868 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003869 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003870 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3871 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003872 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3873 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003874 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003875 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003876 /* Check status register pause & lpa register */
3877 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3878 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3879 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3880 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003881 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003882 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003883 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003884 .serdes_get_strings = mv88e6390_serdes_get_strings,
3885 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003886 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3887 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003888 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003889 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003890};
3891
3892static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003893 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003894 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003895 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003896 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3897 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003898 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3899 .phy_read = mv88e6xxx_g2_smi_phy_read,
3900 .phy_write = mv88e6xxx_g2_smi_phy_write,
3901 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003902 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003903 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003904 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003905 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003906 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003907 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003908 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003909 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003910 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003911 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003912 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003913 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003914 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003915 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003916 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003917 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003918 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3919 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003920 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003921 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3922 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003923 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003924 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003925 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003926 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003927 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003928 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3929 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003930 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3931 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003932 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003933 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003934 /* Check status register pause & lpa register */
3935 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3936 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3937 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3938 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003939 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003940 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003941 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003942 .serdes_get_strings = mv88e6390_serdes_get_strings,
3943 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003944 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3945 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02003946 .avb_ops = &mv88e6390_avb_ops,
3947 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003948 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003949};
3950
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003951static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003952 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003953 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3954 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003955 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003956 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3957 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003958 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003959 .phy_read = mv88e6xxx_g2_smi_phy_read,
3960 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003961 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13003962 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003963 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003964 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003965 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003966 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003967 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003968 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003969 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003970 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003971 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003972 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003973 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003974 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003975 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003976 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003977 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003978 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003979 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3980 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003981 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003982 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3983 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003984 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003985 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003986 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003987 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003988 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003989 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3990 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003991 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003992 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003993 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003994 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3995 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3996 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3997 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003998 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003999 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004000 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004001 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004002 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4003 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004004 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004005 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004006 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004007 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004008};
4009
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004010static const struct mv88e6xxx_ops mv88e6250_ops = {
4011 /* MV88E6XXX_FAMILY_6250 */
4012 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4013 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4014 .irl_init_all = mv88e6352_g2_irl_init_all,
4015 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4016 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4017 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4018 .phy_read = mv88e6xxx_g2_smi_phy_read,
4019 .phy_write = mv88e6xxx_g2_smi_phy_write,
4020 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004021 .port_sync_link = mv88e6xxx_port_sync_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004022 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004023 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004024 .port_tag_remap = mv88e6095_port_tag_remap,
4025 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4026 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4027 .port_set_ether_type = mv88e6351_port_set_ether_type,
4028 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4029 .port_pause_limit = mv88e6097_port_pause_limit,
4030 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004031 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4032 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4033 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4034 .stats_get_strings = mv88e6250_stats_get_strings,
4035 .stats_get_stats = mv88e6250_stats_get_stats,
4036 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4037 .set_egress_port = mv88e6095_g1_set_egress_port,
4038 .watchdog_ops = &mv88e6250_watchdog_ops,
4039 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4040 .pot_clear = mv88e6xxx_g2_pot_clear,
4041 .reset = mv88e6250_g1_reset,
4042 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4043 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004044 .avb_ops = &mv88e6352_avb_ops,
4045 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004046 .phylink_validate = mv88e6065_phylink_validate,
4047};
4048
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004049static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004050 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004051 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004052 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004053 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4054 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004055 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4056 .phy_read = mv88e6xxx_g2_smi_phy_read,
4057 .phy_write = mv88e6xxx_g2_smi_phy_write,
4058 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004059 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004060 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004061 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004062 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004063 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004064 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004065 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004066 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004067 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004068 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004069 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004070 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004071 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004072 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004073 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004074 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004075 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004076 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4077 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004078 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004079 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4080 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004081 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004082 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004083 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004084 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004085 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004086 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4087 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004088 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4089 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004090 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004091 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004092 /* Check status register pause & lpa register */
4093 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4094 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4095 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4096 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004097 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004098 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004099 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004100 .serdes_get_strings = mv88e6390_serdes_get_strings,
4101 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004102 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4103 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004104 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004105 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004106 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004107 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004108};
4109
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004110static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004111 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004112 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4113 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004114 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004115 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4116 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004117 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004118 .phy_read = mv88e6xxx_g2_smi_phy_read,
4119 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004120 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004121 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004122 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004123 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004124 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004125 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004126 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004127 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004128 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004129 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004130 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004131 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004132 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004133 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004134 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004135 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004136 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4137 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004138 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004139 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4140 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004141 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004142 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004143 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004144 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004145 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004146 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004147 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004148 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004149 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004150 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004151};
4152
4153static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004154 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004155 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4156 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004157 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004158 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4159 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004160 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004161 .phy_read = mv88e6xxx_g2_smi_phy_read,
4162 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004163 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004164 .port_sync_link = mv88e6xxx_port_sync_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004165 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004166 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004167 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004168 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004169 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004170 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004171 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004172 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004173 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004174 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004175 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004176 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004177 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004178 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004179 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4180 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004181 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004182 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4183 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004184 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004185 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004186 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004187 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004188 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004189 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004190 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004191 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004192};
4193
Vivien Didelot16e329a2017-03-28 13:50:33 -04004194static const struct mv88e6xxx_ops mv88e6341_ops = {
4195 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004196 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4197 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004198 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004199 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4200 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4201 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4202 .phy_read = mv88e6xxx_g2_smi_phy_read,
4203 .phy_write = mv88e6xxx_g2_smi_phy_write,
4204 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004205 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004206 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004207 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004208 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004209 .port_tag_remap = mv88e6095_port_tag_remap,
4210 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4211 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4212 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004213 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004214 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004215 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004216 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4217 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004218 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004219 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004220 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004221 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004222 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004223 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4224 .stats_get_strings = mv88e6320_stats_get_strings,
4225 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004226 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4227 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004228 .watchdog_ops = &mv88e6390_watchdog_ops,
4229 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004230 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004231 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004232 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004233 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004234 .serdes_power = mv88e6390_serdes_power,
4235 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004236 /* Check status register pause & lpa register */
4237 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4238 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4239 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4240 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004241 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004242 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004243 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004244 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004245 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004246 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004247 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004248};
4249
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004250static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004251 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004252 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4253 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004254 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004255 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004256 .phy_read = mv88e6xxx_g2_smi_phy_read,
4257 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004258 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004259 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004260 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004261 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004262 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004263 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004264 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004265 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004266 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004267 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004268 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004269 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004270 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004271 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004272 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004273 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004274 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004275 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4276 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004277 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004278 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4279 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004280 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004281 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004282 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004283 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004284 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4285 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004286 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004287 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004288 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004289};
4290
4291static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004292 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004293 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4294 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004295 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004296 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004297 .phy_read = mv88e6xxx_g2_smi_phy_read,
4298 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004299 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004300 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004301 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004302 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004303 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004304 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004305 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004306 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004307 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004308 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004309 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004310 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004311 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004312 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004313 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004314 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004315 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004316 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4317 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004318 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004319 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4320 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004321 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004322 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004323 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004324 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004325 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4326 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004327 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004328 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004329 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004330 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004331 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004332};
4333
4334static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004335 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004336 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4337 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004338 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004339 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4340 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004341 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004342 .phy_read = mv88e6xxx_g2_smi_phy_read,
4343 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004344 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004345 .port_sync_link = mv88e6xxx_port_sync_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004346 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004347 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004348 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004349 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004350 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004351 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004352 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004353 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004354 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004355 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004356 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004357 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004358 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004359 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004360 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004361 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004362 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4363 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004364 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004365 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4366 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004367 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004368 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004369 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004370 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004371 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004372 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4373 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004374 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004375 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004376 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004377 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4378 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4379 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4380 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004381 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004382 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004383 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004384 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004385 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004386 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004387 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004388 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4389 .serdes_get_strings = mv88e6352_serdes_get_strings,
4390 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004391 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4392 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004393 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004394};
4395
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004396static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004397 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004398 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004399 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004400 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4401 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004402 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4403 .phy_read = mv88e6xxx_g2_smi_phy_read,
4404 .phy_write = mv88e6xxx_g2_smi_phy_write,
4405 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004406 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004407 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004408 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004409 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004410 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004411 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004412 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004413 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004414 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004415 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004416 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004417 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004418 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004419 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004420 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004421 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004422 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004423 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004424 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004425 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4426 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004427 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004428 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4429 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004430 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004431 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004432 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004433 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004434 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004435 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4436 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004437 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4438 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004439 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004440 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004441 /* Check status register pause & lpa register */
4442 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4443 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4444 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4445 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004446 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004447 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004448 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004449 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004450 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004451 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004452 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4453 .serdes_get_strings = mv88e6390_serdes_get_strings,
4454 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004455 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4456 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004457 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004458};
4459
4460static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004461 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004462 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004463 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004464 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4465 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004466 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4467 .phy_read = mv88e6xxx_g2_smi_phy_read,
4468 .phy_write = mv88e6xxx_g2_smi_phy_write,
4469 .port_set_link = mv88e6xxx_port_set_link,
Chris Packham4efe76622020-11-24 17:34:37 +13004470 .port_sync_link = mv88e6xxx_port_sync_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004471 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004472 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004473 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004474 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004475 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004476 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004477 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004478 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004479 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004480 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004481 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004482 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004483 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004484 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004485 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004486 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004487 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004488 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004489 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4490 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004491 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004492 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4493 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004494 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004495 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004496 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004497 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004498 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004499 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4500 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004501 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4502 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004503 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004504 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004505 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4506 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4507 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4508 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004509 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004510 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004511 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004512 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4513 .serdes_get_strings = mv88e6390_serdes_get_strings,
4514 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004515 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4516 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004517 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004518 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004519 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004520 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004521};
4522
Vivien Didelotf81ec902016-05-09 13:22:58 -04004523static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4524 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004525 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004526 .family = MV88E6XXX_FAMILY_6097,
4527 .name = "Marvell 88E6085",
4528 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004529 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004530 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004531 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004532 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004533 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004534 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004535 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004536 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004537 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004538 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004539 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004540 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004541 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004542 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004543 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004544 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004545 },
4546
4547 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004548 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004549 .family = MV88E6XXX_FAMILY_6095,
4550 .name = "Marvell 88E6095/88E6095F",
4551 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004552 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004553 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004554 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004555 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004556 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004557 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004558 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004559 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004560 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004561 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004562 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004563 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004564 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004565 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004566 },
4567
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004568 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004569 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004570 .family = MV88E6XXX_FAMILY_6097,
4571 .name = "Marvell 88E6097/88E6097F",
4572 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004573 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004574 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004575 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004576 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004577 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004578 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004579 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004580 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004581 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004582 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004583 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004584 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004585 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004586 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004587 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004588 .ops = &mv88e6097_ops,
4589 },
4590
Vivien Didelotf81ec902016-05-09 13:22:58 -04004591 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004592 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004593 .family = MV88E6XXX_FAMILY_6165,
4594 .name = "Marvell 88E6123",
4595 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004596 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004597 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004598 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004599 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004600 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004601 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004602 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004603 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004604 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004605 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004606 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004607 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004608 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004609 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004610 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004611 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004612 },
4613
4614 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004615 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004616 .family = MV88E6XXX_FAMILY_6185,
4617 .name = "Marvell 88E6131",
4618 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004619 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004620 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004621 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004622 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004623 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004624 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004625 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004626 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004627 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004628 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004629 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004630 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004631 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004632 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004633 },
4634
Vivien Didelot990e27b2017-03-28 13:50:32 -04004635 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004636 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004637 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004638 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004639 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004640 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004641 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004642 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004643 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004644 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004645 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004646 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004647 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004648 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004649 .age_time_coeff = 3750,
4650 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004651 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004652 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004653 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004654 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004655 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004656 .ops = &mv88e6141_ops,
4657 },
4658
Vivien Didelotf81ec902016-05-09 13:22:58 -04004659 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004660 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004661 .family = MV88E6XXX_FAMILY_6165,
4662 .name = "Marvell 88E6161",
4663 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004664 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004665 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004666 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004667 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004668 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004669 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004670 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004671 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004672 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004673 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004674 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004675 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004676 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004677 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004678 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004679 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004680 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004681 },
4682
4683 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004684 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004685 .family = MV88E6XXX_FAMILY_6165,
4686 .name = "Marvell 88E6165",
4687 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004688 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004689 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004690 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004691 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004692 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004693 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004694 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004695 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004696 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004697 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004698 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004699 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004700 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004701 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004702 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004703 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004704 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004705 },
4706
4707 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004708 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004709 .family = MV88E6XXX_FAMILY_6351,
4710 .name = "Marvell 88E6171",
4711 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004712 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004713 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004714 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004715 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004716 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004717 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004718 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004719 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004720 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004721 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004722 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004723 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004724 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004725 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004726 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004727 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004728 },
4729
4730 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004731 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004732 .family = MV88E6XXX_FAMILY_6352,
4733 .name = "Marvell 88E6172",
4734 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004735 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004736 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004737 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004738 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004739 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004740 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004741 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004742 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004743 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004744 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004745 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004746 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004747 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004748 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004749 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004750 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004751 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004752 },
4753
4754 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004755 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004756 .family = MV88E6XXX_FAMILY_6351,
4757 .name = "Marvell 88E6175",
4758 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004759 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004760 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004761 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004762 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004763 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004764 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004765 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004766 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004767 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004768 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004769 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004770 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004771 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004772 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004773 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004774 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004775 },
4776
4777 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004778 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004779 .family = MV88E6XXX_FAMILY_6352,
4780 .name = "Marvell 88E6176",
4781 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004782 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004783 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004784 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004785 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004786 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004787 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004788 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004789 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004790 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004791 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004792 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004793 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004794 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004795 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004796 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004797 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004798 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004799 },
4800
4801 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004802 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004803 .family = MV88E6XXX_FAMILY_6185,
4804 .name = "Marvell 88E6185",
4805 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004806 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004807 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004808 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004809 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004810 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004811 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004812 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004813 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004814 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004815 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004816 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004817 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004818 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004819 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004820 },
4821
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004822 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004823 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004824 .family = MV88E6XXX_FAMILY_6390,
4825 .name = "Marvell 88E6190",
4826 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004827 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004828 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004829 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004830 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004831 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004832 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004833 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004834 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004835 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004836 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004837 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004838 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004839 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004840 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004841 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004842 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004843 .ops = &mv88e6190_ops,
4844 },
4845
4846 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004847 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004848 .family = MV88E6XXX_FAMILY_6390,
4849 .name = "Marvell 88E6190X",
4850 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004851 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004852 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004853 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004854 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004855 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004856 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004857 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004858 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004859 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004860 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004861 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004862 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004863 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004864 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004865 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004866 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004867 .ops = &mv88e6190x_ops,
4868 },
4869
4870 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004871 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004872 .family = MV88E6XXX_FAMILY_6390,
4873 .name = "Marvell 88E6191",
4874 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004875 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004876 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004877 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04004878 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004879 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004880 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004881 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004882 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004883 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004884 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004885 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004886 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004887 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004888 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004889 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004890 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04004891 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004892 },
4893
Hubert Feurstein49022642019-07-31 10:23:46 +02004894 [MV88E6220] = {
4895 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
4896 .family = MV88E6XXX_FAMILY_6250,
4897 .name = "Marvell 88E6220",
4898 .num_databases = 64,
4899
4900 /* Ports 2-4 are not routed to pins
4901 * => usable ports 0, 1, 5, 6
4902 */
4903 .num_ports = 7,
4904 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02004905 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02004906 .max_vid = 4095,
4907 .port_base_addr = 0x08,
4908 .phy_base_addr = 0x00,
4909 .global1_addr = 0x0f,
4910 .global2_addr = 0x07,
4911 .age_time_coeff = 15000,
4912 .g1_irqs = 9,
4913 .g2_irqs = 10,
4914 .atu_move_port_mask = 0xf,
4915 .dual_chip = true,
4916 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004917 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02004918 .ops = &mv88e6250_ops,
4919 },
4920
Vivien Didelotf81ec902016-05-09 13:22:58 -04004921 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004922 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004923 .family = MV88E6XXX_FAMILY_6352,
4924 .name = "Marvell 88E6240",
4925 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004926 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004927 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004928 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004929 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004930 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004931 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004932 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004933 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004934 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004935 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004936 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004937 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004938 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004939 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004940 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004941 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004942 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004943 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004944 },
4945
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004946 [MV88E6250] = {
4947 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
4948 .family = MV88E6XXX_FAMILY_6250,
4949 .name = "Marvell 88E6250",
4950 .num_databases = 64,
4951 .num_ports = 7,
4952 .num_internal_phys = 5,
4953 .max_vid = 4095,
4954 .port_base_addr = 0x08,
4955 .phy_base_addr = 0x00,
4956 .global1_addr = 0x0f,
4957 .global2_addr = 0x07,
4958 .age_time_coeff = 15000,
4959 .g1_irqs = 9,
4960 .g2_irqs = 10,
4961 .atu_move_port_mask = 0xf,
4962 .dual_chip = true,
4963 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02004964 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004965 .ops = &mv88e6250_ops,
4966 },
4967
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004968 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004969 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004970 .family = MV88E6XXX_FAMILY_6390,
4971 .name = "Marvell 88E6290",
4972 .num_databases = 4096,
4973 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004974 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004975 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004976 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004977 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004978 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004979 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004980 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004981 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004982 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004983 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004984 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004985 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004986 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004987 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01004988 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004989 .ops = &mv88e6290_ops,
4990 },
4991
Vivien Didelotf81ec902016-05-09 13:22:58 -04004992 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004993 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004994 .family = MV88E6XXX_FAMILY_6320,
4995 .name = "Marvell 88E6320",
4996 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004997 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004998 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004999 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005000 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005001 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005002 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005003 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005004 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005005 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005006 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005007 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005008 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005009 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005010 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005011 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005012 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005013 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005014 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005015 },
5016
5017 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005018 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005019 .family = MV88E6XXX_FAMILY_6320,
5020 .name = "Marvell 88E6321",
5021 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005022 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005023 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005024 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005025 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005026 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005027 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005028 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005029 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005030 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005031 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005032 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005033 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005034 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005035 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005036 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005037 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005038 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005039 },
5040
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005041 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005042 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005043 .family = MV88E6XXX_FAMILY_6341,
5044 .name = "Marvell 88E6341",
5045 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005046 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005047 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005048 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005049 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005050 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005051 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005052 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005053 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005054 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005055 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005056 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005057 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005058 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005059 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005060 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005061 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005062 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005063 .ops = &mv88e6341_ops,
5064 },
5065
Vivien Didelotf81ec902016-05-09 13:22:58 -04005066 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005067 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005068 .family = MV88E6XXX_FAMILY_6351,
5069 .name = "Marvell 88E6350",
5070 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005071 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005072 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005073 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005074 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005075 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005076 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005077 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005078 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005079 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005080 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005081 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005082 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005083 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005084 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005085 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005086 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005087 },
5088
5089 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005090 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005091 .family = MV88E6XXX_FAMILY_6351,
5092 .name = "Marvell 88E6351",
5093 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005094 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005095 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005096 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005097 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005098 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005099 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005100 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005101 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005102 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005103 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005104 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005105 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005106 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005107 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005108 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005109 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005110 },
5111
5112 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005113 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005114 .family = MV88E6XXX_FAMILY_6352,
5115 .name = "Marvell 88E6352",
5116 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005117 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005118 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005119 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005120 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005121 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005122 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005123 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005124 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005125 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005126 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005127 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005128 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005129 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005130 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005131 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005132 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005133 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005134 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005135 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005136 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005137 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005138 .family = MV88E6XXX_FAMILY_6390,
5139 .name = "Marvell 88E6390",
5140 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005141 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005142 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005143 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005144 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005145 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005146 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005147 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005148 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005149 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005150 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005151 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005152 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005153 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005154 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005155 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005156 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005157 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005158 .ops = &mv88e6390_ops,
5159 },
5160 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005161 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005162 .family = MV88E6XXX_FAMILY_6390,
5163 .name = "Marvell 88E6390X",
5164 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005165 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005166 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005167 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005168 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005169 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005170 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005171 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005172 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005173 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005174 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005175 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005176 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005177 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005178 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005179 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005180 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005181 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005182 .ops = &mv88e6390x_ops,
5183 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005184};
5185
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005186static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005187{
Vivien Didelota439c062016-04-17 13:23:58 -04005188 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005189
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005190 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5191 if (mv88e6xxx_table[i].prod_num == prod_num)
5192 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005193
Vivien Didelotb9b37712015-10-30 19:39:48 -04005194 return NULL;
5195}
5196
Vivien Didelotfad09c72016-06-21 12:28:20 -04005197static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005198{
5199 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005200 unsigned int prod_num, rev;
5201 u16 id;
5202 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005203
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005204 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005205 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005206 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005207 if (err)
5208 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005209
Vivien Didelot107fcc12017-06-12 12:37:36 -04005210 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5211 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005212
5213 info = mv88e6xxx_lookup_info(prod_num);
5214 if (!info)
5215 return -ENODEV;
5216
Vivien Didelotcaac8542016-06-20 13:14:09 -04005217 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005218 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005219
Vivien Didelotca070c12016-09-02 14:45:34 -04005220 err = mv88e6xxx_g2_require(chip);
5221 if (err)
5222 return err;
5223
Vivien Didelotfad09c72016-06-21 12:28:20 -04005224 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5225 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005226
5227 return 0;
5228}
5229
Vivien Didelotfad09c72016-06-21 12:28:20 -04005230static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005231{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005232 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005233
Vivien Didelotfad09c72016-06-21 12:28:20 -04005234 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5235 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005236 return NULL;
5237
Vivien Didelotfad09c72016-06-21 12:28:20 -04005238 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005239
Vivien Didelotfad09c72016-06-21 12:28:20 -04005240 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005241 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005242 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005243
Vivien Didelotfad09c72016-06-21 12:28:20 -04005244 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005245}
5246
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005247static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005248 int port,
5249 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005250{
Vivien Didelot04bed142016-08-31 18:06:13 -04005251 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005252
Andrew Lunn443d5a12016-12-03 04:35:18 +01005253 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005254}
5255
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005256static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005257 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005258{
5259 /* We don't need any dynamic resource from the kernel (yet),
5260 * so skip the prepare phase.
5261 */
5262
5263 return 0;
5264}
5265
5266static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005267 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005268{
Vivien Didelot04bed142016-08-31 18:06:13 -04005269 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005270
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005271 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005272 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005273 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005274 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5275 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005276 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005277}
5278
5279static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5280 const struct switchdev_obj_port_mdb *mdb)
5281{
Vivien Didelot04bed142016-08-31 18:06:13 -04005282 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005283 int err;
5284
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005285 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005286 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005287 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005288
5289 return err;
5290}
5291
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005292static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5293 struct dsa_mall_mirror_tc_entry *mirror,
5294 bool ingress)
5295{
5296 enum mv88e6xxx_egress_direction direction = ingress ?
5297 MV88E6XXX_EGRESS_DIR_INGRESS :
5298 MV88E6XXX_EGRESS_DIR_EGRESS;
5299 struct mv88e6xxx_chip *chip = ds->priv;
5300 bool other_mirrors = false;
5301 int i;
5302 int err;
5303
5304 if (!chip->info->ops->set_egress_port)
5305 return -EOPNOTSUPP;
5306
5307 mutex_lock(&chip->reg_lock);
5308 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5309 mirror->to_local_port) {
5310 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5311 other_mirrors |= ingress ?
5312 chip->ports[i].mirror_ingress :
5313 chip->ports[i].mirror_egress;
5314
5315 /* Can't change egress port when other mirror is active */
5316 if (other_mirrors) {
5317 err = -EBUSY;
5318 goto out;
5319 }
5320
5321 err = chip->info->ops->set_egress_port(chip,
5322 direction,
5323 mirror->to_local_port);
5324 if (err)
5325 goto out;
5326 }
5327
5328 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5329out:
5330 mutex_unlock(&chip->reg_lock);
5331
5332 return err;
5333}
5334
5335static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5336 struct dsa_mall_mirror_tc_entry *mirror)
5337{
5338 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5339 MV88E6XXX_EGRESS_DIR_INGRESS :
5340 MV88E6XXX_EGRESS_DIR_EGRESS;
5341 struct mv88e6xxx_chip *chip = ds->priv;
5342 bool other_mirrors = false;
5343 int i;
5344
5345 mutex_lock(&chip->reg_lock);
5346 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5347 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5348
5349 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5350 other_mirrors |= mirror->ingress ?
5351 chip->ports[i].mirror_ingress :
5352 chip->ports[i].mirror_egress;
5353
5354 /* Reset egress port when no other mirror is active */
5355 if (!other_mirrors) {
5356 if (chip->info->ops->set_egress_port(chip,
5357 direction,
5358 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005359 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005360 dev_err(ds->dev, "failed to set egress port\n");
5361 }
5362
5363 mutex_unlock(&chip->reg_lock);
5364}
5365
Russell King4f859012019-02-20 15:35:05 -08005366static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5367 bool unicast, bool multicast)
5368{
5369 struct mv88e6xxx_chip *chip = ds->priv;
5370 int err = -EOPNOTSUPP;
5371
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005372 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005373 if (chip->info->ops->port_set_egress_floods)
5374 err = chip->info->ops->port_set_egress_floods(chip, port,
5375 unicast,
5376 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005377 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005378
5379 return err;
5380}
5381
Florian Fainellia82f67a2017-01-08 14:52:08 -08005382static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005383 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005384 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005385 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005386 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005387 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005388 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005389 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005390 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5391 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005392 .get_strings = mv88e6xxx_get_strings,
5393 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5394 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005395 .port_enable = mv88e6xxx_port_enable,
5396 .port_disable = mv88e6xxx_port_disable,
Andrew Lunn2a550ae2020-07-11 22:32:05 +02005397 .port_max_mtu = mv88e6xxx_get_max_mtu,
5398 .port_change_mtu = mv88e6xxx_change_mtu,
Vivien Didelot08f50062017-08-01 16:32:41 -04005399 .get_mac_eee = mv88e6xxx_get_mac_eee,
5400 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005401 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005402 .get_eeprom = mv88e6xxx_get_eeprom,
5403 .set_eeprom = mv88e6xxx_set_eeprom,
5404 .get_regs_len = mv88e6xxx_get_regs_len,
5405 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005406 .get_rxnfc = mv88e6xxx_get_rxnfc,
5407 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005408 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005409 .port_bridge_join = mv88e6xxx_port_bridge_join,
5410 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005411 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005412 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005413 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005414 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5415 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5416 .port_vlan_add = mv88e6xxx_port_vlan_add,
5417 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005418 .port_fdb_add = mv88e6xxx_port_fdb_add,
5419 .port_fdb_del = mv88e6xxx_port_fdb_del,
5420 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005421 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5422 .port_mdb_add = mv88e6xxx_port_mdb_add,
5423 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005424 .port_mirror_add = mv88e6xxx_port_mirror_add,
5425 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005426 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5427 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005428 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5429 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5430 .port_txtstamp = mv88e6xxx_port_txtstamp,
5431 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5432 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005433 .devlink_param_get = mv88e6xxx_devlink_param_get,
5434 .devlink_param_set = mv88e6xxx_devlink_param_set,
Andrew Lunn93157302020-09-18 21:11:09 +02005435 .devlink_info_get = mv88e6xxx_devlink_info_get,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005436};
5437
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005438static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005439{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005440 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005441 struct dsa_switch *ds;
5442
Vivien Didelot7e99e342019-10-21 16:51:30 -04005443 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005444 if (!ds)
5445 return -ENOMEM;
5446
Vivien Didelot7e99e342019-10-21 16:51:30 -04005447 ds->dev = dev;
5448 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005449 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005450 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005451 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005452 ds->ageing_time_min = chip->info->age_time_coeff;
5453 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005454
5455 dev_set_drvdata(dev, ds);
5456
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005457 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005458}
5459
Vivien Didelotfad09c72016-06-21 12:28:20 -04005460static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005461{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005462 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005463}
5464
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005465static const void *pdata_device_get_match_data(struct device *dev)
5466{
5467 const struct of_device_id *matches = dev->driver->of_match_table;
5468 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5469
5470 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5471 matches++) {
5472 if (!strcmp(pdata->compatible, matches->compatible))
5473 return matches->data;
5474 }
5475 return NULL;
5476}
5477
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005478/* There is no suspend to RAM support at DSA level yet, the switch configuration
5479 * would be lost after a power cycle so prevent it to be suspended.
5480 */
5481static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5482{
5483 return -EOPNOTSUPP;
5484}
5485
5486static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5487{
5488 return 0;
5489}
5490
5491static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5492
Vivien Didelot57d32312016-06-20 13:13:58 -04005493static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005494{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005495 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005496 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005497 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005498 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005499 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005500 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005501 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005502
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005503 if (!np && !pdata)
5504 return -EINVAL;
5505
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005506 if (np)
5507 compat_info = of_device_get_match_data(dev);
5508
5509 if (pdata) {
5510 compat_info = pdata_device_get_match_data(dev);
5511
5512 if (!pdata->netdev)
5513 return -EINVAL;
5514
5515 for (port = 0; port < DSA_MAX_PORTS; port++) {
5516 if (!(pdata->enabled_ports & (1 << port)))
5517 continue;
5518 if (strcmp(pdata->cd.port_names[port], "cpu"))
5519 continue;
5520 pdata->cd.netdev[port] = &pdata->netdev->dev;
5521 break;
5522 }
5523 }
5524
Vivien Didelotcaac8542016-06-20 13:14:09 -04005525 if (!compat_info)
5526 return -EINVAL;
5527
Vivien Didelotfad09c72016-06-21 12:28:20 -04005528 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005529 if (!chip) {
5530 err = -ENOMEM;
5531 goto out;
5532 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005533
Vivien Didelotfad09c72016-06-21 12:28:20 -04005534 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005535
Vivien Didelotfad09c72016-06-21 12:28:20 -04005536 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005537 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005538 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005539
Andrew Lunnb4308f02016-11-21 23:26:55 +01005540 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005541 if (IS_ERR(chip->reset)) {
5542 err = PTR_ERR(chip->reset);
5543 goto out;
5544 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005545 if (chip->reset)
5546 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005547
Vivien Didelotfad09c72016-06-21 12:28:20 -04005548 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005549 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005550 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005551
Vivien Didelote57e5e72016-08-15 17:19:00 -04005552 mv88e6xxx_phy_init(chip);
5553
Andrew Lunn00baabe2018-05-19 22:31:35 +02005554 if (chip->info->ops->get_eeprom) {
5555 if (np)
5556 of_property_read_u32(np, "eeprom-length",
5557 &chip->eeprom_len);
5558 else
5559 chip->eeprom_len = pdata->eeprom_len;
5560 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005561
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005562 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005563 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005564 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005565 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005566 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005567
Andrew Lunna27415d2019-05-01 00:10:50 +02005568 if (np) {
5569 chip->irq = of_irq_get(np, 0);
5570 if (chip->irq == -EPROBE_DEFER) {
5571 err = chip->irq;
5572 goto out;
5573 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005574 }
5575
Andrew Lunna27415d2019-05-01 00:10:50 +02005576 if (pdata)
5577 chip->irq = pdata->irq;
5578
Andrew Lunn294d7112018-02-22 22:58:32 +01005579 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005580 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005581 * controllers
5582 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005583 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005584 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005585 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005586 else
5587 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005588 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005589
Andrew Lunn294d7112018-02-22 22:58:32 +01005590 if (err)
5591 goto out;
5592
5593 if (chip->info->g2_irqs > 0) {
5594 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005595 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005596 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005597 }
5598
Andrew Lunn294d7112018-02-22 22:58:32 +01005599 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5600 if (err)
5601 goto out_g2_irq;
5602
5603 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5604 if (err)
5605 goto out_g1_atu_prob_irq;
5606
Andrew Lunna3c53be52017-01-24 14:53:50 +01005607 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005608 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005609 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005610
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005611 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005612 if (err)
5613 goto out_mdio;
5614
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005615 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005616
5617out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005618 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005619out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005620 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005621out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005622 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005623out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005624 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005625 mv88e6xxx_g2_irq_free(chip);
5626out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005627 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005628 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005629 else
5630 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005631out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005632 if (pdata)
5633 dev_put(pdata->netdev);
5634
Andrew Lunndc30c352016-10-16 19:56:49 +02005635 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005636}
5637
5638static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5639{
5640 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005641 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005642
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005643 if (chip->info->ptp_support) {
5644 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005645 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005646 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005647
Andrew Lunn930188c2016-08-22 16:01:03 +02005648 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005649 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005650 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005651
Andrew Lunn76f38f12018-03-17 20:21:09 +01005652 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5653 mv88e6xxx_g1_atu_prob_irq_free(chip);
5654
5655 if (chip->info->g2_irqs > 0)
5656 mv88e6xxx_g2_irq_free(chip);
5657
Andrew Lunn76f38f12018-03-17 20:21:09 +01005658 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005659 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005660 else
5661 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005662}
5663
5664static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005665 {
5666 .compatible = "marvell,mv88e6085",
5667 .data = &mv88e6xxx_table[MV88E6085],
5668 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005669 {
5670 .compatible = "marvell,mv88e6190",
5671 .data = &mv88e6xxx_table[MV88E6190],
5672 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005673 {
5674 .compatible = "marvell,mv88e6250",
5675 .data = &mv88e6xxx_table[MV88E6250],
5676 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005677 { /* sentinel */ },
5678};
5679
5680MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5681
5682static struct mdio_driver mv88e6xxx_driver = {
5683 .probe = mv88e6xxx_probe,
5684 .remove = mv88e6xxx_remove,
5685 .mdiodrv.driver = {
5686 .name = "mv88e6085",
5687 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005688 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005689 },
5690};
5691
Andrew Lunn7324d502019-04-27 19:19:10 +02005692mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005693
5694MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5695MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5696MODULE_LICENSE("GPL");