blob: 221593261e8feb0a8c2c485da18fc8b4cbc0bb9a [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"
Vivien Didelota935c052016-09-29 12:21:53 -040035#include "global1.h"
Vivien Didelotec561272016-09-02 14:45:33 -040036#include "global2.h"
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +010037#include "hwtstamp.h"
Andrew Lunn10fa5bf2017-05-26 01:03:20 +020038#include "phy.h"
Vivien Didelot18abed22016-11-04 03:23:26 +010039#include "port.h"
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +010040#include "ptp.h"
Andrew Lunn6d917822017-05-26 01:03:21 +020041#include "serdes.h"
Vivien Didelote7ba0fa2019-05-03 19:28:22 -040042#include "smi.h"
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000043
Vivien Didelotfad09c72016-06-21 12:28:20 -040044static void assert_reg_lock(struct mv88e6xxx_chip *chip)
Vivien Didelot3996a4f2015-10-30 18:56:45 -040045{
Vivien Didelotfad09c72016-06-21 12:28:20 -040046 if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
47 dev_err(chip->dev, "Switch registers lock not held!\n");
Vivien Didelot3996a4f2015-10-30 18:56:45 -040048 dump_stack();
49 }
50}
51
Vivien Didelotec561272016-09-02 14:45:33 -040052int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040053{
54 int err;
55
Vivien Didelotfad09c72016-06-21 12:28:20 -040056 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040057
Vivien Didelotfad09c72016-06-21 12:28:20 -040058 err = mv88e6xxx_smi_read(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040059 if (err)
60 return err;
61
Vivien Didelotfad09c72016-06-21 12:28:20 -040062 dev_dbg(chip->dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040063 addr, reg, *val);
64
65 return 0;
66}
67
Vivien Didelotec561272016-09-02 14:45:33 -040068int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
Vivien Didelot914b32f2016-06-20 13:14:11 -040069{
70 int err;
71
Vivien Didelotfad09c72016-06-21 12:28:20 -040072 assert_reg_lock(chip);
Vivien Didelot914b32f2016-06-20 13:14:11 -040073
Vivien Didelotfad09c72016-06-21 12:28:20 -040074 err = mv88e6xxx_smi_write(chip, addr, reg, val);
Vivien Didelot914b32f2016-06-20 13:14:11 -040075 if (err)
76 return err;
77
Vivien Didelotfad09c72016-06-21 12:28:20 -040078 dev_dbg(chip->dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n",
Vivien Didelot914b32f2016-06-20 13:14:11 -040079 addr, reg, val);
80
81 return 0;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +000082}
83
Vivien Didelot683f2242019-08-09 18:47:54 -040084int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
85 u16 mask, u16 val)
86{
87 u16 data;
88 int err;
89 int i;
90
91 /* There's no bus specific operation to wait for a mask */
92 for (i = 0; i < 16; i++) {
93 err = mv88e6xxx_read(chip, addr, reg, &data);
94 if (err)
95 return err;
96
97 if ((data & mask) == val)
98 return 0;
99
100 usleep_range(1000, 2000);
101 }
102
103 dev_err(chip->dev, "Timeout while waiting for switch\n");
104 return -ETIMEDOUT;
105}
106
Vivien Didelot19fb7f62019-08-09 18:47:55 -0400107int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
108 int bit, int val)
109{
110 return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
111 val ? BIT(bit) : 0x0000);
112}
113
Andrew Lunn10fa5bf2017-05-26 01:03:20 +0200114struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
Andrew Lunna3c53be52017-01-24 14:53:50 +0100115{
116 struct mv88e6xxx_mdio_bus *mdio_bus;
117
118 mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus,
119 list);
120 if (!mdio_bus)
121 return NULL;
122
123 return mdio_bus->bus;
124}
125
Andrew Lunndc30c352016-10-16 19:56:49 +0200126static void mv88e6xxx_g1_irq_mask(struct irq_data *d)
127{
128 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
129 unsigned int n = d->hwirq;
130
131 chip->g1_irq.masked |= (1 << n);
132}
133
134static void mv88e6xxx_g1_irq_unmask(struct irq_data *d)
135{
136 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
137 unsigned int n = d->hwirq;
138
139 chip->g1_irq.masked &= ~(1 << n);
140}
141
Andrew Lunn294d7112018-02-22 22:58:32 +0100142static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200143{
Andrew Lunndc30c352016-10-16 19:56:49 +0200144 unsigned int nhandled = 0;
145 unsigned int sub_irq;
146 unsigned int n;
147 u16 reg;
John David Anglin7c0db242019-02-11 13:40:21 -0500148 u16 ctl1;
Andrew Lunndc30c352016-10-16 19:56:49 +0200149 int err;
150
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000151 mv88e6xxx_reg_lock(chip);
Vivien Didelot82466922017-06-15 12:13:59 -0400152 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000153 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200154
155 if (err)
156 goto out;
157
John David Anglin7c0db242019-02-11 13:40:21 -0500158 do {
159 for (n = 0; n < chip->g1_irq.nirqs; ++n) {
160 if (reg & (1 << n)) {
161 sub_irq = irq_find_mapping(chip->g1_irq.domain,
162 n);
163 handle_nested_irq(sub_irq);
164 ++nhandled;
165 }
Andrew Lunndc30c352016-10-16 19:56:49 +0200166 }
John David Anglin7c0db242019-02-11 13:40:21 -0500167
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000168 mv88e6xxx_reg_lock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500169 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1);
170 if (err)
171 goto unlock;
172 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
173unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000174 mv88e6xxx_reg_unlock(chip);
John David Anglin7c0db242019-02-11 13:40:21 -0500175 if (err)
176 goto out;
177 ctl1 &= GENMASK(chip->g1_irq.nirqs, 0);
178 } while (reg & ctl1);
179
Andrew Lunndc30c352016-10-16 19:56:49 +0200180out:
181 return (nhandled > 0 ? IRQ_HANDLED : IRQ_NONE);
182}
183
Andrew Lunn294d7112018-02-22 22:58:32 +0100184static irqreturn_t mv88e6xxx_g1_irq_thread_fn(int irq, void *dev_id)
185{
186 struct mv88e6xxx_chip *chip = dev_id;
187
188 return mv88e6xxx_g1_irq_thread_work(chip);
189}
190
Andrew Lunndc30c352016-10-16 19:56:49 +0200191static void mv88e6xxx_g1_irq_bus_lock(struct irq_data *d)
192{
193 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
194
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000195 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200196}
197
198static void mv88e6xxx_g1_irq_bus_sync_unlock(struct irq_data *d)
199{
200 struct mv88e6xxx_chip *chip = irq_data_get_irq_chip_data(d);
201 u16 mask = GENMASK(chip->g1_irq.nirqs, 0);
202 u16 reg;
203 int err;
204
Vivien Didelotd77f4322017-06-15 12:14:03 -0400205 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200206 if (err)
207 goto out;
208
209 reg &= ~mask;
210 reg |= (~chip->g1_irq.masked & mask);
211
Vivien Didelotd77f4322017-06-15 12:14:03 -0400212 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200213 if (err)
214 goto out;
215
216out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000217 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +0200218}
219
Bhumika Goyal6eb15e22017-08-19 16:25:52 +0530220static const struct irq_chip mv88e6xxx_g1_irq_chip = {
Andrew Lunndc30c352016-10-16 19:56:49 +0200221 .name = "mv88e6xxx-g1",
222 .irq_mask = mv88e6xxx_g1_irq_mask,
223 .irq_unmask = mv88e6xxx_g1_irq_unmask,
224 .irq_bus_lock = mv88e6xxx_g1_irq_bus_lock,
225 .irq_bus_sync_unlock = mv88e6xxx_g1_irq_bus_sync_unlock,
226};
227
228static int mv88e6xxx_g1_irq_domain_map(struct irq_domain *d,
229 unsigned int irq,
230 irq_hw_number_t hwirq)
231{
232 struct mv88e6xxx_chip *chip = d->host_data;
233
234 irq_set_chip_data(irq, d->host_data);
235 irq_set_chip_and_handler(irq, &chip->g1_irq.chip, handle_level_irq);
236 irq_set_noprobe(irq);
237
238 return 0;
239}
240
241static const struct irq_domain_ops mv88e6xxx_g1_irq_domain_ops = {
242 .map = mv88e6xxx_g1_irq_domain_map,
243 .xlate = irq_domain_xlate_twocell,
244};
245
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200246/* To be called with reg_lock held */
Andrew Lunn294d7112018-02-22 22:58:32 +0100247static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200248{
249 int irq, virq;
Andrew Lunn3460a572016-11-20 20:14:16 +0100250 u16 mask;
251
Vivien Didelotd77f4322017-06-15 12:14:03 -0400252 mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100253 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400254 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3460a572016-11-20 20:14:16 +0100255
Andreas Färber5edef2f2016-11-27 23:26:28 +0100256 for (irq = 0; irq < chip->g1_irq.nirqs; irq++) {
Andrew Lunna3db3d32016-11-20 20:14:14 +0100257 virq = irq_find_mapping(chip->g1_irq.domain, irq);
Andrew Lunndc30c352016-10-16 19:56:49 +0200258 irq_dispose_mapping(virq);
259 }
260
Andrew Lunna3db3d32016-11-20 20:14:14 +0100261 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200262}
263
Andrew Lunn294d7112018-02-22 22:58:32 +0100264static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
265{
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200266 /*
267 * free_irq must be called without reg_lock taken because the irq
268 * handler takes this lock, too.
269 */
Andrew Lunn294d7112018-02-22 22:58:32 +0100270 free_irq(chip->irq, chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200271
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000272 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200273 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000274 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100275}
276
277static int mv88e6xxx_g1_irq_setup_common(struct mv88e6xxx_chip *chip)
Andrew Lunndc30c352016-10-16 19:56:49 +0200278{
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100279 int err, irq, virq;
280 u16 reg, mask;
Andrew Lunndc30c352016-10-16 19:56:49 +0200281
282 chip->g1_irq.nirqs = chip->info->g1_irqs;
283 chip->g1_irq.domain = irq_domain_add_simple(
284 NULL, chip->g1_irq.nirqs, 0,
285 &mv88e6xxx_g1_irq_domain_ops, chip);
286 if (!chip->g1_irq.domain)
287 return -ENOMEM;
288
289 for (irq = 0; irq < chip->g1_irq.nirqs; irq++)
290 irq_create_mapping(chip->g1_irq.domain, irq);
291
292 chip->g1_irq.chip = mv88e6xxx_g1_irq_chip;
293 chip->g1_irq.masked = ~0;
294
Vivien Didelotd77f4322017-06-15 12:14:03 -0400295 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200296 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100297 goto out_mapping;
Andrew Lunndc30c352016-10-16 19:56:49 +0200298
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100299 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Andrew Lunndc30c352016-10-16 19:56:49 +0200300
Vivien Didelotd77f4322017-06-15 12:14:03 -0400301 err = mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunndc30c352016-10-16 19:56:49 +0200302 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100303 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200304
305 /* Reading the interrupt status clears (most of) them */
Vivien Didelot82466922017-06-15 12:13:59 -0400306 err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, &reg);
Andrew Lunndc30c352016-10-16 19:56:49 +0200307 if (err)
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100308 goto out_disable;
Andrew Lunndc30c352016-10-16 19:56:49 +0200309
Andrew Lunndc30c352016-10-16 19:56:49 +0200310 return 0;
311
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100312out_disable:
Andrew Lunn3d5fdba2017-12-07 01:05:56 +0100313 mask &= ~GENMASK(chip->g1_irq.nirqs, 0);
Vivien Didelotd77f4322017-06-15 12:14:03 -0400314 mv88e6xxx_g1_write(chip, MV88E6XXX_G1_CTL1, mask);
Andrew Lunn3dd0ef02016-11-20 20:14:17 +0100315
316out_mapping:
317 for (irq = 0; irq < 16; irq++) {
318 virq = irq_find_mapping(chip->g1_irq.domain, irq);
319 irq_dispose_mapping(virq);
320 }
321
322 irq_domain_remove(chip->g1_irq.domain);
Andrew Lunndc30c352016-10-16 19:56:49 +0200323
324 return err;
325}
326
Andrew Lunn294d7112018-02-22 22:58:32 +0100327static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
328{
Andrew Lunnf6d97582019-02-23 17:43:56 +0100329 static struct lock_class_key lock_key;
330 static struct lock_class_key request_key;
Andrew Lunn294d7112018-02-22 22:58:32 +0100331 int err;
332
333 err = mv88e6xxx_g1_irq_setup_common(chip);
334 if (err)
335 return err;
336
Andrew Lunnf6d97582019-02-23 17:43:56 +0100337 /* These lock classes tells lockdep that global 1 irqs are in
338 * a different category than their parent GPIO, so it won't
339 * report false recursion.
340 */
341 irq_set_lockdep_class(chip->irq, &lock_key, &request_key);
342
Andrew Lunn30953832020-01-06 17:13:48 +0100343 snprintf(chip->irq_name, sizeof(chip->irq_name),
344 "mv88e6xxx-%s", dev_name(chip->dev));
345
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000346 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100347 err = request_threaded_irq(chip->irq, NULL,
348 mv88e6xxx_g1_irq_thread_fn,
Marek Behún03403762018-08-30 02:13:50 +0200349 IRQF_ONESHOT | IRQF_SHARED,
Andrew Lunn30953832020-01-06 17:13:48 +0100350 chip->irq_name, chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000351 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100352 if (err)
353 mv88e6xxx_g1_irq_free_common(chip);
354
355 return err;
356}
357
358static void mv88e6xxx_irq_poll(struct kthread_work *work)
359{
360 struct mv88e6xxx_chip *chip = container_of(work,
361 struct mv88e6xxx_chip,
362 irq_poll_work.work);
363 mv88e6xxx_g1_irq_thread_work(chip);
364
365 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
366 msecs_to_jiffies(100));
367}
368
369static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
370{
371 int err;
372
373 err = mv88e6xxx_g1_irq_setup_common(chip);
374 if (err)
375 return err;
376
377 kthread_init_delayed_work(&chip->irq_poll_work,
378 mv88e6xxx_irq_poll);
379
Florian Fainelli3f8b8692019-02-21 20:09:27 -0800380 chip->kworker = kthread_create_worker(0, "%s", dev_name(chip->dev));
Andrew Lunn294d7112018-02-22 22:58:32 +0100381 if (IS_ERR(chip->kworker))
382 return PTR_ERR(chip->kworker);
383
384 kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
385 msecs_to_jiffies(100));
386
387 return 0;
388}
389
390static void mv88e6xxx_irq_poll_free(struct mv88e6xxx_chip *chip)
391{
392 kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
393 kthread_destroy_worker(chip->kworker);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200394
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000395 mv88e6xxx_reg_lock(chip);
Uwe Kleine-König3d824752018-07-20 11:53:15 +0200396 mv88e6xxx_g1_irq_free_common(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000397 mv88e6xxx_reg_unlock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +0100398}
399
Russell King64d47d52020-03-14 10:15:38 +0000400static int mv88e6xxx_port_config_interface(struct mv88e6xxx_chip *chip,
401 int port, phy_interface_t interface)
402{
403 int err;
404
405 if (chip->info->ops->port_set_rgmii_delay) {
406 err = chip->info->ops->port_set_rgmii_delay(chip, port,
407 interface);
408 if (err && err != -EOPNOTSUPP)
409 return err;
410 }
411
412 if (chip->info->ops->port_set_cmode) {
413 err = chip->info->ops->port_set_cmode(chip, port,
414 interface);
415 if (err && err != -EOPNOTSUPP)
416 return err;
417 }
418
419 return 0;
420}
421
Russell Kinga5a68582020-03-14 10:15:43 +0000422static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
423 int link, int speed, int duplex, int pause,
424 phy_interface_t mode)
Vivien Didelotd78343d2016-11-04 03:23:36 +0100425{
426 int err;
427
428 if (!chip->info->ops->port_set_link)
429 return 0;
430
431 /* Port's MAC control must not be changed unless the link is down */
Hubert Feurstein43c8e0a2019-07-30 12:11:42 +0200432 err = chip->info->ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100433 if (err)
434 return err;
435
Russell Kingf365c6f2020-03-14 10:15:53 +0000436 if (chip->info->ops->port_set_speed_duplex) {
437 err = chip->info->ops->port_set_speed_duplex(chip, port,
438 speed, duplex);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100439 if (err && err != -EOPNOTSUPP)
440 goto restore_link;
441 }
442
Andrew Lunn7cbbee02019-03-08 01:21:27 +0100443 if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
444 mode = chip->info->ops->port_max_speed_mode(port);
445
Andrew Lunn54186b92018-08-09 15:38:37 +0200446 if (chip->info->ops->port_set_pause) {
447 err = chip->info->ops->port_set_pause(chip, port, pause);
448 if (err)
449 goto restore_link;
450 }
451
Russell King64d47d52020-03-14 10:15:38 +0000452 err = mv88e6xxx_port_config_interface(chip, port, mode);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100453restore_link:
454 if (chip->info->ops->port_set_link(chip, port, link))
Vivien Didelot774439e52017-06-08 18:34:08 -0400455 dev_err(chip->dev, "p%d: failed to restore MAC's link\n", port);
Vivien Didelotd78343d2016-11-04 03:23:36 +0100456
457 return err;
458}
459
Marek Vasutd700ec42018-09-12 00:15:24 +0200460static int mv88e6xxx_phy_is_internal(struct dsa_switch *ds, int port)
461{
462 struct mv88e6xxx_chip *chip = ds->priv;
463
464 return port < chip->info->num_internal_phys;
465}
466
Russell King5d5b2312020-03-14 10:16:03 +0000467static int mv88e6xxx_port_ppu_updates(struct mv88e6xxx_chip *chip, int port)
468{
469 u16 reg;
470 int err;
471
472 err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_STS, &reg);
473 if (err) {
474 dev_err(chip->dev,
475 "p%d: %s: failed to read port status\n",
476 port, __func__);
477 return err;
478 }
479
480 return !!(reg & MV88E6XXX_PORT_STS_PHY_DETECT);
481}
482
Russell Kinga5a68582020-03-14 10:15:43 +0000483static int mv88e6xxx_serdes_pcs_get_state(struct dsa_switch *ds, int port,
484 struct phylink_link_state *state)
485{
486 struct mv88e6xxx_chip *chip = ds->priv;
487 u8 lane;
488 int err;
489
490 mv88e6xxx_reg_lock(chip);
491 lane = mv88e6xxx_serdes_get_lane(chip, port);
492 if (lane && chip->info->ops->serdes_pcs_get_state)
493 err = chip->info->ops->serdes_pcs_get_state(chip, port, lane,
494 state);
495 else
496 err = -EOPNOTSUPP;
497 mv88e6xxx_reg_unlock(chip);
498
499 return err;
500}
501
502static int mv88e6xxx_serdes_pcs_config(struct mv88e6xxx_chip *chip, int port,
503 unsigned int mode,
504 phy_interface_t interface,
505 const unsigned long *advertise)
506{
507 const struct mv88e6xxx_ops *ops = chip->info->ops;
508 u8 lane;
509
510 if (ops->serdes_pcs_config) {
511 lane = mv88e6xxx_serdes_get_lane(chip, port);
512 if (lane)
513 return ops->serdes_pcs_config(chip, port, lane, mode,
514 interface, advertise);
515 }
516
517 return 0;
518}
519
520static void mv88e6xxx_serdes_pcs_an_restart(struct dsa_switch *ds, int port)
521{
522 struct mv88e6xxx_chip *chip = ds->priv;
523 const struct mv88e6xxx_ops *ops;
524 int err = 0;
525 u8 lane;
526
527 ops = chip->info->ops;
528
529 if (ops->serdes_pcs_an_restart) {
530 mv88e6xxx_reg_lock(chip);
531 lane = mv88e6xxx_serdes_get_lane(chip, port);
532 if (lane)
533 err = ops->serdes_pcs_an_restart(chip, port, lane);
534 mv88e6xxx_reg_unlock(chip);
535
536 if (err)
537 dev_err(ds->dev, "p%d: failed to restart AN\n", port);
538 }
539}
540
541static int mv88e6xxx_serdes_pcs_link_up(struct mv88e6xxx_chip *chip, int port,
542 unsigned int mode,
543 int speed, int duplex)
544{
545 const struct mv88e6xxx_ops *ops = chip->info->ops;
546 u8 lane;
547
548 if (!phylink_autoneg_inband(mode) && ops->serdes_pcs_link_up) {
549 lane = mv88e6xxx_serdes_get_lane(chip, port);
550 if (lane)
551 return ops->serdes_pcs_link_up(chip, port, lane,
552 speed, duplex);
553 }
554
555 return 0;
556}
557
Russell King6c422e32018-08-09 15:38:39 +0200558static void mv88e6065_phylink_validate(struct mv88e6xxx_chip *chip, int port,
559 unsigned long *mask,
560 struct phylink_link_state *state)
561{
562 if (!phy_interface_mode_is_8023z(state->interface)) {
563 /* 10M and 100M are only supported in non-802.3z mode */
564 phylink_set(mask, 10baseT_Half);
565 phylink_set(mask, 10baseT_Full);
566 phylink_set(mask, 100baseT_Half);
567 phylink_set(mask, 100baseT_Full);
568 }
569}
570
571static void mv88e6185_phylink_validate(struct mv88e6xxx_chip *chip, int port,
572 unsigned long *mask,
573 struct phylink_link_state *state)
574{
575 /* FIXME: if the port is in 1000Base-X mode, then it only supports
576 * 1000M FD speeds. In this case, CMODE will indicate 5.
577 */
578 phylink_set(mask, 1000baseT_Full);
579 phylink_set(mask, 1000baseX_Full);
580
581 mv88e6065_phylink_validate(chip, port, mask, state);
582}
583
Marek Behúne3af71a2019-02-25 12:39:55 +0100584static void mv88e6341_phylink_validate(struct mv88e6xxx_chip *chip, int port,
585 unsigned long *mask,
586 struct phylink_link_state *state)
587{
588 if (port >= 5)
589 phylink_set(mask, 2500baseX_Full);
590
591 /* No ethtool bits for 200Mbps */
592 phylink_set(mask, 1000baseT_Full);
593 phylink_set(mask, 1000baseX_Full);
594
595 mv88e6065_phylink_validate(chip, port, mask, state);
596}
597
Russell King6c422e32018-08-09 15:38:39 +0200598static void mv88e6352_phylink_validate(struct mv88e6xxx_chip *chip, int port,
599 unsigned long *mask,
600 struct phylink_link_state *state)
601{
602 /* No ethtool bits for 200Mbps */
603 phylink_set(mask, 1000baseT_Full);
604 phylink_set(mask, 1000baseX_Full);
605
606 mv88e6065_phylink_validate(chip, port, mask, state);
607}
608
609static void mv88e6390_phylink_validate(struct mv88e6xxx_chip *chip, int port,
610 unsigned long *mask,
611 struct phylink_link_state *state)
612{
Andrew Lunnec260162019-02-08 22:25:44 +0100613 if (port >= 9) {
Russell King6c422e32018-08-09 15:38:39 +0200614 phylink_set(mask, 2500baseX_Full);
Andrew Lunnec260162019-02-08 22:25:44 +0100615 phylink_set(mask, 2500baseT_Full);
616 }
Russell King6c422e32018-08-09 15:38:39 +0200617
618 /* No ethtool bits for 200Mbps */
619 phylink_set(mask, 1000baseT_Full);
620 phylink_set(mask, 1000baseX_Full);
621
622 mv88e6065_phylink_validate(chip, port, mask, state);
623}
624
625static void mv88e6390x_phylink_validate(struct mv88e6xxx_chip *chip, int port,
626 unsigned long *mask,
627 struct phylink_link_state *state)
628{
629 if (port >= 9) {
630 phylink_set(mask, 10000baseT_Full);
631 phylink_set(mask, 10000baseKR_Full);
632 }
633
634 mv88e6390_phylink_validate(chip, port, mask, state);
635}
636
Russell Kingc9a23562018-05-10 13:17:35 -0700637static void mv88e6xxx_validate(struct dsa_switch *ds, int port,
638 unsigned long *supported,
639 struct phylink_link_state *state)
640{
Russell King6c422e32018-08-09 15:38:39 +0200641 __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
642 struct mv88e6xxx_chip *chip = ds->priv;
643
644 /* Allow all the expected bits */
645 phylink_set(mask, Autoneg);
646 phylink_set(mask, Pause);
647 phylink_set_port_modes(mask);
648
649 if (chip->info->ops->phylink_validate)
650 chip->info->ops->phylink_validate(chip, port, mask, state);
651
652 bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS);
653 bitmap_and(state->advertising, state->advertising, mask,
654 __ETHTOOL_LINK_MODE_MASK_NBITS);
655
656 /* We can only operate at 2500BaseX or 1000BaseX. If requested
657 * to advertise both, only report advertising at 2500BaseX.
658 */
659 phylink_helper_basex_speed(state);
Russell Kingc9a23562018-05-10 13:17:35 -0700660}
661
Russell Kingc9a23562018-05-10 13:17:35 -0700662static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port,
663 unsigned int mode,
664 const struct phylink_link_state *state)
665{
666 struct mv88e6xxx_chip *chip = ds->priv;
Russell King64d47d52020-03-14 10:15:38 +0000667 int err;
Russell Kingc9a23562018-05-10 13:17:35 -0700668
Russell King64d47d52020-03-14 10:15:38 +0000669 /* FIXME: is this the correct test? If we're in fixed mode on an
670 * internal port, why should we process this any different from
671 * PHY mode? On the other hand, the port may be automedia between
672 * an internal PHY and the serdes...
673 */
Marek Vasutd700ec42018-09-12 00:15:24 +0200674 if ((mode == MLO_AN_PHY) && mv88e6xxx_phy_is_internal(ds, port))
Russell Kingc9a23562018-05-10 13:17:35 -0700675 return;
676
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000677 mv88e6xxx_reg_lock(chip);
Russell King64d47d52020-03-14 10:15:38 +0000678 /* FIXME: should we force the link down here - but if we do, how
679 * do we restore the link force/unforce state? The driver layering
680 * gets in the way.
681 */
682 err = mv88e6xxx_port_config_interface(chip, port, state->interface);
Russell Kinga5a68582020-03-14 10:15:43 +0000683 if (err && err != -EOPNOTSUPP)
684 goto err_unlock;
685
686 err = mv88e6xxx_serdes_pcs_config(chip, port, mode, state->interface,
687 state->advertising);
688 /* FIXME: we should restart negotiation if something changed - which
689 * is something we get if we convert to using phylinks PCS operations.
690 */
691 if (err > 0)
692 err = 0;
693
694err_unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000695 mv88e6xxx_reg_unlock(chip);
Russell Kingc9a23562018-05-10 13:17:35 -0700696
697 if (err && err != -EOPNOTSUPP)
Russell King64d47d52020-03-14 10:15:38 +0000698 dev_err(ds->dev, "p%d: failed to configure MAC/PCS\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700699}
700
Russell Kingc9a23562018-05-10 13:17:35 -0700701static void mv88e6xxx_mac_link_down(struct dsa_switch *ds, int port,
702 unsigned int mode,
703 phy_interface_t interface)
704{
Russell King30c4a5b2020-02-26 10:23:51 +0000705 struct mv88e6xxx_chip *chip = ds->priv;
706 const struct mv88e6xxx_ops *ops;
707 int err = 0;
708
709 ops = chip->info->ops;
710
Russell King5d5b2312020-03-14 10:16:03 +0000711 mv88e6xxx_reg_lock(chip);
712 if (!mv88e6xxx_port_ppu_updates(chip, port) && ops->port_set_link)
Russell King30c4a5b2020-02-26 10:23:51 +0000713 err = ops->port_set_link(chip, port, LINK_FORCED_DOWN);
Russell King5d5b2312020-03-14 10:16:03 +0000714 mv88e6xxx_reg_unlock(chip);
Russell King30c4a5b2020-02-26 10:23:51 +0000715
Russell King5d5b2312020-03-14 10:16:03 +0000716 if (err)
717 dev_err(chip->dev,
718 "p%d: failed to force MAC link down\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700719}
720
721static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
722 unsigned int mode, phy_interface_t interface,
Russell King5b502a72020-02-26 10:23:46 +0000723 struct phy_device *phydev,
724 int speed, int duplex,
725 bool tx_pause, bool rx_pause)
Russell Kingc9a23562018-05-10 13:17:35 -0700726{
Russell King30c4a5b2020-02-26 10:23:51 +0000727 struct mv88e6xxx_chip *chip = ds->priv;
728 const struct mv88e6xxx_ops *ops;
729 int err = 0;
730
731 ops = chip->info->ops;
732
Russell King5d5b2312020-03-14 10:16:03 +0000733 mv88e6xxx_reg_lock(chip);
734 if (!mv88e6xxx_port_ppu_updates(chip, port)) {
Russell King30c4a5b2020-02-26 10:23:51 +0000735 /* FIXME: for an automedia port, should we force the link
736 * down here - what if the link comes up due to "other" media
737 * while we're bringing the port up, how is the exclusivity
Russell Kinga5a68582020-03-14 10:15:43 +0000738 * handled in the Marvell hardware? E.g. port 2 on 88E6390
Russell King30c4a5b2020-02-26 10:23:51 +0000739 * shared between internal PHY and Serdes.
740 */
Russell Kinga5a68582020-03-14 10:15:43 +0000741 err = mv88e6xxx_serdes_pcs_link_up(chip, port, mode, speed,
742 duplex);
743 if (err)
744 goto error;
745
Russell Kingf365c6f2020-03-14 10:15:53 +0000746 if (ops->port_set_speed_duplex) {
747 err = ops->port_set_speed_duplex(chip, port,
748 speed, duplex);
Russell King30c4a5b2020-02-26 10:23:51 +0000749 if (err && err != -EOPNOTSUPP)
750 goto error;
751 }
752
753 if (ops->port_set_link)
754 err = ops->port_set_link(chip, port, LINK_FORCED_UP);
Russell King30c4a5b2020-02-26 10:23:51 +0000755 }
Russell King5d5b2312020-03-14 10:16:03 +0000756error:
757 mv88e6xxx_reg_unlock(chip);
758
759 if (err && err != -EOPNOTSUPP)
760 dev_err(ds->dev,
761 "p%d: failed to configure MAC link up\n", port);
Russell Kingc9a23562018-05-10 13:17:35 -0700762}
763
Andrew Lunna605a0f2016-11-21 23:26:58 +0100764static int mv88e6xxx_stats_snapshot(struct mv88e6xxx_chip *chip, int port)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000765{
Andrew Lunna605a0f2016-11-21 23:26:58 +0100766 if (!chip->info->ops->stats_snapshot)
767 return -EOPNOTSUPP;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000768
Andrew Lunna605a0f2016-11-21 23:26:58 +0100769 return chip->info->ops->stats_snapshot(chip, port);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +0000770}
771
Andrew Lunne413e7e2015-04-02 04:06:38 +0200772static struct mv88e6xxx_hw_stat mv88e6xxx_hw_stats[] = {
Andrew Lunndfafe442016-11-21 23:27:02 +0100773 { "in_good_octets", 8, 0x00, STATS_TYPE_BANK0, },
774 { "in_bad_octets", 4, 0x02, STATS_TYPE_BANK0, },
775 { "in_unicast", 4, 0x04, STATS_TYPE_BANK0, },
776 { "in_broadcasts", 4, 0x06, STATS_TYPE_BANK0, },
777 { "in_multicasts", 4, 0x07, STATS_TYPE_BANK0, },
778 { "in_pause", 4, 0x16, STATS_TYPE_BANK0, },
779 { "in_undersize", 4, 0x18, STATS_TYPE_BANK0, },
780 { "in_fragments", 4, 0x19, STATS_TYPE_BANK0, },
781 { "in_oversize", 4, 0x1a, STATS_TYPE_BANK0, },
782 { "in_jabber", 4, 0x1b, STATS_TYPE_BANK0, },
783 { "in_rx_error", 4, 0x1c, STATS_TYPE_BANK0, },
784 { "in_fcs_error", 4, 0x1d, STATS_TYPE_BANK0, },
785 { "out_octets", 8, 0x0e, STATS_TYPE_BANK0, },
786 { "out_unicast", 4, 0x10, STATS_TYPE_BANK0, },
787 { "out_broadcasts", 4, 0x13, STATS_TYPE_BANK0, },
788 { "out_multicasts", 4, 0x12, STATS_TYPE_BANK0, },
789 { "out_pause", 4, 0x15, STATS_TYPE_BANK0, },
790 { "excessive", 4, 0x11, STATS_TYPE_BANK0, },
791 { "collisions", 4, 0x1e, STATS_TYPE_BANK0, },
792 { "deferred", 4, 0x05, STATS_TYPE_BANK0, },
793 { "single", 4, 0x14, STATS_TYPE_BANK0, },
794 { "multiple", 4, 0x17, STATS_TYPE_BANK0, },
795 { "out_fcs_error", 4, 0x03, STATS_TYPE_BANK0, },
796 { "late", 4, 0x1f, STATS_TYPE_BANK0, },
797 { "hist_64bytes", 4, 0x08, STATS_TYPE_BANK0, },
798 { "hist_65_127bytes", 4, 0x09, STATS_TYPE_BANK0, },
799 { "hist_128_255bytes", 4, 0x0a, STATS_TYPE_BANK0, },
800 { "hist_256_511bytes", 4, 0x0b, STATS_TYPE_BANK0, },
801 { "hist_512_1023bytes", 4, 0x0c, STATS_TYPE_BANK0, },
802 { "hist_1024_max_bytes", 4, 0x0d, STATS_TYPE_BANK0, },
803 { "sw_in_discards", 4, 0x10, STATS_TYPE_PORT, },
804 { "sw_in_filtered", 2, 0x12, STATS_TYPE_PORT, },
805 { "sw_out_filtered", 2, 0x13, STATS_TYPE_PORT, },
806 { "in_discards", 4, 0x00, STATS_TYPE_BANK1, },
807 { "in_filtered", 4, 0x01, STATS_TYPE_BANK1, },
808 { "in_accepted", 4, 0x02, STATS_TYPE_BANK1, },
809 { "in_bad_accepted", 4, 0x03, STATS_TYPE_BANK1, },
810 { "in_good_avb_class_a", 4, 0x04, STATS_TYPE_BANK1, },
811 { "in_good_avb_class_b", 4, 0x05, STATS_TYPE_BANK1, },
812 { "in_bad_avb_class_a", 4, 0x06, STATS_TYPE_BANK1, },
813 { "in_bad_avb_class_b", 4, 0x07, STATS_TYPE_BANK1, },
814 { "tcam_counter_0", 4, 0x08, STATS_TYPE_BANK1, },
815 { "tcam_counter_1", 4, 0x09, STATS_TYPE_BANK1, },
816 { "tcam_counter_2", 4, 0x0a, STATS_TYPE_BANK1, },
817 { "tcam_counter_3", 4, 0x0b, STATS_TYPE_BANK1, },
818 { "in_da_unknown", 4, 0x0e, STATS_TYPE_BANK1, },
819 { "in_management", 4, 0x0f, STATS_TYPE_BANK1, },
820 { "out_queue_0", 4, 0x10, STATS_TYPE_BANK1, },
821 { "out_queue_1", 4, 0x11, STATS_TYPE_BANK1, },
822 { "out_queue_2", 4, 0x12, STATS_TYPE_BANK1, },
823 { "out_queue_3", 4, 0x13, STATS_TYPE_BANK1, },
824 { "out_queue_4", 4, 0x14, STATS_TYPE_BANK1, },
825 { "out_queue_5", 4, 0x15, STATS_TYPE_BANK1, },
826 { "out_queue_6", 4, 0x16, STATS_TYPE_BANK1, },
827 { "out_queue_7", 4, 0x17, STATS_TYPE_BANK1, },
828 { "out_cut_through", 4, 0x18, STATS_TYPE_BANK1, },
829 { "out_octets_a", 4, 0x1a, STATS_TYPE_BANK1, },
830 { "out_octets_b", 4, 0x1b, STATS_TYPE_BANK1, },
831 { "out_management", 4, 0x1f, STATS_TYPE_BANK1, },
Andrew Lunne413e7e2015-04-02 04:06:38 +0200832};
833
Vivien Didelotfad09c72016-06-21 12:28:20 -0400834static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100835 struct mv88e6xxx_hw_stat *s,
Andrew Lunne0d8b612016-11-21 23:27:04 +0100836 int port, u16 bank1_select,
837 u16 histogram)
Andrew Lunn80c46272015-06-20 18:42:30 +0200838{
Andrew Lunn80c46272015-06-20 18:42:30 +0200839 u32 low;
840 u32 high = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100841 u16 reg = 0;
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200842 int err;
Andrew Lunn80c46272015-06-20 18:42:30 +0200843 u64 value;
844
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100845 switch (s->type) {
Andrew Lunndfafe442016-11-21 23:27:02 +0100846 case STATS_TYPE_PORT:
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200847 err = mv88e6xxx_port_read(chip, port, s->reg, &reg);
848 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800849 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200850
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200851 low = reg;
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100852 if (s->size == 4) {
Andrew Lunn0e7b9922016-09-21 01:40:31 +0200853 err = mv88e6xxx_port_read(chip, port, s->reg + 1, &reg);
854 if (err)
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800855 return U64_MAX;
Rasmus Villemoes84b3fd12019-05-29 07:02:11 +0000856 low |= ((u32)reg) << 16;
Andrew Lunn80c46272015-06-20 18:42:30 +0200857 }
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100858 break;
Andrew Lunndfafe442016-11-21 23:27:02 +0100859 case STATS_TYPE_BANK1:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100860 reg = bank1_select;
Andrew Lunndfafe442016-11-21 23:27:02 +0100861 /* fall through */
862 case STATS_TYPE_BANK0:
Andrew Lunne0d8b612016-11-21 23:27:04 +0100863 reg |= s->reg | histogram;
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100864 mv88e6xxx_g1_stats_read(chip, reg, &low);
Andrew Lunncda9f4a2018-03-01 02:02:31 +0100865 if (s->size == 8)
Andrew Lunn7f9ef3a2016-11-21 23:27:05 +0100866 mv88e6xxx_g1_stats_read(chip, reg + 1, &high);
Gustavo A. R. Silva9fc3e4d2017-05-11 22:11:29 -0500867 break;
868 default:
Jisheng Zhang6c3442f2018-04-27 16:18:58 +0800869 return U64_MAX;
Andrew Lunn80c46272015-06-20 18:42:30 +0200870 }
Andrew Lunn6e46e2d2019-02-28 18:14:03 +0100871 value = (((u64)high) << 32) | low;
Andrew Lunn80c46272015-06-20 18:42:30 +0200872 return value;
873}
874
Andrew Lunn436fe172018-03-01 02:02:29 +0100875static int mv88e6xxx_stats_get_strings(struct mv88e6xxx_chip *chip,
876 uint8_t *data, int types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100877{
878 struct mv88e6xxx_hw_stat *stat;
879 int i, j;
880
881 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
882 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100883 if (stat->type & types) {
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100884 memcpy(data + j * ETH_GSTRING_LEN, stat->string,
885 ETH_GSTRING_LEN);
886 j++;
887 }
888 }
Andrew Lunn436fe172018-03-01 02:02:29 +0100889
890 return j;
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100891}
892
Andrew Lunn436fe172018-03-01 02:02:29 +0100893static int mv88e6095_stats_get_strings(struct mv88e6xxx_chip *chip,
894 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100895{
Andrew Lunn436fe172018-03-01 02:02:29 +0100896 return mv88e6xxx_stats_get_strings(chip, data,
897 STATS_TYPE_BANK0 | STATS_TYPE_PORT);
Andrew Lunndfafe442016-11-21 23:27:02 +0100898}
899
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000900static int mv88e6250_stats_get_strings(struct mv88e6xxx_chip *chip,
901 uint8_t *data)
902{
903 return mv88e6xxx_stats_get_strings(chip, data, STATS_TYPE_BANK0);
904}
905
Andrew Lunn436fe172018-03-01 02:02:29 +0100906static int mv88e6320_stats_get_strings(struct mv88e6xxx_chip *chip,
907 uint8_t *data)
Andrew Lunndfafe442016-11-21 23:27:02 +0100908{
Andrew Lunn436fe172018-03-01 02:02:29 +0100909 return mv88e6xxx_stats_get_strings(chip, data,
910 STATS_TYPE_BANK0 | STATS_TYPE_BANK1);
Andrew Lunndfafe442016-11-21 23:27:02 +0100911}
912
Andrew Lunn65f60e42018-03-28 23:50:28 +0200913static const uint8_t *mv88e6xxx_atu_vtu_stats_strings[] = {
914 "atu_member_violation",
915 "atu_miss_violation",
916 "atu_full_violation",
917 "vtu_member_violation",
918 "vtu_miss_violation",
919};
920
921static void mv88e6xxx_atu_vtu_get_strings(uint8_t *data)
922{
923 unsigned int i;
924
925 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings); i++)
926 strlcpy(data + i * ETH_GSTRING_LEN,
927 mv88e6xxx_atu_vtu_stats_strings[i],
928 ETH_GSTRING_LEN);
929}
930
Andrew Lunndfafe442016-11-21 23:27:02 +0100931static void mv88e6xxx_get_strings(struct dsa_switch *ds, int port,
Florian Fainelli89f09042018-04-25 12:12:50 -0700932 u32 stringset, uint8_t *data)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100933{
Vivien Didelot04bed142016-08-31 18:06:13 -0400934 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100935 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100936
Florian Fainelli89f09042018-04-25 12:12:50 -0700937 if (stringset != ETH_SS_STATS)
938 return;
939
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000940 mv88e6xxx_reg_lock(chip);
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100941
Andrew Lunndfafe442016-11-21 23:27:02 +0100942 if (chip->info->ops->stats_get_strings)
Andrew Lunn436fe172018-03-01 02:02:29 +0100943 count = chip->info->ops->stats_get_strings(chip, data);
944
945 if (chip->info->ops->serdes_get_strings) {
946 data += count * ETH_GSTRING_LEN;
Andrew Lunn65f60e42018-03-28 23:50:28 +0200947 count = chip->info->ops->serdes_get_strings(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +0100948 }
Andrew Lunnc6c8cd52018-03-01 02:02:28 +0100949
Andrew Lunn65f60e42018-03-28 23:50:28 +0200950 data += count * ETH_GSTRING_LEN;
951 mv88e6xxx_atu_vtu_get_strings(data);
952
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000953 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100954}
955
956static int mv88e6xxx_stats_get_sset_count(struct mv88e6xxx_chip *chip,
957 int types)
958{
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100959 struct mv88e6xxx_hw_stat *stat;
960 int i, j;
961
962 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
963 stat = &mv88e6xxx_hw_stats[i];
Andrew Lunndfafe442016-11-21 23:27:02 +0100964 if (stat->type & types)
Andrew Lunnf5e2ed02015-12-23 13:23:17 +0100965 j++;
966 }
967 return j;
968}
969
Andrew Lunndfafe442016-11-21 23:27:02 +0100970static int mv88e6095_stats_get_sset_count(struct mv88e6xxx_chip *chip)
971{
972 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
973 STATS_TYPE_PORT);
974}
975
Rasmus Villemoes1f718362019-06-04 07:34:32 +0000976static int mv88e6250_stats_get_sset_count(struct mv88e6xxx_chip *chip)
977{
978 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0);
979}
980
Andrew Lunndfafe442016-11-21 23:27:02 +0100981static int mv88e6320_stats_get_sset_count(struct mv88e6xxx_chip *chip)
982{
983 return mv88e6xxx_stats_get_sset_count(chip, STATS_TYPE_BANK0 |
984 STATS_TYPE_BANK1);
985}
986
Florian Fainelli89f09042018-04-25 12:12:50 -0700987static int mv88e6xxx_get_sset_count(struct dsa_switch *ds, int port, int sset)
Andrew Lunndfafe442016-11-21 23:27:02 +0100988{
989 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn436fe172018-03-01 02:02:29 +0100990 int serdes_count = 0;
991 int count = 0;
Andrew Lunndfafe442016-11-21 23:27:02 +0100992
Florian Fainelli89f09042018-04-25 12:12:50 -0700993 if (sset != ETH_SS_STATS)
994 return 0;
995
Rasmus Villemoesc9acece2019-06-20 13:50:42 +0000996 mv88e6xxx_reg_lock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +0100997 if (chip->info->ops->stats_get_sset_count)
Andrew Lunn436fe172018-03-01 02:02:29 +0100998 count = chip->info->ops->stats_get_sset_count(chip);
999 if (count < 0)
1000 goto out;
1001
1002 if (chip->info->ops->serdes_get_sset_count)
1003 serdes_count = chip->info->ops->serdes_get_sset_count(chip,
1004 port);
Andrew Lunn65f60e42018-03-28 23:50:28 +02001005 if (serdes_count < 0) {
Andrew Lunn436fe172018-03-01 02:02:29 +01001006 count = serdes_count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001007 goto out;
1008 }
1009 count += serdes_count;
1010 count += ARRAY_SIZE(mv88e6xxx_atu_vtu_stats_strings);
1011
Andrew Lunn436fe172018-03-01 02:02:29 +01001012out:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001013 mv88e6xxx_reg_unlock(chip);
Andrew Lunndfafe442016-11-21 23:27:02 +01001014
Andrew Lunn436fe172018-03-01 02:02:29 +01001015 return count;
Andrew Lunndfafe442016-11-21 23:27:02 +01001016}
1017
Andrew Lunn436fe172018-03-01 02:02:29 +01001018static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1019 uint64_t *data, int types,
1020 u16 bank1_select, u16 histogram)
Andrew Lunn052f9472016-11-21 23:27:03 +01001021{
1022 struct mv88e6xxx_hw_stat *stat;
1023 int i, j;
1024
1025 for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
1026 stat = &mv88e6xxx_hw_stats[i];
1027 if (stat->type & types) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001028 mv88e6xxx_reg_lock(chip);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001029 data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port,
1030 bank1_select,
1031 histogram);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001032 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001033
Andrew Lunn052f9472016-11-21 23:27:03 +01001034 j++;
1035 }
1036 }
Andrew Lunn436fe172018-03-01 02:02:29 +01001037 return j;
Andrew Lunn052f9472016-11-21 23:27:03 +01001038}
1039
Andrew Lunn436fe172018-03-01 02:02:29 +01001040static int mv88e6095_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1041 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001042{
1043 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001044 STATS_TYPE_BANK0 | STATS_TYPE_PORT,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001045 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunn052f9472016-11-21 23:27:03 +01001046}
1047
Rasmus Villemoes1f718362019-06-04 07:34:32 +00001048static int mv88e6250_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1049 uint64_t *data)
1050{
1051 return mv88e6xxx_stats_get_stats(chip, port, data, STATS_TYPE_BANK0,
1052 0, MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
1053}
1054
Andrew Lunn436fe172018-03-01 02:02:29 +01001055static int mv88e6320_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1056 uint64_t *data)
Andrew Lunn052f9472016-11-21 23:27:03 +01001057{
1058 return mv88e6xxx_stats_get_stats(chip, port, data,
Andrew Lunne0d8b612016-11-21 23:27:04 +01001059 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001060 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_9,
1061 MV88E6XXX_G1_STATS_OP_HIST_RX_TX);
Andrew Lunne0d8b612016-11-21 23:27:04 +01001062}
1063
Andrew Lunn436fe172018-03-01 02:02:29 +01001064static int mv88e6390_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
1065 uint64_t *data)
Andrew Lunne0d8b612016-11-21 23:27:04 +01001066{
1067 return mv88e6xxx_stats_get_stats(chip, port, data,
1068 STATS_TYPE_BANK0 | STATS_TYPE_BANK1,
Vivien Didelot57d1ef32017-06-15 12:14:05 -04001069 MV88E6XXX_G1_STATS_OP_BANK_1_BIT_10,
1070 0);
Andrew Lunn052f9472016-11-21 23:27:03 +01001071}
1072
Andrew Lunn65f60e42018-03-28 23:50:28 +02001073static void mv88e6xxx_atu_vtu_get_stats(struct mv88e6xxx_chip *chip, int port,
1074 uint64_t *data)
1075{
1076 *data++ = chip->ports[port].atu_member_violation;
1077 *data++ = chip->ports[port].atu_miss_violation;
1078 *data++ = chip->ports[port].atu_full_violation;
1079 *data++ = chip->ports[port].vtu_member_violation;
1080 *data++ = chip->ports[port].vtu_miss_violation;
1081}
1082
Andrew Lunn052f9472016-11-21 23:27:03 +01001083static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
1084 uint64_t *data)
1085{
Andrew Lunn436fe172018-03-01 02:02:29 +01001086 int count = 0;
1087
Andrew Lunn052f9472016-11-21 23:27:03 +01001088 if (chip->info->ops->stats_get_stats)
Andrew Lunn436fe172018-03-01 02:02:29 +01001089 count = chip->info->ops->stats_get_stats(chip, port, data);
1090
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001091 mv88e6xxx_reg_lock(chip);
Andrew Lunn436fe172018-03-01 02:02:29 +01001092 if (chip->info->ops->serdes_get_stats) {
1093 data += count;
Andrew Lunn65f60e42018-03-28 23:50:28 +02001094 count = chip->info->ops->serdes_get_stats(chip, port, data);
Andrew Lunn436fe172018-03-01 02:02:29 +01001095 }
Andrew Lunn65f60e42018-03-28 23:50:28 +02001096 data += count;
1097 mv88e6xxx_atu_vtu_get_stats(chip, port, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001098 mv88e6xxx_reg_unlock(chip);
Andrew Lunn052f9472016-11-21 23:27:03 +01001099}
1100
Vivien Didelotf81ec902016-05-09 13:22:58 -04001101static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port,
1102 uint64_t *data)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001103{
Vivien Didelot04bed142016-08-31 18:06:13 -04001104 struct mv88e6xxx_chip *chip = ds->priv;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001105 int ret;
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001106
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001107 mv88e6xxx_reg_lock(chip);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001108
Andrew Lunna605a0f2016-11-21 23:26:58 +01001109 ret = mv88e6xxx_stats_snapshot(chip, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001110 mv88e6xxx_reg_unlock(chip);
Andrew Lunn377cda12018-02-15 14:38:34 +01001111
1112 if (ret < 0)
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001113 return;
Andrew Lunn052f9472016-11-21 23:27:03 +01001114
1115 mv88e6xxx_get_stats(chip, port, data);
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001116
Lennert Buytenhek91da11f2008-10-07 13:44:02 +00001117}
Ben Hutchings98e67302011-11-25 14:36:19 +00001118
Vivien Didelotf81ec902016-05-09 13:22:58 -04001119static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001120{
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001121 struct mv88e6xxx_chip *chip = ds->priv;
1122 int len;
1123
1124 len = 32 * sizeof(u16);
1125 if (chip->info->ops->serdes_get_regs_len)
1126 len += chip->info->ops->serdes_get_regs_len(chip, port);
1127
1128 return len;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001129}
1130
Vivien Didelotf81ec902016-05-09 13:22:58 -04001131static void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
1132 struct ethtool_regs *regs, void *_p)
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001133{
Vivien Didelot04bed142016-08-31 18:06:13 -04001134 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001135 int err;
1136 u16 reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001137 u16 *p = _p;
1138 int i;
1139
Vivien Didelota5f39322018-12-17 16:05:21 -05001140 regs->version = chip->info->prod_num;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001141
1142 memset(p, 0xff, 32 * sizeof(u16));
1143
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001144 mv88e6xxx_reg_lock(chip);
Vivien Didelot23062512016-05-09 13:22:45 -04001145
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001146 for (i = 0; i < 32; i++) {
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001147
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001148 err = mv88e6xxx_port_read(chip, port, i, &reg);
1149 if (!err)
1150 p[i] = reg;
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001151 }
Vivien Didelot23062512016-05-09 13:22:45 -04001152
Andrew Lunn0d30bbd2020-02-16 18:54:13 +01001153 if (chip->info->ops->serdes_get_regs)
1154 chip->info->ops->serdes_get_regs(chip, port, &p[i]);
1155
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001156 mv88e6xxx_reg_unlock(chip);
Guenter Roecka1ab91f2014-10-29 10:45:05 -07001157}
1158
Vivien Didelot08f50062017-08-01 16:32:41 -04001159static int mv88e6xxx_get_mac_eee(struct dsa_switch *ds, int port,
1160 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001161{
Vivien Didelot5480db62017-08-01 16:32:40 -04001162 /* Nothing to do on the port's MAC */
1163 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001164}
1165
Vivien Didelot08f50062017-08-01 16:32:41 -04001166static int mv88e6xxx_set_mac_eee(struct dsa_switch *ds, int port,
1167 struct ethtool_eee *e)
Guenter Roeck11b3b452015-03-06 22:23:51 -08001168{
Vivien Didelot5480db62017-08-01 16:32:40 -04001169 /* Nothing to do on the port's MAC */
1170 return 0;
Guenter Roeck11b3b452015-03-06 22:23:51 -08001171}
1172
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001173/* Mask of the local ports allowed to receive frames from a given fabric port */
Vivien Didelote5887a22017-03-30 17:37:11 -04001174static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001175{
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001176 struct dsa_switch *ds = chip->ds;
1177 struct dsa_switch_tree *dst = ds->dst;
Vivien Didelote5887a22017-03-30 17:37:11 -04001178 struct net_device *br;
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001179 struct dsa_port *dp;
1180 bool found = false;
Vivien Didelote5887a22017-03-30 17:37:11 -04001181 u16 pvlan;
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001182
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001183 list_for_each_entry(dp, &dst->ports, list) {
1184 if (dp->ds->index == dev && dp->index == port) {
1185 found = true;
1186 break;
1187 }
1188 }
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001189
Vivien Didelote5887a22017-03-30 17:37:11 -04001190 /* Prevent frames from unknown switch or port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001191 if (!found)
Vivien Didelote5887a22017-03-30 17:37:11 -04001192 return 0;
1193
1194 /* Frames from DSA links and CPU ports can egress any local port */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001195 if (dp->type == DSA_PORT_TYPE_CPU || dp->type == DSA_PORT_TYPE_DSA)
Vivien Didelote5887a22017-03-30 17:37:11 -04001196 return mv88e6xxx_port_mask(chip);
1197
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001198 br = dp->bridge_dev;
Vivien Didelote5887a22017-03-30 17:37:11 -04001199 pvlan = 0;
1200
1201 /* Frames from user ports can egress any local DSA links and CPU ports,
1202 * as well as any local member of their bridge group.
1203 */
Vivien Didelot9dc8b132019-10-21 16:51:26 -04001204 list_for_each_entry(dp, &dst->ports, list)
1205 if (dp->ds == ds &&
1206 (dp->type == DSA_PORT_TYPE_CPU ||
1207 dp->type == DSA_PORT_TYPE_DSA ||
1208 (br && dp->bridge_dev == br)))
1209 pvlan |= BIT(dp->index);
Vivien Didelote5887a22017-03-30 17:37:11 -04001210
1211 return pvlan;
1212}
1213
Vivien Didelot240ea3e2017-03-30 17:37:12 -04001214static int mv88e6xxx_port_vlan_map(struct mv88e6xxx_chip *chip, int port)
Vivien Didelote5887a22017-03-30 17:37:11 -04001215{
1216 u16 output_ports = mv88e6xxx_port_vlan(chip, chip->ds->index, port);
Vivien Didelotb7666ef2016-02-26 13:16:06 -05001217
1218 /* prevent frames from going back out of the port they came in on */
1219 output_ports &= ~BIT(port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001220
Vivien Didelot5a7921f2016-11-04 03:23:28 +01001221 return mv88e6xxx_port_set_vlan_map(chip, port, output_ports);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001222}
1223
Vivien Didelotf81ec902016-05-09 13:22:58 -04001224static void mv88e6xxx_port_stp_state_set(struct dsa_switch *ds, int port,
1225 u8 state)
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001226{
Vivien Didelot04bed142016-08-31 18:06:13 -04001227 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot553eb542016-05-13 20:38:23 -04001228 int err;
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001229
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001230 mv88e6xxx_reg_lock(chip);
Vivien Didelotf894c292017-06-08 18:34:10 -04001231 err = mv88e6xxx_port_set_state(chip, port, state);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001232 mv88e6xxx_reg_unlock(chip);
Vivien Didelot553eb542016-05-13 20:38:23 -04001233
1234 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001235 dev_err(ds->dev, "p%d: failed to update state\n", port);
Guenter Roeckfacd95b2015-03-26 18:36:35 -07001236}
1237
Vivien Didelot93e18d62018-05-11 17:16:35 -04001238static int mv88e6xxx_pri_setup(struct mv88e6xxx_chip *chip)
1239{
1240 int err;
1241
1242 if (chip->info->ops->ieee_pri_map) {
1243 err = chip->info->ops->ieee_pri_map(chip);
1244 if (err)
1245 return err;
1246 }
1247
1248 if (chip->info->ops->ip_pri_map) {
1249 err = chip->info->ops->ip_pri_map(chip);
1250 if (err)
1251 return err;
1252 }
1253
1254 return 0;
1255}
1256
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001257static int mv88e6xxx_devmap_setup(struct mv88e6xxx_chip *chip)
1258{
Vivien Didelotc5f51762019-10-30 22:09:13 -04001259 struct dsa_switch *ds = chip->ds;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001260 int target, port;
1261 int err;
1262
1263 if (!chip->info->global2_addr)
1264 return 0;
1265
1266 /* Initialize the routing port to the 32 possible target devices */
1267 for (target = 0; target < 32; target++) {
Vivien Didelotc5f51762019-10-30 22:09:13 -04001268 port = dsa_routing_port(ds, target);
1269 if (port == ds->num_ports)
1270 port = 0x1f;
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001271
1272 err = mv88e6xxx_g2_device_mapping_write(chip, target, port);
1273 if (err)
1274 return err;
1275 }
1276
Vivien Didelot02317e62018-05-09 11:38:49 -04001277 if (chip->info->ops->set_cascade_port) {
1278 port = MV88E6XXX_CASCADE_PORT_MULTIPLE;
1279 err = chip->info->ops->set_cascade_port(chip, port);
1280 if (err)
1281 return err;
1282 }
1283
Vivien Didelot23c98912018-05-09 11:38:50 -04001284 err = mv88e6xxx_g1_set_device_number(chip, chip->ds->index);
1285 if (err)
1286 return err;
1287
Vivien Didelotc7f047b2018-04-26 21:56:45 -04001288 return 0;
1289}
1290
Vivien Didelotb28f8722018-04-26 21:56:44 -04001291static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
1292{
1293 /* Clear all trunk masks and mapping */
1294 if (chip->info->global2_addr)
1295 return mv88e6xxx_g2_trunk_clear(chip);
1296
1297 return 0;
1298}
1299
Vivien Didelot9e5baf92018-05-09 11:38:51 -04001300static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
1301{
1302 if (chip->info->ops->rmu_disable)
1303 return chip->info->ops->rmu_disable(chip);
1304
1305 return 0;
1306}
1307
Vivien Didelot9e907d72017-07-17 13:03:43 -04001308static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
1309{
1310 if (chip->info->ops->pot_clear)
1311 return chip->info->ops->pot_clear(chip);
1312
1313 return 0;
1314}
1315
Vivien Didelot51c901a2017-07-17 13:03:41 -04001316static int mv88e6xxx_rsvd2cpu_setup(struct mv88e6xxx_chip *chip)
1317{
1318 if (chip->info->ops->mgmt_rsvd2cpu)
1319 return chip->info->ops->mgmt_rsvd2cpu(chip);
1320
1321 return 0;
1322}
1323
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001324static int mv88e6xxx_atu_setup(struct mv88e6xxx_chip *chip)
1325{
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001326 int err;
1327
Vivien Didelotdaefc942017-03-11 16:12:54 -05001328 err = mv88e6xxx_g1_atu_flush(chip, 0, true);
1329 if (err)
1330 return err;
1331
Vivien Didelotc3a7d4a2017-03-11 16:12:51 -05001332 err = mv88e6xxx_g1_atu_set_learn2all(chip, true);
1333 if (err)
1334 return err;
1335
Vivien Didelota2ac29d2017-03-11 16:12:49 -05001336 return mv88e6xxx_g1_atu_set_age_time(chip, 300000);
1337}
1338
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04001339static int mv88e6xxx_irl_setup(struct mv88e6xxx_chip *chip)
1340{
1341 int port;
1342 int err;
1343
1344 if (!chip->info->ops->irl_init_all)
1345 return 0;
1346
1347 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1348 /* Disable ingress rate limiting by resetting all per port
1349 * ingress rate limit resources to their initial state.
1350 */
1351 err = chip->info->ops->irl_init_all(chip, port);
1352 if (err)
1353 return err;
1354 }
1355
1356 return 0;
1357}
1358
Vivien Didelot04a69a12017-10-13 14:18:05 -04001359static int mv88e6xxx_mac_setup(struct mv88e6xxx_chip *chip)
1360{
1361 if (chip->info->ops->set_switch_mac) {
1362 u8 addr[ETH_ALEN];
1363
1364 eth_random_addr(addr);
1365
1366 return chip->info->ops->set_switch_mac(chip, addr);
1367 }
1368
1369 return 0;
1370}
1371
Vivien Didelot17a15942017-03-30 17:37:09 -04001372static int mv88e6xxx_pvt_map(struct mv88e6xxx_chip *chip, int dev, int port)
1373{
1374 u16 pvlan = 0;
1375
1376 if (!mv88e6xxx_has_pvt(chip))
Vivien Didelotd14939b2019-10-21 16:51:25 -04001377 return 0;
Vivien Didelot17a15942017-03-30 17:37:09 -04001378
1379 /* Skip the local source device, which uses in-chip port VLAN */
1380 if (dev != chip->ds->index)
Vivien Didelotaec5ac82017-03-30 17:37:15 -04001381 pvlan = mv88e6xxx_port_vlan(chip, dev, port);
Vivien Didelot17a15942017-03-30 17:37:09 -04001382
1383 return mv88e6xxx_g2_pvt_write(chip, dev, port, pvlan);
1384}
1385
Vivien Didelot81228992017-03-30 17:37:08 -04001386static int mv88e6xxx_pvt_setup(struct mv88e6xxx_chip *chip)
1387{
Vivien Didelot17a15942017-03-30 17:37:09 -04001388 int dev, port;
1389 int err;
1390
Vivien Didelot81228992017-03-30 17:37:08 -04001391 if (!mv88e6xxx_has_pvt(chip))
1392 return 0;
1393
1394 /* Clear 5 Bit Port for usage with Marvell Link Street devices:
1395 * use 4 bits for the Src_Port/Src_Trunk and 5 bits for the Src_Dev.
1396 */
Vivien Didelot17a15942017-03-30 17:37:09 -04001397 err = mv88e6xxx_g2_misc_4_bit_port(chip);
1398 if (err)
1399 return err;
1400
1401 for (dev = 0; dev < MV88E6XXX_MAX_PVT_SWITCHES; ++dev) {
1402 for (port = 0; port < MV88E6XXX_MAX_PVT_PORTS; ++port) {
1403 err = mv88e6xxx_pvt_map(chip, dev, port);
1404 if (err)
1405 return err;
1406 }
1407 }
1408
1409 return 0;
Vivien Didelot81228992017-03-30 17:37:08 -04001410}
1411
Vivien Didelot749efcb2016-09-22 16:49:24 -04001412static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port)
1413{
1414 struct mv88e6xxx_chip *chip = ds->priv;
1415 int err;
1416
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001417 mv88e6xxx_reg_lock(chip);
Vivien Didelote606ca32017-03-11 16:12:55 -05001418 err = mv88e6xxx_g1_atu_remove(chip, 0, port, false);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001419 mv88e6xxx_reg_unlock(chip);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001420
1421 if (err)
Vivien Didelot774439e52017-06-08 18:34:08 -04001422 dev_err(ds->dev, "p%d: failed to flush ATU\n", port);
Vivien Didelot749efcb2016-09-22 16:49:24 -04001423}
1424
Vivien Didelotb486d7c2017-05-01 14:05:13 -04001425static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip)
1426{
1427 if (!chip->info->max_vid)
1428 return 0;
1429
1430 return mv88e6xxx_g1_vtu_flush(chip);
1431}
1432
Vivien Didelotf1394b782017-05-01 14:05:22 -04001433static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip,
1434 struct mv88e6xxx_vtu_entry *entry)
1435{
1436 if (!chip->info->ops->vtu_getnext)
1437 return -EOPNOTSUPP;
1438
1439 return chip->info->ops->vtu_getnext(chip, entry);
1440}
1441
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04001442static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip,
1443 struct mv88e6xxx_vtu_entry *entry)
1444{
1445 if (!chip->info->ops->vtu_loadpurge)
1446 return -EOPNOTSUPP;
1447
1448 return chip->info->ops->vtu_loadpurge(chip, entry);
1449}
1450
Vivien Didelotd7f435f2017-03-11 16:12:56 -05001451static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid)
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001452{
1453 DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
Vivien Didelot425d2d32019-08-01 14:36:34 -04001454 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001455 int i, err;
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001456
1457 bitmap_zero(fid_bitmap, MV88E6XXX_N_FID);
1458
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001459 /* Set every FID bit used by the (un)bridged ports */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001460 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotb4e48c52016-11-04 03:23:29 +01001461 err = mv88e6xxx_port_get_fid(chip, i, fid);
Vivien Didelot2db9ce12016-02-26 13:16:04 -05001462 if (err)
1463 return err;
1464
1465 set_bit(*fid, fid_bitmap);
1466 }
1467
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001468 /* Set every FID bit used by the VLAN entries */
Vivien Didelot425d2d32019-08-01 14:36:34 -04001469 vlan.vid = chip->info->max_vid;
1470 vlan.valid = false;
1471
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001472 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001473 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001474 if (err)
1475 return err;
1476
1477 if (!vlan.valid)
1478 break;
1479
1480 set_bit(vlan.fid, fid_bitmap);
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001481 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001482
1483 /* The reset value 0x000 is used to indicate that multiple address
1484 * databases are not needed. Return the next positive available.
1485 */
1486 *fid = find_next_zero_bit(fid_bitmap, MV88E6XXX_N_FID, 1);
Vivien Didelotfad09c72016-06-21 12:28:20 -04001487 if (unlikely(*fid >= mv88e6xxx_num_databases(chip)))
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001488 return -ENOSPC;
1489
1490 /* Clear the database */
Vivien Didelotdaefc942017-03-11 16:12:54 -05001491 return mv88e6xxx_g1_atu_flush(chip, *fid, true);
Vivien Didelot3285f9e2016-02-26 13:16:03 -05001492}
1493
Andrew Lunn23e8b472019-10-25 01:03:52 +02001494static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
1495{
1496 if (chip->info->ops->atu_get_hash)
1497 return chip->info->ops->atu_get_hash(chip, hash);
1498
1499 return -EOPNOTSUPP;
1500}
1501
1502static int mv88e6xxx_atu_set_hash(struct mv88e6xxx_chip *chip, u8 hash)
1503{
1504 if (chip->info->ops->atu_set_hash)
1505 return chip->info->ops->atu_set_hash(chip, hash);
1506
1507 return -EOPNOTSUPP;
1508}
1509
Vivien Didelotda9c3592016-02-12 12:09:40 -05001510static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
1511 u16 vid_begin, u16 vid_end)
1512{
Vivien Didelot04bed142016-08-31 18:06:13 -04001513 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot425d2d32019-08-01 14:36:34 -04001514 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001515 int i, err;
1516
Andrew Lunndb06ae412017-09-25 23:32:20 +02001517 /* DSA and CPU ports have to be members of multiple vlans */
1518 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
1519 return 0;
1520
Vivien Didelotda9c3592016-02-12 12:09:40 -05001521 if (!vid_begin)
1522 return -EOPNOTSUPP;
1523
Vivien Didelot425d2d32019-08-01 14:36:34 -04001524 vlan.vid = vid_begin - 1;
1525 vlan.valid = false;
1526
Vivien Didelotda9c3592016-02-12 12:09:40 -05001527 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04001528 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001529 if (err)
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001530 return err;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001531
1532 if (!vlan.valid)
1533 break;
1534
1535 if (vlan.vid > vid_end)
1536 break;
1537
Vivien Didelot370b4ff2016-09-29 12:21:57 -04001538 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelotda9c3592016-02-12 12:09:40 -05001539 if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
1540 continue;
1541
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001542 if (!dsa_to_port(ds, i)->slave)
Andrew Lunn66e28092016-12-11 21:07:19 +01001543 continue;
1544
Vivien Didelotbd00e052017-05-01 14:05:11 -04001545 if (vlan.member[i] ==
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001546 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001547 continue;
1548
Vivien Didelotc8652c82017-10-16 11:12:19 -04001549 if (dsa_to_port(ds, i)->bridge_dev ==
Vivien Didelot68bb8ea2019-10-21 16:51:15 -04001550 dsa_to_port(ds, port)->bridge_dev)
Vivien Didelotda9c3592016-02-12 12:09:40 -05001551 break; /* same bridge, check next VLAN */
1552
Vivien Didelotc8652c82017-10-16 11:12:19 -04001553 if (!dsa_to_port(ds, i)->bridge_dev)
Andrew Lunn66e28092016-12-11 21:07:19 +01001554 continue;
1555
Andrew Lunn743fcc22017-11-09 22:29:54 +01001556 dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
1557 port, vlan.vid, i,
Vivien Didelotc8652c82017-10-16 11:12:19 -04001558 netdev_name(dsa_to_port(ds, i)->bridge_dev));
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001559 return -EOPNOTSUPP;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001560 }
1561 } while (vlan.vid < vid_end);
1562
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001563 return 0;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001564}
1565
Vivien Didelotf81ec902016-05-09 13:22:58 -04001566static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port,
1567 bool vlan_filtering)
Vivien Didelot214cdb92016-02-26 13:16:08 -05001568{
Vivien Didelot04bed142016-08-31 18:06:13 -04001569 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot81c6edb2017-06-12 12:37:41 -04001570 u16 mode = vlan_filtering ? MV88E6XXX_PORT_CTL2_8021Q_MODE_SECURE :
1571 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001572 int err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001573
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001574 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001575 return -EOPNOTSUPP;
1576
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001577 mv88e6xxx_reg_lock(chip);
Vivien Didelot385a0992016-11-04 03:23:31 +01001578 err = mv88e6xxx_port_set_8021q_mode(chip, port, mode);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001579 mv88e6xxx_reg_unlock(chip);
Vivien Didelot214cdb92016-02-26 13:16:08 -05001580
Andrew Lunn0e7b9922016-09-21 01:40:31 +02001581 return err;
Vivien Didelot214cdb92016-02-26 13:16:08 -05001582}
1583
Vivien Didelot57d32312016-06-20 13:13:58 -04001584static int
1585mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001586 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001587{
Vivien Didelot04bed142016-08-31 18:06:13 -04001588 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotda9c3592016-02-12 12:09:40 -05001589 int err;
1590
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001591 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001592 return -EOPNOTSUPP;
1593
Vivien Didelotda9c3592016-02-12 12:09:40 -05001594 /* If the requested port doesn't belong to the same bridge as the VLAN
1595 * members, do not support it (yet) and fallback to software VLAN.
1596 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001597 mv88e6xxx_reg_lock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001598 err = mv88e6xxx_port_check_hw_vlan(ds, port, vlan->vid_begin,
1599 vlan->vid_end);
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001600 mv88e6xxx_reg_unlock(chip);
Vivien Didelotda9c3592016-02-12 12:09:40 -05001601
Vivien Didelot76e398a2015-11-01 12:33:55 -05001602 /* We don't need any dynamic resource from the kernel (yet),
1603 * so skip the prepare phase.
1604 */
Vivien Didelot7095a4c2019-08-01 14:36:33 -04001605 return err;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001606}
1607
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001608static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port,
1609 const unsigned char *addr, u16 vid,
1610 u8 state)
1611{
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001612 struct mv88e6xxx_atu_entry entry;
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001613 struct mv88e6xxx_vtu_entry vlan;
1614 u16 fid;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001615 int err;
1616
1617 /* Null VLAN ID corresponds to the port private database */
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001618 if (vid == 0) {
1619 err = mv88e6xxx_port_get_fid(chip, port, &fid);
1620 if (err)
1621 return err;
1622 } else {
1623 vlan.vid = vid - 1;
1624 vlan.valid = false;
1625
1626 err = mv88e6xxx_vtu_getnext(chip, &vlan);
1627 if (err)
1628 return err;
1629
1630 /* switchdev expects -EOPNOTSUPP to honor software VLANs */
1631 if (vlan.vid != vid || !vlan.valid)
1632 return -EOPNOTSUPP;
1633
1634 fid = vlan.fid;
1635 }
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001636
Vivien Didelotd8291a92019-09-07 16:00:47 -04001637 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001638 ether_addr_copy(entry.mac, addr);
1639 eth_addr_dec(entry.mac);
1640
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001641 err = mv88e6xxx_g1_atu_getnext(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001642 if (err)
1643 return err;
1644
1645 /* Initialize a fresh ATU entry if it isn't found */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001646 if (!entry.state || !ether_addr_equal(entry.mac, addr)) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001647 memset(&entry, 0, sizeof(entry));
1648 ether_addr_copy(entry.mac, addr);
1649 }
1650
1651 /* Purge the ATU entry only if no port is using it anymore */
Vivien Didelotd8291a92019-09-07 16:00:47 -04001652 if (!state) {
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001653 entry.portvec &= ~BIT(port);
1654 if (!entry.portvec)
Vivien Didelotd8291a92019-09-07 16:00:47 -04001655 entry.state = 0;
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001656 } else {
1657 entry.portvec |= BIT(port);
1658 entry.state = state;
1659 }
1660
Vivien Didelot5ef8d242019-08-01 14:36:35 -04001661 return mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
Andrew Lunna4c93ae2017-11-09 22:29:55 +01001662}
1663
Vivien Didelotda7dc872019-09-07 16:00:49 -04001664static int mv88e6xxx_policy_apply(struct mv88e6xxx_chip *chip, int port,
1665 const struct mv88e6xxx_policy *policy)
1666{
1667 enum mv88e6xxx_policy_mapping mapping = policy->mapping;
1668 enum mv88e6xxx_policy_action action = policy->action;
1669 const u8 *addr = policy->addr;
1670 u16 vid = policy->vid;
1671 u8 state;
1672 int err;
1673 int id;
1674
1675 if (!chip->info->ops->port_set_policy)
1676 return -EOPNOTSUPP;
1677
1678 switch (mapping) {
1679 case MV88E6XXX_POLICY_MAPPING_DA:
1680 case MV88E6XXX_POLICY_MAPPING_SA:
1681 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1682 state = 0; /* Dissociate the port and address */
1683 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1684 is_multicast_ether_addr(addr))
1685 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC_POLICY;
1686 else if (action == MV88E6XXX_POLICY_ACTION_DISCARD &&
1687 is_unicast_ether_addr(addr))
1688 state = MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC_POLICY;
1689 else
1690 return -EOPNOTSUPP;
1691
1692 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
1693 state);
1694 if (err)
1695 return err;
1696 break;
1697 default:
1698 return -EOPNOTSUPP;
1699 }
1700
1701 /* Skip the port's policy clearing if the mapping is still in use */
1702 if (action == MV88E6XXX_POLICY_ACTION_NORMAL)
1703 idr_for_each_entry(&chip->policies, policy, id)
1704 if (policy->port == port &&
1705 policy->mapping == mapping &&
1706 policy->action != action)
1707 return 0;
1708
1709 return chip->info->ops->port_set_policy(chip, port, mapping, action);
1710}
1711
1712static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
1713 struct ethtool_rx_flow_spec *fs)
1714{
1715 struct ethhdr *mac_entry = &fs->h_u.ether_spec;
1716 struct ethhdr *mac_mask = &fs->m_u.ether_spec;
1717 enum mv88e6xxx_policy_mapping mapping;
1718 enum mv88e6xxx_policy_action action;
1719 struct mv88e6xxx_policy *policy;
1720 u16 vid = 0;
1721 u8 *addr;
1722 int err;
1723 int id;
1724
1725 if (fs->location != RX_CLS_LOC_ANY)
1726 return -EINVAL;
1727
1728 if (fs->ring_cookie == RX_CLS_FLOW_DISC)
1729 action = MV88E6XXX_POLICY_ACTION_DISCARD;
1730 else
1731 return -EOPNOTSUPP;
1732
1733 switch (fs->flow_type & ~FLOW_EXT) {
1734 case ETHER_FLOW:
1735 if (!is_zero_ether_addr(mac_mask->h_dest) &&
1736 is_zero_ether_addr(mac_mask->h_source)) {
1737 mapping = MV88E6XXX_POLICY_MAPPING_DA;
1738 addr = mac_entry->h_dest;
1739 } else if (is_zero_ether_addr(mac_mask->h_dest) &&
1740 !is_zero_ether_addr(mac_mask->h_source)) {
1741 mapping = MV88E6XXX_POLICY_MAPPING_SA;
1742 addr = mac_entry->h_source;
1743 } else {
1744 /* Cannot support DA and SA mapping in the same rule */
1745 return -EOPNOTSUPP;
1746 }
1747 break;
1748 default:
1749 return -EOPNOTSUPP;
1750 }
1751
1752 if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
1753 if (fs->m_ext.vlan_tci != 0xffff)
1754 return -EOPNOTSUPP;
1755 vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
1756 }
1757
1758 idr_for_each_entry(&chip->policies, policy, id) {
1759 if (policy->port == port && policy->mapping == mapping &&
1760 policy->action == action && policy->vid == vid &&
1761 ether_addr_equal(policy->addr, addr))
1762 return -EEXIST;
1763 }
1764
1765 policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
1766 if (!policy)
1767 return -ENOMEM;
1768
1769 fs->location = 0;
1770 err = idr_alloc_u32(&chip->policies, policy, &fs->location, 0xffffffff,
1771 GFP_KERNEL);
1772 if (err) {
1773 devm_kfree(chip->dev, policy);
1774 return err;
1775 }
1776
1777 memcpy(&policy->fs, fs, sizeof(*fs));
1778 ether_addr_copy(policy->addr, addr);
1779 policy->mapping = mapping;
1780 policy->action = action;
1781 policy->port = port;
1782 policy->vid = vid;
1783
1784 err = mv88e6xxx_policy_apply(chip, port, policy);
1785 if (err) {
1786 idr_remove(&chip->policies, fs->location);
1787 devm_kfree(chip->dev, policy);
1788 return err;
1789 }
1790
1791 return 0;
1792}
1793
1794static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
1795 struct ethtool_rxnfc *rxnfc, u32 *rule_locs)
1796{
1797 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1798 struct mv88e6xxx_chip *chip = ds->priv;
1799 struct mv88e6xxx_policy *policy;
1800 int err;
1801 int id;
1802
1803 mv88e6xxx_reg_lock(chip);
1804
1805 switch (rxnfc->cmd) {
1806 case ETHTOOL_GRXCLSRLCNT:
1807 rxnfc->data = 0;
1808 rxnfc->data |= RX_CLS_LOC_SPECIAL;
1809 rxnfc->rule_cnt = 0;
1810 idr_for_each_entry(&chip->policies, policy, id)
1811 if (policy->port == port)
1812 rxnfc->rule_cnt++;
1813 err = 0;
1814 break;
1815 case ETHTOOL_GRXCLSRULE:
1816 err = -ENOENT;
1817 policy = idr_find(&chip->policies, fs->location);
1818 if (policy) {
1819 memcpy(fs, &policy->fs, sizeof(*fs));
1820 err = 0;
1821 }
1822 break;
1823 case ETHTOOL_GRXCLSRLALL:
1824 rxnfc->data = 0;
1825 rxnfc->rule_cnt = 0;
1826 idr_for_each_entry(&chip->policies, policy, id)
1827 if (policy->port == port)
1828 rule_locs[rxnfc->rule_cnt++] = id;
1829 err = 0;
1830 break;
1831 default:
1832 err = -EOPNOTSUPP;
1833 break;
1834 }
1835
1836 mv88e6xxx_reg_unlock(chip);
1837
1838 return err;
1839}
1840
1841static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port,
1842 struct ethtool_rxnfc *rxnfc)
1843{
1844 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
1845 struct mv88e6xxx_chip *chip = ds->priv;
1846 struct mv88e6xxx_policy *policy;
1847 int err;
1848
1849 mv88e6xxx_reg_lock(chip);
1850
1851 switch (rxnfc->cmd) {
1852 case ETHTOOL_SRXCLSRLINS:
1853 err = mv88e6xxx_policy_insert(chip, port, fs);
1854 break;
1855 case ETHTOOL_SRXCLSRLDEL:
1856 err = -ENOENT;
1857 policy = idr_remove(&chip->policies, fs->location);
1858 if (policy) {
1859 policy->action = MV88E6XXX_POLICY_ACTION_NORMAL;
1860 err = mv88e6xxx_policy_apply(chip, port, policy);
1861 devm_kfree(chip->dev, policy);
1862 }
1863 break;
1864 default:
1865 err = -EOPNOTSUPP;
1866 break;
1867 }
1868
1869 mv88e6xxx_reg_unlock(chip);
1870
1871 return err;
1872}
1873
Andrew Lunn87fa8862017-11-09 22:29:56 +01001874static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port,
1875 u16 vid)
1876{
1877 const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1878 u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC;
1879
1880 return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state);
1881}
1882
1883static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid)
1884{
1885 int port;
1886 int err;
1887
1888 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
1889 err = mv88e6xxx_port_add_broadcast(chip, port, vid);
1890 if (err)
1891 return err;
1892 }
1893
1894 return 0;
1895}
1896
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001897static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port,
Russell King933b4422020-02-26 17:14:26 +00001898 u16 vid, u8 member, bool warn)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001899{
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001900 const u8 non_member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001901 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001902 int i, err;
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001903
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001904 if (!vid)
1905 return -EOPNOTSUPP;
1906
1907 vlan.vid = vid - 1;
1908 vlan.valid = false;
1909
1910 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001911 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001912 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04001913
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001914 if (vlan.vid != vid || !vlan.valid) {
1915 memset(&vlan, 0, sizeof(vlan));
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001916
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001917 err = mv88e6xxx_atu_new(chip, &vlan.fid);
1918 if (err)
1919 return err;
Andrew Lunn87fa8862017-11-09 22:29:56 +01001920
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001921 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i)
1922 if (i == port)
1923 vlan.member[i] = member;
1924 else
1925 vlan.member[i] = non_member;
1926
1927 vlan.vid = vid;
1928 vlan.valid = true;
1929
1930 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1931 if (err)
1932 return err;
1933
1934 err = mv88e6xxx_broadcast_setup(chip, vlan.vid);
1935 if (err)
1936 return err;
1937 } else if (vlan.member[port] != member) {
1938 vlan.member[port] = member;
1939
1940 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
1941 if (err)
1942 return err;
Russell King933b4422020-02-26 17:14:26 +00001943 } else if (warn) {
Vivien Didelotb1ac6fb2019-08-01 14:36:37 -04001944 dev_info(chip->dev, "p%d: already a member of VLAN %d\n",
1945 port, vid);
1946 }
1947
1948 return 0;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001949}
1950
Vivien Didelotf81ec902016-05-09 13:22:58 -04001951static void mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port,
Vivien Didelot80e02362017-11-30 11:23:57 -05001952 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05001953{
Vivien Didelot04bed142016-08-31 18:06:13 -04001954 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001955 bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
1956 bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
Russell King933b4422020-02-26 17:14:26 +00001957 bool warn;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001958 u8 member;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001959 u16 vid;
Vivien Didelot76e398a2015-11-01 12:33:55 -05001960
Vivien Didelot3cf3c842017-05-01 14:05:10 -04001961 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04001962 return;
1963
Vivien Didelotc91498e2017-06-07 18:12:13 -04001964 if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001965 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNMODIFIED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001966 else if (untagged)
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001967 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_UNTAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001968 else
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04001969 member = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_TAGGED;
Vivien Didelotc91498e2017-06-07 18:12:13 -04001970
Russell King933b4422020-02-26 17:14:26 +00001971 /* net/dsa/slave.c will call dsa_port_vlan_add() for the affected port
1972 * and then the CPU port. Do not warn for duplicates for the CPU port.
1973 */
1974 warn = !dsa_is_cpu_port(ds, port) && !dsa_is_dsa_port(ds, port);
1975
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001976 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05001977
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001978 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid)
Russell King933b4422020-02-26 17:14:26 +00001979 if (mv88e6xxx_port_vlan_join(chip, port, vid, member, warn))
Vivien Didelot774439e52017-06-08 18:34:08 -04001980 dev_err(ds->dev, "p%d: failed to add VLAN %d%c\n", port,
1981 vid, untagged ? 'u' : 't');
Vivien Didelot76e398a2015-11-01 12:33:55 -05001982
Vivien Didelot77064f32016-11-04 03:23:30 +01001983 if (pvid && mv88e6xxx_port_set_pvid(chip, port, vlan->vid_end))
Vivien Didelot774439e52017-06-08 18:34:08 -04001984 dev_err(ds->dev, "p%d: failed to set PVID %d\n", port,
1985 vlan->vid_end);
Vivien Didelot4d5770b2016-04-06 11:55:05 -04001986
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00001987 mv88e6xxx_reg_unlock(chip);
Vivien Didelot0d3b33e2015-08-13 12:52:22 -04001988}
1989
Vivien Didelot521098922019-08-01 14:36:36 -04001990static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip,
1991 int port, u16 vid)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001992{
Vivien Didelotb4e47c02016-09-29 12:21:58 -04001993 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04001994 int i, err;
1995
Vivien Didelot521098922019-08-01 14:36:36 -04001996 if (!vid)
1997 return -EOPNOTSUPP;
1998
1999 vlan.vid = vid - 1;
2000 vlan.valid = false;
2001
2002 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002003 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002004 return err;
Vivien Didelot36d04ba2015-10-22 09:34:39 -04002005
Vivien Didelot521098922019-08-01 14:36:36 -04002006 /* If the VLAN doesn't exist in hardware or the port isn't a member,
2007 * tell switchdev that this VLAN is likely handled in software.
2008 */
2009 if (vlan.vid != vid || !vlan.valid ||
2010 vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
Vivien Didelot3c06f082016-02-05 14:04:39 -05002011 return -EOPNOTSUPP;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002012
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002013 vlan.member[port] = MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002014
2015 /* keep the VLAN unless all ports are excluded */
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002016 vlan.valid = false;
Vivien Didelot370b4ff2016-09-29 12:21:57 -04002017 for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) {
Vivien Didelot7ec60d6e2017-06-15 12:14:02 -04002018 if (vlan.member[i] !=
2019 MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) {
Vivien Didelotf02bdff2015-10-11 18:08:36 -04002020 vlan.valid = true;
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002021 break;
2022 }
2023 }
2024
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04002025 err = mv88e6xxx_vtu_loadpurge(chip, &vlan);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002026 if (err)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002027 return err;
2028
Vivien Didelote606ca32017-03-11 16:12:55 -05002029 return mv88e6xxx_g1_atu_remove(chip, vlan.fid, port, false);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002030}
2031
Vivien Didelotf81ec902016-05-09 13:22:58 -04002032static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
2033 const struct switchdev_obj_port_vlan *vlan)
Vivien Didelot76e398a2015-11-01 12:33:55 -05002034{
Vivien Didelot04bed142016-08-31 18:06:13 -04002035 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot76e398a2015-11-01 12:33:55 -05002036 u16 pvid, vid;
2037 int err = 0;
2038
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002039 if (!chip->info->max_vid)
Vivien Didelot54d77b52016-05-09 13:22:47 -04002040 return -EOPNOTSUPP;
2041
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002042 mv88e6xxx_reg_lock(chip);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002043
Vivien Didelot77064f32016-11-04 03:23:30 +01002044 err = mv88e6xxx_port_get_pvid(chip, port, &pvid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002045 if (err)
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002046 goto unlock;
2047
Vivien Didelot76e398a2015-11-01 12:33:55 -05002048 for (vid = vlan->vid_begin; vid <= vlan->vid_end; ++vid) {
Vivien Didelot521098922019-08-01 14:36:36 -04002049 err = mv88e6xxx_port_vlan_leave(chip, port, vid);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002050 if (err)
2051 goto unlock;
2052
2053 if (vid == pvid) {
Vivien Didelot77064f32016-11-04 03:23:30 +01002054 err = mv88e6xxx_port_set_pvid(chip, port, 0);
Vivien Didelot76e398a2015-11-01 12:33:55 -05002055 if (err)
2056 goto unlock;
2057 }
2058 }
2059
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002060unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002061 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7dad08d2015-08-13 12:52:21 -04002062
2063 return err;
2064}
2065
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002066static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
2067 const unsigned char *addr, u16 vid)
Guenter Roeckdefb05b2015-03-26 18:36:38 -07002068{
Vivien Didelot04bed142016-08-31 18:06:13 -04002069 struct mv88e6xxx_chip *chip = ds->priv;
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002070 int err;
Vivien Didelot6630e232015-08-06 01:44:07 -04002071
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002072 mv88e6xxx_reg_lock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002073 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid,
2074 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002075 mv88e6xxx_reg_unlock(chip);
Arkadi Sharshevsky1b6dd552017-08-06 16:15:40 +03002076
2077 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002078}
2079
Vivien Didelotf81ec902016-05-09 13:22:58 -04002080static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
Arkadi Sharshevsky6c2c1dc2017-08-06 16:15:39 +03002081 const unsigned char *addr, u16 vid)
David S. Millercdf09692015-08-11 12:00:37 -07002082{
Vivien Didelot04bed142016-08-31 18:06:13 -04002083 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002084 int err;
David S. Millercdf09692015-08-11 12:00:37 -07002085
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002086 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04002087 err = mv88e6xxx_port_db_load_purge(chip, port, addr, vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002088 mv88e6xxx_reg_unlock(chip);
David S. Millercdf09692015-08-11 12:00:37 -07002089
Vivien Didelot83dabd12016-08-31 11:50:04 -04002090 return err;
David S. Millercdf09692015-08-11 12:00:37 -07002091}
2092
Vivien Didelot83dabd12016-08-31 11:50:04 -04002093static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
2094 u16 fid, u16 vid, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002095 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002096{
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002097 struct mv88e6xxx_atu_entry addr;
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002098 bool is_static;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002099 int err;
2100
Vivien Didelotd8291a92019-09-07 16:00:47 -04002101 addr.state = 0;
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002102 eth_broadcast_addr(addr.mac);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002103
2104 do {
Vivien Didelotdabc1a92017-03-11 16:12:53 -05002105 err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002106 if (err)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002107 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002108
Vivien Didelotd8291a92019-09-07 16:00:47 -04002109 if (!addr.state)
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002110 break;
2111
Vivien Didelot01bd96c2017-03-11 16:12:57 -05002112 if (addr.trunk || (addr.portvec & BIT(port)) == 0)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002113 continue;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002114
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002115 if (!is_unicast_ether_addr(addr.mac))
2116 continue;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002117
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002118 is_static = (addr.state ==
2119 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
2120 err = cb(addr.mac, vid, is_static, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002121 if (err)
2122 return err;
Vivien Didelot74b6ba02016-02-26 13:16:02 -05002123 } while (!is_broadcast_ether_addr(addr.mac));
2124
2125 return err;
2126}
2127
Vivien Didelot83dabd12016-08-31 11:50:04 -04002128static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002129 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelot83dabd12016-08-31 11:50:04 -04002130{
Vivien Didelot425d2d32019-08-01 14:36:34 -04002131 struct mv88e6xxx_vtu_entry vlan;
Vivien Didelot83dabd12016-08-31 11:50:04 -04002132 u16 fid;
2133 int err;
2134
2135 /* Dump port's default Filtering Information Database (VLAN ID 0) */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002136 err = mv88e6xxx_port_get_fid(chip, port, &fid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002137 if (err)
2138 return err;
2139
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002140 err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002141 if (err)
2142 return err;
2143
2144 /* Dump VLANs' Filtering Information Databases */
Vivien Didelot425d2d32019-08-01 14:36:34 -04002145 vlan.vid = chip->info->max_vid;
2146 vlan.valid = false;
2147
Vivien Didelot83dabd12016-08-31 11:50:04 -04002148 do {
Vivien Didelotf1394b782017-05-01 14:05:22 -04002149 err = mv88e6xxx_vtu_getnext(chip, &vlan);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002150 if (err)
2151 return err;
2152
2153 if (!vlan.valid)
2154 break;
2155
2156 err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002157 cb, data);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002158 if (err)
2159 return err;
Vivien Didelot3cf3c842017-05-01 14:05:10 -04002160 } while (vlan.vid < chip->info->max_vid);
Vivien Didelot83dabd12016-08-31 11:50:04 -04002161
2162 return err;
2163}
2164
Vivien Didelotf81ec902016-05-09 13:22:58 -04002165static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
Arkadi Sharshevsky2bedde12017-08-06 16:15:49 +03002166 dsa_fdb_dump_cb_t *cb, void *data)
Vivien Didelotf33475b2015-10-22 09:34:41 -04002167{
Vivien Didelot04bed142016-08-31 18:06:13 -04002168 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelotfcf15362019-06-12 12:42:47 -04002169 int err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002170
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002171 mv88e6xxx_reg_lock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002172 err = mv88e6xxx_port_db_dump(chip, port, cb, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002173 mv88e6xxx_reg_unlock(chip);
Vivien Didelotfcf15362019-06-12 12:42:47 -04002174
2175 return err;
Vivien Didelotf33475b2015-10-22 09:34:41 -04002176}
2177
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002178static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
2179 struct net_device *br)
2180{
Vivien Didelotef2025e2019-10-21 16:51:27 -04002181 struct dsa_switch *ds = chip->ds;
2182 struct dsa_switch_tree *dst = ds->dst;
2183 struct dsa_port *dp;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002184 int err;
2185
Vivien Didelotef2025e2019-10-21 16:51:27 -04002186 list_for_each_entry(dp, &dst->ports, list) {
2187 if (dp->bridge_dev == br) {
2188 if (dp->ds == ds) {
2189 /* This is a local bridge group member,
2190 * remap its Port VLAN Map.
2191 */
2192 err = mv88e6xxx_port_vlan_map(chip, dp->index);
2193 if (err)
2194 return err;
2195 } else {
2196 /* This is an external bridge group member,
2197 * remap its cross-chip Port VLAN Table entry.
2198 */
2199 err = mv88e6xxx_pvt_map(chip, dp->ds->index,
2200 dp->index);
Vivien Didelote96a6e02017-03-30 17:37:13 -04002201 if (err)
2202 return err;
2203 }
2204 }
2205 }
2206
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002207 return 0;
2208}
2209
Vivien Didelotf81ec902016-05-09 13:22:58 -04002210static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
Vivien Didelotfae8a252017-01-27 15:29:42 -05002211 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002212{
Vivien Didelot04bed142016-08-31 18:06:13 -04002213 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002214 int err;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002215
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002216 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002217 err = mv88e6xxx_bridge_map(chip, br);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002218 mv88e6xxx_reg_unlock(chip);
Vivien Didelota6692752016-02-12 12:09:39 -05002219
Vivien Didelot466dfa02016-02-26 13:16:05 -05002220 return err;
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002221}
2222
Vivien Didelotf123f2f2017-01-27 15:29:41 -05002223static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port,
2224 struct net_device *br)
Vivien Didelote79a8bc2015-11-04 17:23:40 -05002225{
Vivien Didelot04bed142016-08-31 18:06:13 -04002226 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot466dfa02016-02-26 13:16:05 -05002227
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002228 mv88e6xxx_reg_lock(chip);
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002229 if (mv88e6xxx_bridge_map(chip, br) ||
2230 mv88e6xxx_port_vlan_map(chip, port))
2231 dev_err(ds->dev, "failed to remap in-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002232 mv88e6xxx_reg_unlock(chip);
Vivien Didelot66d9cd02016-02-05 14:07:14 -05002233}
2234
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002235static int mv88e6xxx_crosschip_bridge_join(struct dsa_switch *ds, int dev,
2236 int port, struct net_device *br)
2237{
2238 struct mv88e6xxx_chip *chip = ds->priv;
2239 int err;
2240
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002241 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002242 err = mv88e6xxx_pvt_map(chip, dev, port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002243 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002244
2245 return err;
2246}
2247
2248static void mv88e6xxx_crosschip_bridge_leave(struct dsa_switch *ds, int dev,
2249 int port, struct net_device *br)
2250{
2251 struct mv88e6xxx_chip *chip = ds->priv;
2252
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002253 mv88e6xxx_reg_lock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002254 if (mv88e6xxx_pvt_map(chip, dev, port))
2255 dev_err(ds->dev, "failed to remap cross-chip Port VLAN\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002256 mv88e6xxx_reg_unlock(chip);
Vivien Didelotaec5ac82017-03-30 17:37:15 -04002257}
2258
Vivien Didelot17e708b2016-12-05 17:30:27 -05002259static int mv88e6xxx_software_reset(struct mv88e6xxx_chip *chip)
2260{
2261 if (chip->info->ops->reset)
2262 return chip->info->ops->reset(chip);
2263
2264 return 0;
2265}
2266
Vivien Didelot309eca62016-12-05 17:30:26 -05002267static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)
2268{
2269 struct gpio_desc *gpiod = chip->reset;
2270
2271 /* If there is a GPIO connected to the reset pin, toggle it */
2272 if (gpiod) {
2273 gpiod_set_value_cansleep(gpiod, 1);
2274 usleep_range(10000, 20000);
2275 gpiod_set_value_cansleep(gpiod, 0);
2276 usleep_range(10000, 20000);
2277 }
2278}
2279
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002280static int mv88e6xxx_disable_ports(struct mv88e6xxx_chip *chip)
2281{
2282 int i, err;
2283
2284 /* Set all ports to the Disabled state */
2285 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotf894c292017-06-08 18:34:10 -04002286 err = mv88e6xxx_port_set_state(chip, i, BR_STATE_DISABLED);
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002287 if (err)
2288 return err;
2289 }
2290
2291 /* Wait for transmit queues to drain,
2292 * i.e. 2ms for a maximum frame to be transmitted at 10 Mbps.
2293 */
2294 usleep_range(2000, 4000);
2295
2296 return 0;
2297}
2298
Vivien Didelotfad09c72016-06-21 12:28:20 -04002299static int mv88e6xxx_switch_reset(struct mv88e6xxx_chip *chip)
Vivien Didelot552238b2016-05-09 13:22:49 -04002300{
Vivien Didelota935c052016-09-29 12:21:53 -04002301 int err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002302
Vivien Didelot4ac4b5a2016-12-05 17:30:25 -05002303 err = mv88e6xxx_disable_ports(chip);
2304 if (err)
2305 return err;
Vivien Didelot552238b2016-05-09 13:22:49 -04002306
Vivien Didelot309eca62016-12-05 17:30:26 -05002307 mv88e6xxx_hardware_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002308
Vivien Didelot17e708b2016-12-05 17:30:27 -05002309 return mv88e6xxx_software_reset(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04002310}
2311
Vivien Didelot43145572017-03-11 16:12:59 -05002312static int mv88e6xxx_set_port_mode(struct mv88e6xxx_chip *chip, int port,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002313 enum mv88e6xxx_frame_mode frame,
2314 enum mv88e6xxx_egress_mode egress, u16 etype)
Andrew Lunn56995cb2016-12-03 04:35:19 +01002315{
2316 int err;
2317
Vivien Didelot43145572017-03-11 16:12:59 -05002318 if (!chip->info->ops->port_set_frame_mode)
2319 return -EOPNOTSUPP;
2320
2321 err = mv88e6xxx_port_set_egress_mode(chip, port, egress);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002322 if (err)
2323 return err;
2324
Vivien Didelot43145572017-03-11 16:12:59 -05002325 err = chip->info->ops->port_set_frame_mode(chip, port, frame);
2326 if (err)
2327 return err;
2328
2329 if (chip->info->ops->port_set_ether_type)
2330 return chip->info->ops->port_set_ether_type(chip, port, etype);
2331
2332 return 0;
2333}
2334
2335static int mv88e6xxx_set_port_mode_normal(struct mv88e6xxx_chip *chip, int port)
2336{
2337 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_NORMAL,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002338 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002339 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002340}
2341
2342static int mv88e6xxx_set_port_mode_dsa(struct mv88e6xxx_chip *chip, int port)
2343{
2344 return mv88e6xxx_set_port_mode(chip, port, MV88E6XXX_FRAME_MODE_DSA,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002345 MV88E6XXX_EGRESS_MODE_UNMODIFIED,
Vivien Didelotb8109592017-06-12 12:37:45 -04002346 MV88E6XXX_PORT_ETH_TYPE_DEFAULT);
Vivien Didelot43145572017-03-11 16:12:59 -05002347}
2348
2349static int mv88e6xxx_set_port_mode_edsa(struct mv88e6xxx_chip *chip, int port)
2350{
2351 return mv88e6xxx_set_port_mode(chip, port,
2352 MV88E6XXX_FRAME_MODE_ETHERTYPE,
Vivien Didelot31bef4e2017-06-08 18:34:09 -04002353 MV88E6XXX_EGRESS_MODE_ETHERTYPE,
2354 ETH_P_EDSA);
Vivien Didelot43145572017-03-11 16:12:59 -05002355}
2356
2357static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)
2358{
2359 if (dsa_is_dsa_port(chip->ds, port))
2360 return mv88e6xxx_set_port_mode_dsa(chip, port);
2361
Vivien Didelot2b3e9892017-10-26 11:22:54 -04002362 if (dsa_is_user_port(chip->ds, port))
Vivien Didelot43145572017-03-11 16:12:59 -05002363 return mv88e6xxx_set_port_mode_normal(chip, port);
2364
2365 /* Setup CPU port mode depending on its supported tag format */
2366 if (chip->info->tag_protocol == DSA_TAG_PROTO_DSA)
2367 return mv88e6xxx_set_port_mode_dsa(chip, port);
2368
2369 if (chip->info->tag_protocol == DSA_TAG_PROTO_EDSA)
2370 return mv88e6xxx_set_port_mode_edsa(chip, port);
2371
2372 return -EINVAL;
2373}
2374
Vivien Didelotea698f42017-03-11 16:12:50 -05002375static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port)
2376{
2377 bool message = dsa_is_dsa_port(chip->ds, port);
2378
2379 return mv88e6xxx_port_set_message_port(chip, port, message);
2380}
2381
Vivien Didelot601aeed2017-03-11 16:13:00 -05002382static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port)
2383{
Vivien Didelot3ee50cb2017-12-05 15:34:09 -05002384 struct dsa_switch *ds = chip->ds;
David S. Miller407308f2019-06-15 13:35:29 -07002385 bool flood;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002386
David S. Miller407308f2019-06-15 13:35:29 -07002387 /* Upstream ports flood frames with unknown unicast or multicast DA */
2388 flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port);
2389 if (chip->info->ops->port_set_egress_floods)
2390 return chip->info->ops->port_set_egress_floods(chip, port,
2391 flood, flood);
Vivien Didelot601aeed2017-03-11 16:13:00 -05002392
David S. Miller407308f2019-06-15 13:35:29 -07002393 return 0;
Vivien Didelot601aeed2017-03-11 16:13:00 -05002394}
2395
Vivien Didelot45de77f2019-08-31 16:18:36 -04002396static irqreturn_t mv88e6xxx_serdes_irq_thread_fn(int irq, void *dev_id)
2397{
2398 struct mv88e6xxx_port *mvp = dev_id;
2399 struct mv88e6xxx_chip *chip = mvp->chip;
2400 irqreturn_t ret = IRQ_NONE;
2401 int port = mvp->port;
2402 u8 lane;
2403
2404 mv88e6xxx_reg_lock(chip);
2405 lane = mv88e6xxx_serdes_get_lane(chip, port);
2406 if (lane)
2407 ret = mv88e6xxx_serdes_irq_status(chip, port, lane);
2408 mv88e6xxx_reg_unlock(chip);
2409
2410 return ret;
2411}
2412
2413static int mv88e6xxx_serdes_irq_request(struct mv88e6xxx_chip *chip, int port,
2414 u8 lane)
2415{
2416 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2417 unsigned int irq;
2418 int err;
2419
2420 /* Nothing to request if this SERDES port has no IRQ */
2421 irq = mv88e6xxx_serdes_irq_mapping(chip, port);
2422 if (!irq)
2423 return 0;
2424
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002425 snprintf(dev_id->serdes_irq_name, sizeof(dev_id->serdes_irq_name),
2426 "mv88e6xxx-%s-serdes-%d", dev_name(chip->dev), port);
2427
Vivien Didelot45de77f2019-08-31 16:18:36 -04002428 /* Requesting the IRQ will trigger IRQ callbacks, so release the lock */
2429 mv88e6xxx_reg_unlock(chip);
2430 err = request_threaded_irq(irq, NULL, mv88e6xxx_serdes_irq_thread_fn,
Andrew Lunne6f2f6b2020-01-06 17:13:49 +01002431 IRQF_ONESHOT, dev_id->serdes_irq_name,
2432 dev_id);
Vivien Didelot45de77f2019-08-31 16:18:36 -04002433 mv88e6xxx_reg_lock(chip);
2434 if (err)
2435 return err;
2436
2437 dev_id->serdes_irq = irq;
2438
2439 return mv88e6xxx_serdes_irq_enable(chip, port, lane);
2440}
2441
2442static int mv88e6xxx_serdes_irq_free(struct mv88e6xxx_chip *chip, int port,
2443 u8 lane)
2444{
2445 struct mv88e6xxx_port *dev_id = &chip->ports[port];
2446 unsigned int irq = dev_id->serdes_irq;
2447 int err;
2448
2449 /* Nothing to free if no IRQ has been requested */
2450 if (!irq)
2451 return 0;
2452
2453 err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
2454
2455 /* Freeing the IRQ will trigger IRQ callbacks, so release the lock */
2456 mv88e6xxx_reg_unlock(chip);
2457 free_irq(irq, dev_id);
2458 mv88e6xxx_reg_lock(chip);
2459
2460 dev_id->serdes_irq = 0;
2461
2462 return err;
2463}
2464
Andrew Lunn6d917822017-05-26 01:03:21 +02002465static int mv88e6xxx_serdes_power(struct mv88e6xxx_chip *chip, int port,
2466 bool on)
2467{
Vivien Didelotdc272f62019-08-31 16:18:33 -04002468 u8 lane;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002469 int err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002470
Vivien Didelotdc272f62019-08-31 16:18:33 -04002471 lane = mv88e6xxx_serdes_get_lane(chip, port);
2472 if (!lane)
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002473 return 0;
2474
2475 if (on) {
Vivien Didelotdc272f62019-08-31 16:18:33 -04002476 err = mv88e6xxx_serdes_power_up(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002477 if (err)
2478 return err;
2479
Vivien Didelot45de77f2019-08-31 16:18:36 -04002480 err = mv88e6xxx_serdes_irq_request(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002481 } else {
Vivien Didelot45de77f2019-08-31 16:18:36 -04002482 err = mv88e6xxx_serdes_irq_free(chip, port, lane);
2483 if (err)
2484 return err;
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002485
Vivien Didelotdc272f62019-08-31 16:18:33 -04002486 err = mv88e6xxx_serdes_power_down(chip, port, lane);
Vivien Didelotfc0bc012019-08-19 16:00:53 -04002487 }
2488
2489 return err;
Andrew Lunn6d917822017-05-26 01:03:21 +02002490}
2491
Vivien Didelotfa371c82017-12-05 15:34:10 -05002492static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
2493{
2494 struct dsa_switch *ds = chip->ds;
2495 int upstream_port;
2496 int err;
2497
Vivien Didelot07073c72017-12-05 15:34:13 -05002498 upstream_port = dsa_upstream_port(ds, port);
Vivien Didelotfa371c82017-12-05 15:34:10 -05002499 if (chip->info->ops->port_set_upstream_port) {
2500 err = chip->info->ops->port_set_upstream_port(chip, port,
2501 upstream_port);
2502 if (err)
2503 return err;
2504 }
2505
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002506 if (port == upstream_port) {
2507 if (chip->info->ops->set_cpu_port) {
2508 err = chip->info->ops->set_cpu_port(chip,
2509 upstream_port);
2510 if (err)
2511 return err;
2512 }
2513
2514 if (chip->info->ops->set_egress_port) {
2515 err = chip->info->ops->set_egress_port(chip,
Iwan R Timmer5c74c542019-11-07 22:11:13 +01002516 MV88E6XXX_EGRESS_DIR_INGRESS,
2517 upstream_port);
2518 if (err)
2519 return err;
2520
2521 err = chip->info->ops->set_egress_port(chip,
2522 MV88E6XXX_EGRESS_DIR_EGRESS,
2523 upstream_port);
Vivien Didelot0ea54dd2017-12-05 15:34:11 -05002524 if (err)
2525 return err;
2526 }
2527 }
2528
Vivien Didelotfa371c82017-12-05 15:34:10 -05002529 return 0;
2530}
2531
Vivien Didelotfad09c72016-06-21 12:28:20 -04002532static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
Guenter Roeckd827e882015-03-26 18:36:29 -07002533{
Vivien Didelotfad09c72016-06-21 12:28:20 -04002534 struct dsa_switch *ds = chip->ds;
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002535 int err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002536 u16 reg;
Guenter Roeckd827e882015-03-26 18:36:29 -07002537
Andrew Lunn7b898462018-08-09 15:38:47 +02002538 chip->ports[port].chip = chip;
2539 chip->ports[port].port = port;
2540
Vivien Didelotd78343d2016-11-04 03:23:36 +01002541 /* MAC Forcing register: don't force link, speed, duplex or flow control
2542 * state to any particular values on physical ports, but force the CPU
2543 * port and all DSA ports to their maximum bandwidth and full duplex.
2544 */
2545 if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
2546 err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
2547 SPEED_MAX, DUPLEX_FULL,
Andrew Lunn54186b92018-08-09 15:38:37 +02002548 PAUSE_OFF,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002549 PHY_INTERFACE_MODE_NA);
2550 else
2551 err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
2552 SPEED_UNFORCED, DUPLEX_UNFORCED,
Andrew Lunn54186b92018-08-09 15:38:37 +02002553 PAUSE_ON,
Vivien Didelotd78343d2016-11-04 03:23:36 +01002554 PHY_INTERFACE_MODE_NA);
2555 if (err)
2556 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002557
2558 /* Port Control: disable Drop-on-Unlock, disable Drop-on-Lock,
2559 * disable Header mode, enable IGMP/MLD snooping, disable VLAN
2560 * tunneling, determine priority by looking at 802.1p and IP
2561 * priority fields (IP prio has precedence), and set STP state
2562 * to Forwarding.
2563 *
2564 * If this is the CPU link, use DSA or EDSA tagging depending
2565 * on which tagging mode was configured.
2566 *
2567 * If this is a link to another switch, use DSA tagging mode.
2568 *
2569 * If this is the upstream port for this switch, enable
2570 * forwarding of unknown unicasts and multicasts.
2571 */
Vivien Didelota89b433be2017-06-12 12:37:37 -04002572 reg = MV88E6XXX_PORT_CTL0_IGMP_MLD_SNOOP |
2573 MV88E6185_PORT_CTL0_USE_TAG | MV88E6185_PORT_CTL0_USE_IP |
2574 MV88E6XXX_PORT_CTL0_STATE_FORWARDING;
2575 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002576 if (err)
2577 return err;
Andrew Lunn6083ce72015-08-17 23:52:52 +02002578
Vivien Didelot601aeed2017-03-11 16:13:00 -05002579 err = mv88e6xxx_setup_port_mode(chip, port);
Andrew Lunn56995cb2016-12-03 04:35:19 +01002580 if (err)
2581 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002582
Vivien Didelot601aeed2017-03-11 16:13:00 -05002583 err = mv88e6xxx_setup_egress_floods(chip, port);
Vivien Didelot43145572017-03-11 16:12:59 -05002584 if (err)
2585 return err;
2586
Vivien Didelot8efdda42015-08-13 12:52:23 -04002587 /* Port Control 2: don't force a good FCS, set the maximum frame size to
Vivien Didelot46fbe5e2016-02-26 13:16:07 -05002588 * 10240 bytes, disable 802.1q tags checking, don't discard tagged or
Vivien Didelot8efdda42015-08-13 12:52:23 -04002589 * untagged frames on this port, do a destination address lookup on all
2590 * received packets as usual, disable ARP mirroring and don't send a
2591 * copy of all transmitted/received frames on this port to the CPU.
Andrew Lunn54d792f2015-05-06 01:09:47 +02002592 */
Andrew Lunna23b2962017-02-04 20:15:28 +01002593 err = mv88e6xxx_port_set_map_da(chip, port);
2594 if (err)
2595 return err;
2596
Vivien Didelotfa371c82017-12-05 15:34:10 -05002597 err = mv88e6xxx_setup_upstream_port(chip, port);
2598 if (err)
2599 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002600
Andrew Lunna23b2962017-02-04 20:15:28 +01002601 err = mv88e6xxx_port_set_8021q_mode(chip, port,
Vivien Didelot81c6edb2017-06-12 12:37:41 -04002602 MV88E6XXX_PORT_CTL2_8021Q_MODE_DISABLED);
Andrew Lunna23b2962017-02-04 20:15:28 +01002603 if (err)
2604 return err;
2605
Vivien Didelotcd782652017-06-08 18:34:13 -04002606 if (chip->info->ops->port_set_jumbo_size) {
2607 err = chip->info->ops->port_set_jumbo_size(chip, port, 10240);
Andrew Lunn5f436662016-12-03 04:45:17 +01002608 if (err)
2609 return err;
2610 }
2611
Andrew Lunn54d792f2015-05-06 01:09:47 +02002612 /* Port Association Vector: when learning source addresses
2613 * of packets, add the address to the address database using
2614 * a port bitmap that has only the bit for this port set and
2615 * the other bits clear.
2616 */
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002617 reg = 1 << port;
Vivien Didelot996ecb82016-04-14 14:42:08 -04002618 /* Disable learning for CPU port */
2619 if (dsa_is_cpu_port(ds, port))
Vivien Didelot65fa4022016-04-14 14:42:07 -04002620 reg = 0;
Andrew Lunn4c7ea3c2015-11-03 10:52:36 -05002621
Vivien Didelot2a4614e2017-06-12 12:37:43 -04002622 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR,
2623 reg);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002624 if (err)
2625 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002626
2627 /* Egress rate control 2: disable egress rate control. */
Vivien Didelot2cb8cb12017-06-12 12:37:42 -04002628 err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_EGRESS_RATE_CTL2,
2629 0x0000);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002630 if (err)
2631 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002632
Vivien Didelot08984322017-06-08 18:34:12 -04002633 if (chip->info->ops->port_pause_limit) {
2634 err = chip->info->ops->port_pause_limit(chip, port, 0, 0);
Andrew Lunnb35d322a2016-12-03 04:45:19 +01002635 if (err)
2636 return err;
2637 }
2638
Vivien Didelotc8c94892017-03-11 16:13:01 -05002639 if (chip->info->ops->port_disable_learn_limit) {
2640 err = chip->info->ops->port_disable_learn_limit(chip, port);
2641 if (err)
2642 return err;
2643 }
2644
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05002645 if (chip->info->ops->port_disable_pri_override) {
2646 err = chip->info->ops->port_disable_pri_override(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002647 if (err)
2648 return err;
Andrew Lunnef0a7312016-12-03 04:35:16 +01002649 }
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02002650
Andrew Lunnef0a7312016-12-03 04:35:16 +01002651 if (chip->info->ops->port_tag_remap) {
2652 err = chip->info->ops->port_tag_remap(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002653 if (err)
2654 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002655 }
2656
Andrew Lunnef70b112016-12-03 04:45:18 +01002657 if (chip->info->ops->port_egress_rate_limiting) {
2658 err = chip->info->ops->port_egress_rate_limiting(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002659 if (err)
2660 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02002661 }
2662
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02002663 if (chip->info->ops->port_setup_message_port) {
2664 err = chip->info->ops->port_setup_message_port(chip, port);
2665 if (err)
2666 return err;
2667 }
Guenter Roeckd827e882015-03-26 18:36:29 -07002668
Vivien Didelot207afda2016-04-14 14:42:09 -04002669 /* Port based VLAN map: give each port the same default address
Vivien Didelotb7666ef2016-02-26 13:16:06 -05002670 * database, and allow bidirectional communication between the
2671 * CPU and DSA port(s), and the other ports.
Guenter Roeckd827e882015-03-26 18:36:29 -07002672 */
Vivien Didelotb4e48c52016-11-04 03:23:29 +01002673 err = mv88e6xxx_port_set_fid(chip, port, 0);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002674 if (err)
2675 return err;
Vivien Didelot2db9ce12016-02-26 13:16:04 -05002676
Vivien Didelot240ea3e2017-03-30 17:37:12 -04002677 err = mv88e6xxx_port_vlan_map(chip, port);
Andrew Lunn0e7b9922016-09-21 01:40:31 +02002678 if (err)
2679 return err;
Guenter Roeckd827e882015-03-26 18:36:29 -07002680
2681 /* Default VLAN ID and priority: don't set a default VLAN
2682 * ID, and set the default packet priority to zero.
2683 */
Vivien Didelotb7929fb2017-06-12 12:37:40 -04002684 return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
Andrew Lunndbde9e62015-05-06 01:09:48 +02002685}
2686
Andrew Lunn04aca992017-05-26 01:03:24 +02002687static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
2688 struct phy_device *phydev)
2689{
2690 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot523a8902017-05-26 18:02:42 -04002691 int err;
Andrew Lunn04aca992017-05-26 01:03:24 +02002692
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002693 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002694 err = mv88e6xxx_serdes_power(chip, port, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002695 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002696
2697 return err;
2698}
2699
Andrew Lunn75104db2019-02-24 20:44:43 +01002700static void mv88e6xxx_port_disable(struct dsa_switch *ds, int port)
Andrew Lunn04aca992017-05-26 01:03:24 +02002701{
2702 struct mv88e6xxx_chip *chip = ds->priv;
2703
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002704 mv88e6xxx_reg_lock(chip);
Vivien Didelot523a8902017-05-26 18:02:42 -04002705 if (mv88e6xxx_serdes_power(chip, port, false))
2706 dev_err(chip->dev, "failed to power off SERDES\n");
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002707 mv88e6xxx_reg_unlock(chip);
Andrew Lunn04aca992017-05-26 01:03:24 +02002708}
2709
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002710static int mv88e6xxx_set_ageing_time(struct dsa_switch *ds,
2711 unsigned int ageing_time)
2712{
Vivien Didelot04bed142016-08-31 18:06:13 -04002713 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002714 int err;
2715
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002716 mv88e6xxx_reg_lock(chip);
Vivien Didelot720c6342017-03-11 16:12:48 -05002717 err = mv88e6xxx_g1_atu_set_age_time(chip, ageing_time);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00002718 mv88e6xxx_reg_unlock(chip);
Vivien Didelot2cfcd962016-07-18 20:45:40 -04002719
2720 return err;
2721}
2722
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002723static int mv88e6xxx_stats_setup(struct mv88e6xxx_chip *chip)
Vivien Didelot08a01262016-05-09 13:22:50 -04002724{
2725 int err;
Vivien Didelot08a01262016-05-09 13:22:50 -04002726
Andrew Lunnde2273872016-11-21 23:27:01 +01002727 /* Initialize the statistics unit */
Vivien Didelot447b1bb2018-05-11 17:16:36 -04002728 if (chip->info->ops->stats_set_histogram) {
2729 err = chip->info->ops->stats_set_histogram(chip);
2730 if (err)
2731 return err;
2732 }
Andrew Lunnde2273872016-11-21 23:27:01 +01002733
Andrew Lunn40cff8f2017-11-10 00:36:41 +01002734 return mv88e6xxx_g1_stats_clear(chip);
Vivien Didelot97299342016-07-18 20:45:30 -04002735}
2736
Andrew Lunnea890982019-01-09 00:24:03 +01002737/* Check if the errata has already been applied. */
2738static bool mv88e6390_setup_errata_applied(struct mv88e6xxx_chip *chip)
2739{
2740 int port;
2741 int err;
2742 u16 val;
2743
2744 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002745 err = mv88e6xxx_port_hidden_read(chip, 0xf, port, 0, &val);
Andrew Lunnea890982019-01-09 00:24:03 +01002746 if (err) {
2747 dev_err(chip->dev,
2748 "Error reading hidden register: %d\n", err);
2749 return false;
2750 }
2751 if (val != 0x01c0)
2752 return false;
2753 }
2754
2755 return true;
2756}
2757
2758/* The 6390 copper ports have an errata which require poking magic
2759 * values into undocumented hidden registers and then performing a
2760 * software reset.
2761 */
2762static int mv88e6390_setup_errata(struct mv88e6xxx_chip *chip)
2763{
2764 int port;
2765 int err;
2766
2767 if (mv88e6390_setup_errata_applied(chip))
2768 return 0;
2769
2770 /* Set the ports into blocking mode */
2771 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
2772 err = mv88e6xxx_port_set_state(chip, port, BR_STATE_DISABLED);
2773 if (err)
2774 return err;
2775 }
2776
2777 for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
Marek Behún60907012019-08-26 23:31:51 +02002778 err = mv88e6xxx_port_hidden_write(chip, 0xf, port, 0, 0x01c0);
Andrew Lunnea890982019-01-09 00:24:03 +01002779 if (err)
2780 return err;
2781 }
2782
2783 return mv88e6xxx_software_reset(chip);
2784}
2785
Andrew Lunn23e8b472019-10-25 01:03:52 +02002786enum mv88e6xxx_devlink_param_id {
2787 MV88E6XXX_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
2788 MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2789};
2790
2791static int mv88e6xxx_devlink_param_get(struct dsa_switch *ds, u32 id,
2792 struct devlink_param_gset_ctx *ctx)
2793{
2794 struct mv88e6xxx_chip *chip = ds->priv;
2795 int err;
2796
2797 mv88e6xxx_reg_lock(chip);
2798
2799 switch (id) {
2800 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2801 err = mv88e6xxx_atu_get_hash(chip, &ctx->val.vu8);
2802 break;
2803 default:
2804 err = -EOPNOTSUPP;
2805 break;
2806 }
2807
2808 mv88e6xxx_reg_unlock(chip);
2809
2810 return err;
2811}
2812
2813static int mv88e6xxx_devlink_param_set(struct dsa_switch *ds, u32 id,
2814 struct devlink_param_gset_ctx *ctx)
2815{
2816 struct mv88e6xxx_chip *chip = ds->priv;
2817 int err;
2818
2819 mv88e6xxx_reg_lock(chip);
2820
2821 switch (id) {
2822 case MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH:
2823 err = mv88e6xxx_atu_set_hash(chip, ctx->val.vu8);
2824 break;
2825 default:
2826 err = -EOPNOTSUPP;
2827 break;
2828 }
2829
2830 mv88e6xxx_reg_unlock(chip);
2831
2832 return err;
2833}
2834
2835static const struct devlink_param mv88e6xxx_devlink_params[] = {
2836 DSA_DEVLINK_PARAM_DRIVER(MV88E6XXX_DEVLINK_PARAM_ID_ATU_HASH,
2837 "ATU_hash", DEVLINK_PARAM_TYPE_U8,
2838 BIT(DEVLINK_PARAM_CMODE_RUNTIME)),
2839};
2840
2841static int mv88e6xxx_setup_devlink_params(struct dsa_switch *ds)
2842{
2843 return dsa_devlink_params_register(ds, mv88e6xxx_devlink_params,
2844 ARRAY_SIZE(mv88e6xxx_devlink_params));
2845}
2846
2847static void mv88e6xxx_teardown_devlink_params(struct dsa_switch *ds)
2848{
2849 dsa_devlink_params_unregister(ds, mv88e6xxx_devlink_params,
2850 ARRAY_SIZE(mv88e6xxx_devlink_params));
2851}
2852
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002853enum mv88e6xxx_devlink_resource_id {
2854 MV88E6XXX_RESOURCE_ID_ATU,
2855 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2856 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2857 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2858 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2859};
2860
2861static u64 mv88e6xxx_devlink_atu_bin_get(struct mv88e6xxx_chip *chip,
2862 u16 bin)
2863{
2864 u16 occupancy = 0;
2865 int err;
2866
2867 mv88e6xxx_reg_lock(chip);
2868
2869 err = mv88e6xxx_g2_atu_stats_set(chip, MV88E6XXX_G2_ATU_STATS_MODE_ALL,
2870 bin);
2871 if (err) {
2872 dev_err(chip->dev, "failed to set ATU stats kind/bin\n");
2873 goto unlock;
2874 }
2875
2876 err = mv88e6xxx_g1_atu_get_next(chip, 0);
2877 if (err) {
2878 dev_err(chip->dev, "failed to perform ATU get next\n");
2879 goto unlock;
2880 }
2881
2882 err = mv88e6xxx_g2_atu_stats_get(chip, &occupancy);
2883 if (err) {
2884 dev_err(chip->dev, "failed to get ATU stats\n");
2885 goto unlock;
2886 }
2887
Andrew Lunn012fc742020-03-11 21:02:31 +01002888 occupancy &= MV88E6XXX_G2_ATU_STATS_MASK;
2889
Andrew Lunne0c69ca2019-11-05 01:13:01 +01002890unlock:
2891 mv88e6xxx_reg_unlock(chip);
2892
2893 return occupancy;
2894}
2895
2896static u64 mv88e6xxx_devlink_atu_bin_0_get(void *priv)
2897{
2898 struct mv88e6xxx_chip *chip = priv;
2899
2900 return mv88e6xxx_devlink_atu_bin_get(chip,
2901 MV88E6XXX_G2_ATU_STATS_BIN_0);
2902}
2903
2904static u64 mv88e6xxx_devlink_atu_bin_1_get(void *priv)
2905{
2906 struct mv88e6xxx_chip *chip = priv;
2907
2908 return mv88e6xxx_devlink_atu_bin_get(chip,
2909 MV88E6XXX_G2_ATU_STATS_BIN_1);
2910}
2911
2912static u64 mv88e6xxx_devlink_atu_bin_2_get(void *priv)
2913{
2914 struct mv88e6xxx_chip *chip = priv;
2915
2916 return mv88e6xxx_devlink_atu_bin_get(chip,
2917 MV88E6XXX_G2_ATU_STATS_BIN_2);
2918}
2919
2920static u64 mv88e6xxx_devlink_atu_bin_3_get(void *priv)
2921{
2922 struct mv88e6xxx_chip *chip = priv;
2923
2924 return mv88e6xxx_devlink_atu_bin_get(chip,
2925 MV88E6XXX_G2_ATU_STATS_BIN_3);
2926}
2927
2928static u64 mv88e6xxx_devlink_atu_get(void *priv)
2929{
2930 return mv88e6xxx_devlink_atu_bin_0_get(priv) +
2931 mv88e6xxx_devlink_atu_bin_1_get(priv) +
2932 mv88e6xxx_devlink_atu_bin_2_get(priv) +
2933 mv88e6xxx_devlink_atu_bin_3_get(priv);
2934}
2935
2936static int mv88e6xxx_setup_devlink_resources(struct dsa_switch *ds)
2937{
2938 struct devlink_resource_size_params size_params;
2939 struct mv88e6xxx_chip *chip = ds->priv;
2940 int err;
2941
2942 devlink_resource_size_params_init(&size_params,
2943 mv88e6xxx_num_macs(chip),
2944 mv88e6xxx_num_macs(chip),
2945 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2946
2947 err = dsa_devlink_resource_register(ds, "ATU",
2948 mv88e6xxx_num_macs(chip),
2949 MV88E6XXX_RESOURCE_ID_ATU,
2950 DEVLINK_RESOURCE_ID_PARENT_TOP,
2951 &size_params);
2952 if (err)
2953 goto out;
2954
2955 devlink_resource_size_params_init(&size_params,
2956 mv88e6xxx_num_macs(chip) / 4,
2957 mv88e6xxx_num_macs(chip) / 4,
2958 1, DEVLINK_RESOURCE_UNIT_ENTRY);
2959
2960 err = dsa_devlink_resource_register(ds, "ATU_bin_0",
2961 mv88e6xxx_num_macs(chip) / 4,
2962 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2963 MV88E6XXX_RESOURCE_ID_ATU,
2964 &size_params);
2965 if (err)
2966 goto out;
2967
2968 err = dsa_devlink_resource_register(ds, "ATU_bin_1",
2969 mv88e6xxx_num_macs(chip) / 4,
2970 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
2971 MV88E6XXX_RESOURCE_ID_ATU,
2972 &size_params);
2973 if (err)
2974 goto out;
2975
2976 err = dsa_devlink_resource_register(ds, "ATU_bin_2",
2977 mv88e6xxx_num_macs(chip) / 4,
2978 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
2979 MV88E6XXX_RESOURCE_ID_ATU,
2980 &size_params);
2981 if (err)
2982 goto out;
2983
2984 err = dsa_devlink_resource_register(ds, "ATU_bin_3",
2985 mv88e6xxx_num_macs(chip) / 4,
2986 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
2987 MV88E6XXX_RESOURCE_ID_ATU,
2988 &size_params);
2989 if (err)
2990 goto out;
2991
2992 dsa_devlink_resource_occ_get_register(ds,
2993 MV88E6XXX_RESOURCE_ID_ATU,
2994 mv88e6xxx_devlink_atu_get,
2995 chip);
2996
2997 dsa_devlink_resource_occ_get_register(ds,
2998 MV88E6XXX_RESOURCE_ID_ATU_BIN_0,
2999 mv88e6xxx_devlink_atu_bin_0_get,
3000 chip);
3001
3002 dsa_devlink_resource_occ_get_register(ds,
3003 MV88E6XXX_RESOURCE_ID_ATU_BIN_1,
3004 mv88e6xxx_devlink_atu_bin_1_get,
3005 chip);
3006
3007 dsa_devlink_resource_occ_get_register(ds,
3008 MV88E6XXX_RESOURCE_ID_ATU_BIN_2,
3009 mv88e6xxx_devlink_atu_bin_2_get,
3010 chip);
3011
3012 dsa_devlink_resource_occ_get_register(ds,
3013 MV88E6XXX_RESOURCE_ID_ATU_BIN_3,
3014 mv88e6xxx_devlink_atu_bin_3_get,
3015 chip);
3016
3017 return 0;
3018
3019out:
3020 dsa_devlink_resources_unregister(ds);
3021 return err;
3022}
3023
Andrew Lunn23e8b472019-10-25 01:03:52 +02003024static void mv88e6xxx_teardown(struct dsa_switch *ds)
3025{
3026 mv88e6xxx_teardown_devlink_params(ds);
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003027 dsa_devlink_resources_unregister(ds);
Andrew Lunn23e8b472019-10-25 01:03:52 +02003028}
3029
Vivien Didelotf81ec902016-05-09 13:22:58 -04003030static int mv88e6xxx_setup(struct dsa_switch *ds)
Guenter Roeckacdaffc2015-03-26 18:36:28 -07003031{
Vivien Didelot04bed142016-08-31 18:06:13 -04003032 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003033 u8 cmode;
Vivien Didelot552238b2016-05-09 13:22:49 -04003034 int err;
Vivien Didelota1a6a4d2016-05-09 13:22:56 -04003035 int i;
3036
Vivien Didelotfad09c72016-06-21 12:28:20 -04003037 chip->ds = ds;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003038 ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003039
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003040 mv88e6xxx_reg_lock(chip);
Vivien Didelot552238b2016-05-09 13:22:49 -04003041
Andrew Lunnea890982019-01-09 00:24:03 +01003042 if (chip->info->ops->setup_errata) {
3043 err = chip->info->ops->setup_errata(chip);
3044 if (err)
3045 goto unlock;
3046 }
3047
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003048 /* Cache the cmode of each port. */
3049 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
3050 if (chip->info->ops->port_get_cmode) {
3051 err = chip->info->ops->port_get_cmode(chip, i, &cmode);
3052 if (err)
Dan Carpentere29129f2018-08-14 12:09:05 +03003053 goto unlock;
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003054
3055 chip->ports[i].cmode = cmode;
3056 }
3057 }
3058
Vivien Didelot97299342016-07-18 20:45:30 -04003059 /* Setup Switch Port Registers */
Vivien Didelot370b4ff2016-09-29 12:21:57 -04003060 for (i = 0; i < mv88e6xxx_num_ports(chip); i++) {
Vivien Didelotb759f522019-08-19 16:00:52 -04003061 if (dsa_is_unused_port(ds, i))
3062 continue;
3063
Hubert Feursteinc8574862019-07-31 10:23:48 +02003064 /* Prevent the use of an invalid port. */
Vivien Didelotb759f522019-08-19 16:00:52 -04003065 if (mv88e6xxx_is_invalid_port(chip, i)) {
Hubert Feursteinc8574862019-07-31 10:23:48 +02003066 dev_err(chip->dev, "port %d is invalid\n", i);
3067 err = -EINVAL;
3068 goto unlock;
3069 }
3070
Vivien Didelot97299342016-07-18 20:45:30 -04003071 err = mv88e6xxx_setup_port(chip, i);
3072 if (err)
3073 goto unlock;
3074 }
3075
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003076 err = mv88e6xxx_irl_setup(chip);
3077 if (err)
3078 goto unlock;
3079
Vivien Didelot04a69a12017-10-13 14:18:05 -04003080 err = mv88e6xxx_mac_setup(chip);
3081 if (err)
3082 goto unlock;
3083
Vivien Didelot1b17aed2017-05-26 18:03:05 -04003084 err = mv88e6xxx_phy_setup(chip);
3085 if (err)
3086 goto unlock;
3087
Vivien Didelotb486d7c2017-05-01 14:05:13 -04003088 err = mv88e6xxx_vtu_setup(chip);
3089 if (err)
3090 goto unlock;
3091
Vivien Didelot81228992017-03-30 17:37:08 -04003092 err = mv88e6xxx_pvt_setup(chip);
3093 if (err)
3094 goto unlock;
3095
Vivien Didelota2ac29d2017-03-11 16:12:49 -05003096 err = mv88e6xxx_atu_setup(chip);
3097 if (err)
3098 goto unlock;
3099
Andrew Lunn87fa8862017-11-09 22:29:56 +01003100 err = mv88e6xxx_broadcast_setup(chip, 0);
3101 if (err)
3102 goto unlock;
3103
Vivien Didelot9e907d72017-07-17 13:03:43 -04003104 err = mv88e6xxx_pot_setup(chip);
3105 if (err)
3106 goto unlock;
3107
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003108 err = mv88e6xxx_rmu_setup(chip);
3109 if (err)
3110 goto unlock;
3111
Vivien Didelot51c901a2017-07-17 13:03:41 -04003112 err = mv88e6xxx_rsvd2cpu_setup(chip);
3113 if (err)
3114 goto unlock;
Andrew Lunn6e55f692016-12-03 04:45:16 +01003115
Vivien Didelotb28f8722018-04-26 21:56:44 -04003116 err = mv88e6xxx_trunk_setup(chip);
3117 if (err)
3118 goto unlock;
3119
Vivien Didelotc7f047b2018-04-26 21:56:45 -04003120 err = mv88e6xxx_devmap_setup(chip);
3121 if (err)
3122 goto unlock;
3123
Vivien Didelot93e18d62018-05-11 17:16:35 -04003124 err = mv88e6xxx_pri_setup(chip);
3125 if (err)
3126 goto unlock;
3127
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003128 /* Setup PTP Hardware Clock and timestamping */
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003129 if (chip->info->ptp_support) {
3130 err = mv88e6xxx_ptp_setup(chip);
3131 if (err)
3132 goto unlock;
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01003133
3134 err = mv88e6xxx_hwtstamp_setup(chip);
3135 if (err)
3136 goto unlock;
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01003137 }
3138
Vivien Didelot447b1bb2018-05-11 17:16:36 -04003139 err = mv88e6xxx_stats_setup(chip);
3140 if (err)
3141 goto unlock;
3142
Vivien Didelot6b17e862015-08-13 12:52:18 -04003143unlock:
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003144 mv88e6xxx_reg_unlock(chip);
Andrew Lunndb687a52015-06-20 21:31:29 +02003145
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003146 if (err)
3147 return err;
3148
3149 /* Have to be called without holding the register lock, since
3150 * they take the devlink lock, and we later take the locks in
3151 * the reverse order when getting/setting parameters or
3152 * resource occupancy.
Andrew Lunn23e8b472019-10-25 01:03:52 +02003153 */
Andrew Lunne0c69ca2019-11-05 01:13:01 +01003154 err = mv88e6xxx_setup_devlink_resources(ds);
3155 if (err)
3156 return err;
3157
3158 err = mv88e6xxx_setup_devlink_params(ds);
3159 if (err)
3160 dsa_devlink_resources_unregister(ds);
3161
3162 return err;
Andrew Lunn54d792f2015-05-06 01:09:47 +02003163}
3164
Vivien Didelote57e5e72016-08-15 17:19:00 -04003165static int mv88e6xxx_mdio_read(struct mii_bus *bus, int phy, int reg)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003166{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003167 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3168 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003169 u16 val;
3170 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003171
Andrew Lunnee26a222017-01-24 14:53:48 +01003172 if (!chip->info->ops->phy_read)
3173 return -EOPNOTSUPP;
3174
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003175 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003176 err = chip->info->ops->phy_read(chip, bus, phy, reg, &val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003177 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003178
Andrew Lunnda9f3302017-02-01 03:40:05 +01003179 if (reg == MII_PHYSID2) {
Andrew Lunnddc49ac2018-11-12 18:51:01 +01003180 /* Some internal PHYs don't have a model number. */
3181 if (chip->info->family != MV88E6XXX_FAMILY_6165)
3182 /* Then there is the 6165 family. It gets is
3183 * PHYs correct. But it can also have two
3184 * SERDES interfaces in the PHY address
3185 * space. And these don't have a model
3186 * number. But they are not PHYs, so we don't
3187 * want to give them something a PHY driver
3188 * will recognise.
3189 *
3190 * Use the mv88e6390 family model number
3191 * instead, for anything which really could be
3192 * a PHY,
3193 */
3194 if (!(val & 0x3f0))
3195 val |= MV88E6XXX_PORT_SWITCH_ID_PROD_6390 >> 4;
Andrew Lunnda9f3302017-02-01 03:40:05 +01003196 }
3197
Vivien Didelote57e5e72016-08-15 17:19:00 -04003198 return err ? err : val;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003199}
3200
Vivien Didelote57e5e72016-08-15 17:19:00 -04003201static int mv88e6xxx_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003202{
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003203 struct mv88e6xxx_mdio_bus *mdio_bus = bus->priv;
3204 struct mv88e6xxx_chip *chip = mdio_bus->chip;
Vivien Didelote57e5e72016-08-15 17:19:00 -04003205 int err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003206
Andrew Lunnee26a222017-01-24 14:53:48 +01003207 if (!chip->info->ops->phy_write)
3208 return -EOPNOTSUPP;
3209
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003210 mv88e6xxx_reg_lock(chip);
Andrew Lunnee26a222017-01-24 14:53:48 +01003211 err = chip->info->ops->phy_write(chip, bus, phy, reg, val);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003212 mv88e6xxx_reg_unlock(chip);
Vivien Didelote57e5e72016-08-15 17:19:00 -04003213
3214 return err;
Andrew Lunnfd3a0ee2015-04-02 04:06:36 +02003215}
3216
Vivien Didelotfad09c72016-06-21 12:28:20 -04003217static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
Andrew Lunna3c53be52017-01-24 14:53:50 +01003218 struct device_node *np,
3219 bool external)
Andrew Lunnb516d452016-06-04 21:17:06 +02003220{
3221 static int index;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003222 struct mv88e6xxx_mdio_bus *mdio_bus;
Andrew Lunnb516d452016-06-04 21:17:06 +02003223 struct mii_bus *bus;
3224 int err;
3225
Andrew Lunn2510bab2018-02-22 01:51:49 +01003226 if (external) {
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003227 mv88e6xxx_reg_lock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003228 err = mv88e6xxx_g2_scratch_gpio_set_smi(chip, true);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003229 mv88e6xxx_reg_unlock(chip);
Andrew Lunn2510bab2018-02-22 01:51:49 +01003230
3231 if (err)
3232 return err;
3233 }
3234
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003235 bus = devm_mdiobus_alloc_size(chip->dev, sizeof(*mdio_bus));
Andrew Lunnb516d452016-06-04 21:17:06 +02003236 if (!bus)
3237 return -ENOMEM;
3238
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003239 mdio_bus = bus->priv;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003240 mdio_bus->bus = bus;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003241 mdio_bus->chip = chip;
Andrew Lunna3c53be52017-01-24 14:53:50 +01003242 INIT_LIST_HEAD(&mdio_bus->list);
3243 mdio_bus->external = external;
Andrew Lunn0dd12d52017-01-24 14:53:49 +01003244
Andrew Lunnb516d452016-06-04 21:17:06 +02003245 if (np) {
3246 bus->name = np->full_name;
Rob Herringf7ce9102017-07-18 16:43:19 -05003247 snprintf(bus->id, MII_BUS_ID_SIZE, "%pOF", np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003248 } else {
3249 bus->name = "mv88e6xxx SMI";
3250 snprintf(bus->id, MII_BUS_ID_SIZE, "mv88e6xxx-%d", index++);
3251 }
3252
3253 bus->read = mv88e6xxx_mdio_read;
3254 bus->write = mv88e6xxx_mdio_write;
Vivien Didelotfad09c72016-06-21 12:28:20 -04003255 bus->parent = chip->dev;
Andrew Lunnb516d452016-06-04 21:17:06 +02003256
Andrew Lunn6f882842018-03-17 20:32:05 +01003257 if (!external) {
3258 err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
3259 if (err)
3260 return err;
3261 }
3262
Florian Fainelli00e798c2018-05-15 16:56:19 -07003263 err = of_mdiobus_register(bus, np);
Andrew Lunnb516d452016-06-04 21:17:06 +02003264 if (err) {
Vivien Didelotfad09c72016-06-21 12:28:20 -04003265 dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
Andrew Lunn6f882842018-03-17 20:32:05 +01003266 mv88e6xxx_g2_irq_mdio_free(chip, bus);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003267 return err;
Andrew Lunnb516d452016-06-04 21:17:06 +02003268 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003269
3270 if (external)
3271 list_add_tail(&mdio_bus->list, &chip->mdios);
3272 else
3273 list_add(&mdio_bus->list, &chip->mdios);
Andrew Lunnb516d452016-06-04 21:17:06 +02003274
3275 return 0;
Andrew Lunnb516d452016-06-04 21:17:06 +02003276}
3277
Andrew Lunna3c53be52017-01-24 14:53:50 +01003278static const struct of_device_id mv88e6xxx_mdio_external_match[] = {
3279 { .compatible = "marvell,mv88e6xxx-mdio-external",
3280 .data = (void *)true },
3281 { },
3282};
3283
Andrew Lunn3126aee2017-12-07 01:05:57 +01003284static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
3285
3286{
3287 struct mv88e6xxx_mdio_bus *mdio_bus;
3288 struct mii_bus *bus;
3289
3290 list_for_each_entry(mdio_bus, &chip->mdios, list) {
3291 bus = mdio_bus->bus;
3292
Andrew Lunn6f882842018-03-17 20:32:05 +01003293 if (!mdio_bus->external)
3294 mv88e6xxx_g2_irq_mdio_free(chip, bus);
3295
Andrew Lunn3126aee2017-12-07 01:05:57 +01003296 mdiobus_unregister(bus);
3297 }
3298}
3299
Andrew Lunna3c53be52017-01-24 14:53:50 +01003300static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
3301 struct device_node *np)
3302{
3303 const struct of_device_id *match;
3304 struct device_node *child;
3305 int err;
3306
3307 /* Always register one mdio bus for the internal/default mdio
3308 * bus. This maybe represented in the device tree, but is
3309 * optional.
3310 */
3311 child = of_get_child_by_name(np, "mdio");
3312 err = mv88e6xxx_mdio_register(chip, child, false);
3313 if (err)
3314 return err;
3315
3316 /* Walk the device tree, and see if there are any other nodes
3317 * which say they are compatible with the external mdio
3318 * bus.
3319 */
3320 for_each_available_child_of_node(np, child) {
3321 match = of_match_node(mv88e6xxx_mdio_external_match, child);
3322 if (match) {
3323 err = mv88e6xxx_mdio_register(chip, child, true);
Andrew Lunn3126aee2017-12-07 01:05:57 +01003324 if (err) {
3325 mv88e6xxx_mdios_unregister(chip);
Nishka Dasgupta78e42042019-07-23 16:13:07 +05303326 of_node_put(child);
Andrew Lunna3c53be52017-01-24 14:53:50 +01003327 return err;
Andrew Lunn3126aee2017-12-07 01:05:57 +01003328 }
Andrew Lunna3c53be52017-01-24 14:53:50 +01003329 }
3330 }
3331
3332 return 0;
3333}
3334
Vivien Didelot855b1932016-07-20 18:18:35 -04003335static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds)
3336{
Vivien Didelot04bed142016-08-31 18:06:13 -04003337 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003338
3339 return chip->eeprom_len;
3340}
3341
Vivien Didelot855b1932016-07-20 18:18:35 -04003342static int mv88e6xxx_get_eeprom(struct dsa_switch *ds,
3343 struct ethtool_eeprom *eeprom, u8 *data)
3344{
Vivien Didelot04bed142016-08-31 18:06:13 -04003345 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003346 int err;
3347
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003348 if (!chip->info->ops->get_eeprom)
3349 return -EOPNOTSUPP;
3350
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003351 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003352 err = chip->info->ops->get_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003353 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003354
3355 if (err)
3356 return err;
3357
3358 eeprom->magic = 0xc3ec4951;
3359
3360 return 0;
3361}
3362
Vivien Didelot855b1932016-07-20 18:18:35 -04003363static int mv88e6xxx_set_eeprom(struct dsa_switch *ds,
3364 struct ethtool_eeprom *eeprom, u8 *data)
3365{
Vivien Didelot04bed142016-08-31 18:06:13 -04003366 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot855b1932016-07-20 18:18:35 -04003367 int err;
3368
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003369 if (!chip->info->ops->set_eeprom)
3370 return -EOPNOTSUPP;
3371
Vivien Didelot855b1932016-07-20 18:18:35 -04003372 if (eeprom->magic != 0xc3ec4951)
3373 return -EINVAL;
3374
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003375 mv88e6xxx_reg_lock(chip);
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003376 err = chip->info->ops->set_eeprom(chip, eeprom, data);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00003377 mv88e6xxx_reg_unlock(chip);
Vivien Didelot855b1932016-07-20 18:18:35 -04003378
3379 return err;
3380}
3381
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003382static const struct mv88e6xxx_ops mv88e6085_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003383 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003384 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3385 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003386 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003387 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003388 .phy_read = mv88e6185_phy_ppu_read,
3389 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003390 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003391 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003392 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003393 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003394 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003395 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunnef70b112016-12-03 04:45:18 +01003396 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003397 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003398 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003399 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003400 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003401 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003402 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003403 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003404 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3405 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003406 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003407 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3408 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003409 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003410 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003411 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003412 .ppu_enable = mv88e6185_g1_ppu_enable,
3413 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003414 .reset = mv88e6185_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003415 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003416 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003417 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003418 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003419};
3420
3421static const struct mv88e6xxx_ops mv88e6095_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003422 /* MV88E6XXX_FAMILY_6095 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003423 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3424 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003425 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003426 .phy_read = mv88e6185_phy_ppu_read,
3427 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003428 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003429 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003430 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003431 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunna23b2962017-02-04 20:15:28 +01003432 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003433 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003434 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003435 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003436 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003437 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3438 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003439 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003440 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003441 .ppu_enable = mv88e6185_g1_ppu_enable,
3442 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003443 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003444 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003445 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003446 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003447};
3448
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003449static const struct mv88e6xxx_ops mv88e6097_ops = {
Stefan Eichenberger15da3cc2016-11-25 09:41:30 +01003450 /* MV88E6XXX_FAMILY_6097 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003451 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3452 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003453 .irl_init_all = mv88e6352_g2_irl_init_all,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003454 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3455 .phy_read = mv88e6xxx_g2_smi_phy_read,
3456 .phy_write = mv88e6xxx_g2_smi_phy_write,
3457 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003458 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003459 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003460 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003461 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003462 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003463 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003464 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003465 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003466 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003467 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003468 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003469 .port_setup_message_port = mv88e6xxx_setup_message_port,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003470 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003471 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003472 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3473 .stats_get_strings = mv88e6095_stats_get_strings,
3474 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003475 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3476 .set_egress_port = mv88e6095_g1_set_egress_port,
Volodymyr Bendiuga91eaa472017-02-14 11:29:30 +01003477 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003478 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003479 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003480 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003481 .rmu_disable = mv88e6085_g1_rmu_disable,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003482 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003483 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003484 .phylink_validate = mv88e6185_phylink_validate,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01003485};
3486
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003487static const struct mv88e6xxx_ops mv88e6123_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003488 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003489 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3490 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003491 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003492 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003493 .phy_read = mv88e6xxx_g2_smi_phy_read,
3494 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003495 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003496 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003497 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003498 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003499 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003500 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003501 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003502 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn0ac64c32017-06-02 23:22:46 +02003503 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003504 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003505 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3506 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003507 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003508 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3509 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003510 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003511 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003512 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003513 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003514 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3515 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003516 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003517 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003518 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003519};
3520
3521static const struct mv88e6xxx_ops mv88e6131_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003522 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003523 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3524 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003525 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003526 .phy_read = mv88e6185_phy_ppu_read,
3527 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003528 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003529 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003530 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003531 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003532 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003533 .port_set_ether_type = mv88e6351_port_set_ether_type,
Andrew Lunna23b2962017-02-04 20:15:28 +01003534 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Vivien Didelotcd782652017-06-08 18:34:13 -04003535 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003536 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003537 .port_pause_limit = mv88e6097_port_pause_limit,
Andrew Lunn54186b92018-08-09 15:38:37 +02003538 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003539 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003540 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003541 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003542 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003543 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3544 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003545 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003546 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3547 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003548 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003549 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003550 .ppu_enable = mv88e6185_g1_ppu_enable,
Vivien Didelot02317e62018-05-09 11:38:49 -04003551 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003552 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003553 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003554 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003555 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003556 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003557};
3558
Vivien Didelot990e27b2017-03-28 13:50:32 -04003559static const struct mv88e6xxx_ops mv88e6141_ops = {
3560 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003561 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3562 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003563 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003564 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3565 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
3566 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3567 .phy_read = mv88e6xxx_g2_smi_phy_read,
3568 .phy_write = mv88e6xxx_g2_smi_phy_write,
3569 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003570 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003571 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003572 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003573 .port_tag_remap = mv88e6095_port_tag_remap,
3574 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
3575 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
3576 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003577 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003578 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003579 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003580 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
3581 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003582 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02003583 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003584 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003585 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003586 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003587 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3588 .stats_get_strings = mv88e6320_stats_get_strings,
3589 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003590 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3591 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003592 .watchdog_ops = &mv88e6390_watchdog_ops,
3593 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003594 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003595 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003596 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003597 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02003598 .serdes_power = mv88e6390_serdes_power,
3599 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003600 /* Check status register pause & lpa register */
3601 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3602 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3603 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3604 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003605 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003606 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003607 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003608 .gpio_ops = &mv88e6352_gpio_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01003609 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot990e27b2017-03-28 13:50:32 -04003610};
3611
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003612static const struct mv88e6xxx_ops mv88e6161_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003613 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003614 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3615 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003616 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003617 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnec8378b2017-06-02 23:22:45 +02003618 .phy_read = mv88e6xxx_g2_smi_phy_read,
3619 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003620 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003621 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003622 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003623 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003624 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003625 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003626 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003627 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003628 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003629 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003630 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003631 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003632 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna6da21b2019-03-01 23:43:39 +01003633 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003634 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003635 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3636 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003637 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003638 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3639 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003640 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003641 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003642 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003643 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003644 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3645 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003646 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003647 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003648 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003649 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003650 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003651};
3652
3653static const struct mv88e6xxx_ops mv88e6165_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003654 /* MV88E6XXX_FAMILY_6165 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003655 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3656 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003657 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003658 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Andrew Lunnefb3e742017-01-24 14:53:47 +01003659 .phy_read = mv88e6165_phy_read,
3660 .phy_write = mv88e6165_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003661 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003662 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003663 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003664 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003665 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003666 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003667 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003668 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003669 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3670 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003671 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003672 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3673 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003674 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003675 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003676 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003677 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003678 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3679 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003680 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003681 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Andrew Lunna469a612018-07-18 22:38:21 +02003682 .avb_ops = &mv88e6165_avb_ops,
Andrew Lunndfa54342018-07-18 22:38:22 +02003683 .ptp_ops = &mv88e6165_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02003684 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003685};
3686
3687static const struct mv88e6xxx_ops mv88e6171_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003688 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003689 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3690 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003691 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003692 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003693 .phy_read = mv88e6xxx_g2_smi_phy_read,
3694 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003695 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003696 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003697 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003698 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003699 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003700 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003701 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003702 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003703 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003704 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003705 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003706 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003707 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003708 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003709 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003710 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003711 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3712 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003713 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003714 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3715 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003716 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003717 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003718 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003719 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003720 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3721 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003722 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003723 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003724 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003725};
3726
3727static const struct mv88e6xxx_ops mv88e6172_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003728 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003729 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3730 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003731 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003732 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3733 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003734 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003735 .phy_read = mv88e6xxx_g2_smi_phy_read,
3736 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003737 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003738 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003739 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003740 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003741 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003742 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003743 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003744 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003745 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003746 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003747 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003748 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003749 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003750 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003751 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003752 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003753 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003754 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3755 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003756 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003757 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3758 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003759 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003760 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003761 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003762 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003763 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003764 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3765 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003766 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003767 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003768 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003769 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3770 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3771 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3772 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003773 .serdes_power = mv88e6352_serdes_power,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003774 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3775 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003776 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003777 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003778};
3779
3780static const struct mv88e6xxx_ops mv88e6175_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003781 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003782 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3783 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003784 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003785 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003786 .phy_read = mv88e6xxx_g2_smi_phy_read,
3787 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003788 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01003789 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003790 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003791 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003792 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003793 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003794 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003795 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003796 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003797 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003798 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003799 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003800 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003801 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003802 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003803 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003804 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3805 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003806 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003807 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3808 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003809 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003810 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003811 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003812 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003813 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3814 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003815 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003816 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003817 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003818};
3819
3820static const struct mv88e6xxx_ops mv88e6176_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003821 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003822 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3823 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003824 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04003825 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
3826 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003827 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003828 .phy_read = mv88e6xxx_g2_smi_phy_read,
3829 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003830 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01003831 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003832 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003833 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003834 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003835 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003836 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003837 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04003838 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01003839 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04003840 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003841 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003842 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003843 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003844 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003845 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003846 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003847 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3848 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003849 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003850 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3851 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003852 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003853 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003854 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003855 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003856 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003857 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3858 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003859 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003860 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04003861 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003862 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
3863 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
3864 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
3865 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02003866 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003867 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003868 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003869 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01003870 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
3871 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003872 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003873 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003874};
3875
3876static const struct mv88e6xxx_ops mv88e6185_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003877 /* MV88E6XXX_FAMILY_6185 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04003878 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
3879 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04003880 .set_switch_mac = mv88e6xxx_g1_set_switch_mac,
Vivien Didelot7e20cfb2017-05-26 18:03:06 -04003881 .phy_read = mv88e6185_phy_ppu_read,
3882 .phy_write = mv88e6185_phy_ppu_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01003883 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00003884 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003885 .port_set_frame_mode = mv88e6085_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003886 .port_set_egress_floods = mv88e6185_port_set_egress_floods,
Andrew Lunnef70b112016-12-03 04:45:18 +01003887 .port_egress_rate_limiting = mv88e6095_port_egress_rate_limiting,
Andrew Lunna23b2962017-02-04 20:15:28 +01003888 .port_set_upstream_port = mv88e6095_port_set_upstream_port,
Andrew Lunn54186b92018-08-09 15:38:37 +02003889 .port_set_pause = mv88e6185_port_set_pause,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003890 .port_get_cmode = mv88e6185_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003891 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01003892 .stats_snapshot = mv88e6xxx_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01003893 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003894 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
3895 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01003896 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003897 .set_cpu_port = mv88e6095_g1_set_cpu_port,
3898 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01003899 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04003900 .mgmt_rsvd2cpu = mv88e6185_g2_mgmt_rsvd2cpu,
Vivien Didelot02317e62018-05-09 11:38:49 -04003901 .set_cascade_port = mv88e6185_g1_set_cascade_port,
Vivien Didelota199d8b2016-12-05 17:30:28 -05003902 .ppu_enable = mv88e6185_g1_ppu_enable,
3903 .ppu_disable = mv88e6185_g1_ppu_disable,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003904 .reset = mv88e6185_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04003905 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04003906 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02003907 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04003908};
3909
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003910static const struct mv88e6xxx_ops mv88e6190_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003911 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003912 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003913 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003914 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3915 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003916 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3917 .phy_read = mv88e6xxx_g2_smi_phy_read,
3918 .phy_write = mv88e6xxx_g2_smi_phy_write,
3919 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003920 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003921 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003922 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003923 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003924 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003925 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003926 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003927 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003928 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003929 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003930 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003931 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003932 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003933 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003934 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003935 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003936 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3937 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003938 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003939 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3940 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01003941 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01003942 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04003943 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05003944 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04003945 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02003946 .atu_get_hash = mv88e6165_g1_atu_get_hash,
3947 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04003948 .vtu_getnext = mv88e6390_g1_vtu_getnext,
3949 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02003950 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02003951 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00003952 /* Check status register pause & lpa register */
3953 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
3954 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
3955 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
3956 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04003957 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04003958 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04003959 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01003960 .serdes_get_strings = mv88e6390_serdes_get_strings,
3961 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01003962 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
3963 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01003964 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01003965 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02003966 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003967};
3968
3969static const struct mv88e6xxx_ops mv88e6190x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01003970 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01003971 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04003972 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05003973 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
3974 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003975 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
3976 .phy_read = mv88e6xxx_g2_smi_phy_read,
3977 .phy_write = mv88e6xxx_g2_smi_phy_write,
3978 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01003979 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00003980 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01003981 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01003982 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04003983 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003984 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05003985 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01003986 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04003987 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05003988 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05003989 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02003990 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01003991 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02003992 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01003993 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01003994 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01003995 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
3996 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01003997 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04003998 .set_cpu_port = mv88e6390_g1_set_cpu_port,
3999 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004000 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004001 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004002 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004003 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004004 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004005 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4006 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004007 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4008 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004009 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004010 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004011 /* Check status register pause & lpa register */
4012 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4013 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4014 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4015 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004016 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004017 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004018 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004019 .serdes_get_strings = mv88e6390_serdes_get_strings,
4020 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004021 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4022 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004023 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004024 .gpio_ops = &mv88e6352_gpio_ops,
Russell King6c422e32018-08-09 15:38:39 +02004025 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004026};
4027
4028static const struct mv88e6xxx_ops mv88e6191_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004029 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004030 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004031 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004032 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4033 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004034 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4035 .phy_read = mv88e6xxx_g2_smi_phy_read,
4036 .phy_write = mv88e6xxx_g2_smi_phy_write,
4037 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004038 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004039 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004040 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004041 .port_tag_remap = mv88e6390_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004042 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004043 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004044 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004045 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004046 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004047 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004048 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004049 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004050 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004051 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004052 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004053 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4054 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004055 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004056 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4057 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004058 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004059 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004060 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004061 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004062 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004063 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4064 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004065 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4066 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004067 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004068 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004069 /* Check status register pause & lpa register */
4070 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4071 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4072 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4073 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004074 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004075 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004076 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004077 .serdes_get_strings = mv88e6390_serdes_get_strings,
4078 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004079 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4080 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004081 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004082 .avb_ops = &mv88e6390_avb_ops,
4083 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004084 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004085};
4086
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004087static const struct mv88e6xxx_ops mv88e6240_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004088 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004089 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4090 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004091 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004092 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4093 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004094 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004095 .phy_read = mv88e6xxx_g2_smi_phy_read,
4096 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004097 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004098 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004099 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004100 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004101 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004102 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004103 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004104 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004105 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004106 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004107 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004108 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004109 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004110 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004111 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004112 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004113 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004114 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4115 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004116 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004117 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4118 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004119 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004120 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004121 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004122 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004123 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004124 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4125 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004126 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004127 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004128 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004129 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4130 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4131 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4132 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004133 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004134 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004135 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004136 .serdes_irq_status = mv88e6352_serdes_irq_status,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004137 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4138 .serdes_get_regs = mv88e6352_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004139 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004140 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004141 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004142 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004143};
4144
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004145static const struct mv88e6xxx_ops mv88e6250_ops = {
4146 /* MV88E6XXX_FAMILY_6250 */
4147 .ieee_pri_map = mv88e6250_g1_ieee_pri_map,
4148 .ip_pri_map = mv88e6085_g1_ip_pri_map,
4149 .irl_init_all = mv88e6352_g2_irl_init_all,
4150 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4151 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
4152 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4153 .phy_read = mv88e6xxx_g2_smi_phy_read,
4154 .phy_write = mv88e6xxx_g2_smi_phy_write,
4155 .port_set_link = mv88e6xxx_port_set_link,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004156 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004157 .port_set_speed_duplex = mv88e6250_port_set_speed_duplex,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004158 .port_tag_remap = mv88e6095_port_tag_remap,
4159 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4160 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4161 .port_set_ether_type = mv88e6351_port_set_ether_type,
4162 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
4163 .port_pause_limit = mv88e6097_port_pause_limit,
4164 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004165 .stats_snapshot = mv88e6320_g1_stats_snapshot,
4166 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
4167 .stats_get_sset_count = mv88e6250_stats_get_sset_count,
4168 .stats_get_strings = mv88e6250_stats_get_strings,
4169 .stats_get_stats = mv88e6250_stats_get_stats,
4170 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4171 .set_egress_port = mv88e6095_g1_set_egress_port,
4172 .watchdog_ops = &mv88e6250_watchdog_ops,
4173 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
4174 .pot_clear = mv88e6xxx_g2_pot_clear,
4175 .reset = mv88e6250_g1_reset,
4176 .vtu_getnext = mv88e6250_g1_vtu_getnext,
4177 .vtu_loadpurge = mv88e6250_g1_vtu_loadpurge,
Hubert Feurstein71509612019-07-31 10:23:51 +02004178 .avb_ops = &mv88e6352_avb_ops,
4179 .ptp_ops = &mv88e6250_ptp_ops,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00004180 .phylink_validate = mv88e6065_phylink_validate,
4181};
4182
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004183static const struct mv88e6xxx_ops mv88e6290_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004184 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004185 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004186 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004187 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4188 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004189 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4190 .phy_read = mv88e6xxx_g2_smi_phy_read,
4191 .phy_write = mv88e6xxx_g2_smi_phy_write,
4192 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004193 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004194 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004195 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004196 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004197 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004198 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004199 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004200 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelot08984322017-06-08 18:34:12 -04004201 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004202 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004203 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004204 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004205 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004206 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004207 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004208 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004209 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4210 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004211 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004212 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4213 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004214 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004215 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004216 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004217 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004218 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004219 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4220 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004221 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4222 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004223 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004224 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004225 /* Check status register pause & lpa register */
4226 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4227 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4228 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4229 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004230 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004231 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004232 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004233 .serdes_get_strings = mv88e6390_serdes_get_strings,
4234 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004235 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4236 .serdes_get_regs = mv88e6390_serdes_get_regs,
Andrew Lunn4262c382020-01-18 19:40:56 +01004237 .phylink_validate = mv88e6390_phylink_validate,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004238 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004239 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004240 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004241 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004242};
4243
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004244static const struct mv88e6xxx_ops mv88e6320_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004245 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004246 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4247 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004248 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004249 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4250 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004251 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004252 .phy_read = mv88e6xxx_g2_smi_phy_read,
4253 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004254 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004255 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004256 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004257 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004258 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004259 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004260 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004261 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004262 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004263 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004264 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004265 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004266 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004267 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004268 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004269 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4270 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004271 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004272 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4273 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004274 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004275 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004276 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004277 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004278 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004279 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004280 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004281 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004282 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004283 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004284};
4285
4286static const struct mv88e6xxx_ops mv88e6321_ops = {
Vivien Didelotbd807202017-07-17 13:03:37 -04004287 /* MV88E6XXX_FAMILY_6320 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004288 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4289 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004290 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004291 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4292 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004293 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004294 .phy_read = mv88e6xxx_g2_smi_phy_read,
4295 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004296 .port_set_link = mv88e6xxx_port_set_link,
Russell Kingf365c6f2020-03-14 10:15:53 +00004297 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004298 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004299 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004300 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004301 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004302 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004303 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004304 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004305 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004306 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004307 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004308 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004309 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004310 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004311 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4312 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004313 .stats_get_stats = mv88e6320_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004314 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4315 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunn9c7f37e2018-12-19 18:28:54 +01004316 .watchdog_ops = &mv88e6390_watchdog_ops,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004317 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004318 .vtu_getnext = mv88e6185_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004319 .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004320 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004321 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004322 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004323 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004324};
4325
Vivien Didelot16e329a2017-03-28 13:50:33 -04004326static const struct mv88e6xxx_ops mv88e6341_ops = {
4327 /* MV88E6XXX_FAMILY_6341 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004328 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4329 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004330 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004331 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4332 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
4333 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4334 .phy_read = mv88e6xxx_g2_smi_phy_read,
4335 .phy_write = mv88e6xxx_g2_smi_phy_write,
4336 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004337 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004338 .port_set_speed_duplex = mv88e6341_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004339 .port_max_speed_mode = mv88e6341_port_max_speed_mode,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004340 .port_tag_remap = mv88e6095_port_tag_remap,
4341 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
4342 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
4343 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004344 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004345 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004346 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004347 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
4348 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004349 .port_get_cmode = mv88e6352_port_get_cmode,
Marek Behún7a3007d2019-08-26 23:31:55 +02004350 .port_set_cmode = mv88e6341_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004351 .port_setup_message_port = mv88e6xxx_setup_message_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004352 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004353 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004354 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4355 .stats_get_strings = mv88e6320_stats_get_strings,
4356 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004357 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4358 .set_egress_port = mv88e6390_g1_set_egress_port,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004359 .watchdog_ops = &mv88e6390_watchdog_ops,
4360 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004361 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004362 .reset = mv88e6352_g1_reset,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004363 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004364 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004365 .serdes_power = mv88e6390_serdes_power,
4366 .serdes_get_lane = mv88e6341_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004367 /* Check status register pause & lpa register */
4368 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4369 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4370 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4371 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004372 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004373 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004374 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004375 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004376 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004377 .ptp_ops = &mv88e6352_ptp_ops,
Marek Behúne3af71a2019-02-25 12:39:55 +01004378 .phylink_validate = mv88e6341_phylink_validate,
Vivien Didelot16e329a2017-03-28 13:50:33 -04004379};
4380
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004381static const struct mv88e6xxx_ops mv88e6350_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004382 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004383 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4384 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004385 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004386 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004387 .phy_read = mv88e6xxx_g2_smi_phy_read,
4388 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004389 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004390 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004391 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004392 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004393 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004394 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004395 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004396 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004397 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004398 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004399 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004400 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004401 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004402 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004403 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004404 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004405 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4406 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004407 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004408 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4409 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004410 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004411 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004412 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004413 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004414 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4415 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004416 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004417 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Russell King6c422e32018-08-09 15:38:39 +02004418 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004419};
4420
4421static const struct mv88e6xxx_ops mv88e6351_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004422 /* MV88E6XXX_FAMILY_6351 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004423 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4424 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004425 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004426 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004427 .phy_read = mv88e6xxx_g2_smi_phy_read,
4428 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004429 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn94d66ae2016-11-10 15:44:01 +01004430 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004431 .port_set_speed_duplex = mv88e6185_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004432 .port_tag_remap = mv88e6095_port_tag_remap,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004433 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004434 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004435 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004436 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004437 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004438 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004439 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004440 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004441 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004442 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004443 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004444 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004445 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4446 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004447 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004448 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4449 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004450 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004451 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004452 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004453 .reset = mv88e6352_g1_reset,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004454 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4455 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004456 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004457 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004458 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004459 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004460 .phylink_validate = mv88e6185_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004461};
4462
4463static const struct mv88e6xxx_ops mv88e6352_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004464 /* MV88E6XXX_FAMILY_6352 */
Vivien Didelot93e18d62018-05-11 17:16:35 -04004465 .ieee_pri_map = mv88e6085_g1_ieee_pri_map,
4466 .ip_pri_map = mv88e6085_g1_ip_pri_map,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004467 .irl_init_all = mv88e6352_g2_irl_init_all,
Vivien Didelotee4dc2e72016-09-29 12:22:02 -04004468 .get_eeprom = mv88e6xxx_g2_get_eeprom16,
4469 .set_eeprom = mv88e6xxx_g2_set_eeprom16,
Vivien Didelotb073d4e2016-09-29 12:22:01 -04004470 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004471 .phy_read = mv88e6xxx_g2_smi_phy_read,
4472 .phy_write = mv88e6xxx_g2_smi_phy_write,
Vivien Didelot08ef7f12016-11-04 03:23:32 +01004473 .port_set_link = mv88e6xxx_port_set_link,
Vivien Didelota0a0f622016-11-04 03:23:34 +01004474 .port_set_rgmii_delay = mv88e6352_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004475 .port_set_speed_duplex = mv88e6352_port_set_speed_duplex,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004476 .port_tag_remap = mv88e6095_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004477 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004478 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004479 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004480 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004481 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004482 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004483 .port_pause_limit = mv88e6097_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004484 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004485 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004486 .port_get_cmode = mv88e6352_port_get_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004487 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunna605a0f2016-11-21 23:26:58 +01004488 .stats_snapshot = mv88e6320_g1_stats_snapshot,
Andrew Lunn40cff8f2017-11-10 00:36:41 +01004489 .stats_set_histogram = mv88e6095_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004490 .stats_get_sset_count = mv88e6095_stats_get_sset_count,
4491 .stats_get_strings = mv88e6095_stats_get_strings,
Andrew Lunn052f9472016-11-21 23:27:03 +01004492 .stats_get_stats = mv88e6095_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004493 .set_cpu_port = mv88e6095_g1_set_cpu_port,
4494 .set_egress_port = mv88e6095_g1_set_egress_port,
Andrew Lunnfcd25162017-02-09 00:03:42 +01004495 .watchdog_ops = &mv88e6097_watchdog_ops,
Vivien Didelot51c901a2017-07-17 13:03:41 -04004496 .mgmt_rsvd2cpu = mv88e6352_g2_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004497 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004498 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004499 .rmu_disable = mv88e6352_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004500 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4501 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelotf1394b782017-05-01 14:05:22 -04004502 .vtu_getnext = mv88e6352_g1_vtu_getnext,
Vivien Didelot0ad5daf2017-05-01 14:05:23 -04004503 .vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
Vivien Didelot9db4a722019-08-31 16:18:31 -04004504 .serdes_get_lane = mv88e6352_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004505 .serdes_pcs_get_state = mv88e6352_serdes_pcs_get_state,
4506 .serdes_pcs_config = mv88e6352_serdes_pcs_config,
4507 .serdes_pcs_an_restart = mv88e6352_serdes_pcs_an_restart,
4508 .serdes_pcs_link_up = mv88e6352_serdes_pcs_link_up,
Andrew Lunn6d917822017-05-26 01:03:21 +02004509 .serdes_power = mv88e6352_serdes_power,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004510 .serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004511 .serdes_irq_enable = mv88e6352_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004512 .serdes_irq_status = mv88e6352_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004513 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004514 .avb_ops = &mv88e6352_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004515 .ptp_ops = &mv88e6352_ptp_ops,
Andrew Lunncda9f4a2018-03-01 02:02:31 +01004516 .serdes_get_sset_count = mv88e6352_serdes_get_sset_count,
4517 .serdes_get_strings = mv88e6352_serdes_get_strings,
4518 .serdes_get_stats = mv88e6352_serdes_get_stats,
Andrew Lunnd3f88a22020-02-16 18:54:14 +01004519 .serdes_get_regs_len = mv88e6352_serdes_get_regs_len,
4520 .serdes_get_regs = mv88e6352_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004521 .phylink_validate = mv88e6352_phylink_validate,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004522};
4523
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004524static const struct mv88e6xxx_ops mv88e6390_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004525 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004526 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004527 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004528 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4529 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004530 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4531 .phy_read = mv88e6xxx_g2_smi_phy_read,
4532 .phy_write = mv88e6xxx_g2_smi_phy_write,
4533 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004534 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004535 .port_set_speed_duplex = mv88e6390_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004536 .port_max_speed_mode = mv88e6390_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004537 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004538 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004539 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004540 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004541 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004542 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004543 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004544 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004545 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004546 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004547 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnfdc71ee2018-11-11 00:32:15 +01004548 .port_set_cmode = mv88e6390_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004549 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004550 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004551 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004552 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4553 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004554 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004555 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4556 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004557 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004558 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004559 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004560 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004561 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004562 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4563 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004564 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4565 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Andrew Lunn6335e9f2017-05-26 01:03:23 +02004566 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004567 .serdes_get_lane = mv88e6390_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004568 /* Check status register pause & lpa register */
4569 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4570 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4571 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4572 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004573 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004574 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004575 .serdes_irq_status = mv88e6390_serdes_irq_status,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004576 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004577 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004578 .ptp_ops = &mv88e6352_ptp_ops,
Nikita Yushchenko0df95282019-12-25 08:22:38 +03004579 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4580 .serdes_get_strings = mv88e6390_serdes_get_strings,
4581 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004582 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4583 .serdes_get_regs = mv88e6390_serdes_get_regs,
Russell King6c422e32018-08-09 15:38:39 +02004584 .phylink_validate = mv88e6390_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004585};
4586
4587static const struct mv88e6xxx_ops mv88e6390x_ops = {
Andrew Lunn4b325d82016-11-21 23:26:59 +01004588 /* MV88E6XXX_FAMILY_6390 */
Andrew Lunnea890982019-01-09 00:24:03 +01004589 .setup_errata = mv88e6390_setup_errata,
Vivien Didelotcd8da8b2017-06-19 10:55:36 -04004590 .irl_init_all = mv88e6390_g2_irl_init_all,
Vivien Didelot98fc3c62017-01-12 18:07:16 -05004591 .get_eeprom = mv88e6xxx_g2_get_eeprom8,
4592 .set_eeprom = mv88e6xxx_g2_set_eeprom8,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004593 .set_switch_mac = mv88e6xxx_g2_set_switch_mac,
4594 .phy_read = mv88e6xxx_g2_smi_phy_read,
4595 .phy_write = mv88e6xxx_g2_smi_phy_write,
4596 .port_set_link = mv88e6xxx_port_set_link,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004597 .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
Russell Kingf365c6f2020-03-14 10:15:53 +00004598 .port_set_speed_duplex = mv88e6390x_port_set_speed_duplex,
Andrew Lunn7cbbee02019-03-08 01:21:27 +01004599 .port_max_speed_mode = mv88e6390x_port_max_speed_mode,
Andrew Lunnef0a7312016-12-03 04:35:16 +01004600 .port_tag_remap = mv88e6390_port_tag_remap,
Vivien Didelotf3a2cd32019-09-07 16:00:48 -04004601 .port_set_policy = mv88e6352_port_set_policy,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004602 .port_set_frame_mode = mv88e6351_port_set_frame_mode,
Vivien Didelot601aeed2017-03-11 16:13:00 -05004603 .port_set_egress_floods = mv88e6352_port_set_egress_floods,
Andrew Lunn56995cb2016-12-03 04:35:19 +01004604 .port_set_ether_type = mv88e6351_port_set_ether_type,
Vivien Didelotcd782652017-06-08 18:34:13 -04004605 .port_set_jumbo_size = mv88e6165_port_set_jumbo_size,
Andrew Lunnef70b112016-12-03 04:45:18 +01004606 .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting,
Vivien Didelot08984322017-06-08 18:34:12 -04004607 .port_pause_limit = mv88e6390_port_pause_limit,
Vivien Didelotc8c94892017-03-11 16:13:01 -05004608 .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit,
Vivien Didelot9dbfb4e2017-03-11 16:13:02 -05004609 .port_disable_pri_override = mv88e6xxx_port_disable_pri_override,
Andrew Lunn2d2e1dd2018-08-09 15:38:45 +02004610 .port_get_cmode = mv88e6352_port_get_cmode,
Andrew Lunnb3dce4d2018-11-11 00:32:14 +01004611 .port_set_cmode = mv88e6390x_port_set_cmode,
Hubert Feurstein121b8fe2019-07-31 10:23:49 +02004612 .port_setup_message_port = mv88e6xxx_setup_message_port,
Andrew Lunn79523472016-11-21 23:27:00 +01004613 .stats_snapshot = mv88e6390_g1_stats_snapshot,
Andrew Lunnde2273872016-11-21 23:27:01 +01004614 .stats_set_histogram = mv88e6390_g1_stats_set_histogram,
Andrew Lunndfafe442016-11-21 23:27:02 +01004615 .stats_get_sset_count = mv88e6320_stats_get_sset_count,
4616 .stats_get_strings = mv88e6320_stats_get_strings,
Andrew Lunne0d8b612016-11-21 23:27:04 +01004617 .stats_get_stats = mv88e6390_stats_get_stats,
Vivien Didelotfa8d1172017-06-08 18:34:11 -04004618 .set_cpu_port = mv88e6390_g1_set_cpu_port,
4619 .set_egress_port = mv88e6390_g1_set_egress_port,
Andrew Lunn61303732017-02-09 00:03:43 +01004620 .watchdog_ops = &mv88e6390_watchdog_ops,
Andrew Lunn6e55f692016-12-03 04:45:16 +01004621 .mgmt_rsvd2cpu = mv88e6390_g1_mgmt_rsvd2cpu,
Vivien Didelot9e907d72017-07-17 13:03:43 -04004622 .pot_clear = mv88e6xxx_g2_pot_clear,
Vivien Didelot17e708b2016-12-05 17:30:27 -05004623 .reset = mv88e6352_g1_reset,
Vivien Didelot9e5baf92018-05-09 11:38:51 -04004624 .rmu_disable = mv88e6390_g1_rmu_disable,
Andrew Lunn23e8b472019-10-25 01:03:52 +02004625 .atu_get_hash = mv88e6165_g1_atu_get_hash,
4626 .atu_set_hash = mv88e6165_g1_atu_set_hash,
Vivien Didelot931d1822017-05-01 14:05:27 -04004627 .vtu_getnext = mv88e6390_g1_vtu_getnext,
4628 .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge,
Marek Behúnd3cf7d82019-08-26 23:31:53 +02004629 .serdes_power = mv88e6390_serdes_power,
Marek Behún17deaf52019-08-26 23:31:52 +02004630 .serdes_get_lane = mv88e6390x_serdes_get_lane,
Russell Kinga5a68582020-03-14 10:15:43 +00004631 .serdes_pcs_get_state = mv88e6390_serdes_pcs_get_state,
4632 .serdes_pcs_config = mv88e6390_serdes_pcs_config,
4633 .serdes_pcs_an_restart = mv88e6390_serdes_pcs_an_restart,
4634 .serdes_pcs_link_up = mv88e6390_serdes_pcs_link_up,
Vivien Didelot4241ef52019-08-31 16:18:29 -04004635 .serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
Vivien Didelot61a46b42019-08-31 16:18:34 -04004636 .serdes_irq_enable = mv88e6390_serdes_irq_enable,
Vivien Didelot907b9b92019-08-31 16:18:35 -04004637 .serdes_irq_status = mv88e6390_serdes_irq_status,
Andrew Lunn4262c382020-01-18 19:40:56 +01004638 .serdes_get_sset_count = mv88e6390_serdes_get_sset_count,
4639 .serdes_get_strings = mv88e6390_serdes_get_strings,
4640 .serdes_get_stats = mv88e6390_serdes_get_stats,
Andrew Lunnbf3504c2020-02-16 18:54:15 +01004641 .serdes_get_regs_len = mv88e6390_serdes_get_regs_len,
4642 .serdes_get_regs = mv88e6390_serdes_get_regs,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004643 .gpio_ops = &mv88e6352_gpio_ops,
Brandon Streiff0d632c32018-02-14 01:07:44 +01004644 .avb_ops = &mv88e6390_avb_ops,
Andrew Lunn6d2ac8e2018-07-18 22:38:20 +02004645 .ptp_ops = &mv88e6352_ptp_ops,
Russell King6c422e32018-08-09 15:38:39 +02004646 .phylink_validate = mv88e6390x_phylink_validate,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004647};
4648
Vivien Didelotf81ec902016-05-09 13:22:58 -04004649static const struct mv88e6xxx_info mv88e6xxx_table[] = {
4650 [MV88E6085] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004651 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6085,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004652 .family = MV88E6XXX_FAMILY_6097,
4653 .name = "Marvell 88E6085",
4654 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004655 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004656 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004657 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004658 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004659 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004660 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004661 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004662 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004663 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004664 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004665 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004666 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004667 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004668 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004669 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004670 .ops = &mv88e6085_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004671 },
4672
4673 [MV88E6095] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004674 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6095,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004675 .family = MV88E6XXX_FAMILY_6095,
4676 .name = "Marvell 88E6095/88E6095F",
4677 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004678 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004679 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004680 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004681 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004682 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004683 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004684 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004685 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004686 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004687 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004688 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004689 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004690 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004691 .ops = &mv88e6095_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004692 },
4693
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004694 [MV88E6097] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004695 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6097,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004696 .family = MV88E6XXX_FAMILY_6097,
4697 .name = "Marvell 88E6097/88E6097F",
4698 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004699 .num_macs = 8192,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004700 .num_ports = 11,
Andrew Lunnbc393152018-03-17 20:32:04 +01004701 .num_internal_phys = 8,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004702 .max_vid = 4095,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004703 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004704 .phy_base_addr = 0x0,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004705 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004706 .global2_addr = 0x1c,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004707 .age_time_coeff = 15000,
Stefan Eichenbergerc5341782016-11-25 09:41:29 +01004708 .g1_irqs = 8,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004709 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004710 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004711 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004712 .multi_chip = true,
Stefan Eichenberger2bfcfcd2016-12-05 14:12:42 +01004713 .tag_protocol = DSA_TAG_PROTO_EDSA,
Stefan Eichenberger7d381a02016-11-22 17:47:21 +01004714 .ops = &mv88e6097_ops,
4715 },
4716
Vivien Didelotf81ec902016-05-09 13:22:58 -04004717 [MV88E6123] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004718 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6123,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004719 .family = MV88E6XXX_FAMILY_6165,
4720 .name = "Marvell 88E6123",
4721 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004722 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004723 .num_ports = 3,
Andrew Lunnbc393152018-03-17 20:32:04 +01004724 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004725 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004726 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004727 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004728 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004729 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004730 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004731 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004732 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004733 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004734 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004735 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004736 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004737 .ops = &mv88e6123_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004738 },
4739
4740 [MV88E6131] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004741 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6131,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004742 .family = MV88E6XXX_FAMILY_6185,
4743 .name = "Marvell 88E6131",
4744 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004745 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004746 .num_ports = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01004747 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004748 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004749 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004750 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004751 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004752 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004753 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004754 .g1_irqs = 9,
Vivien Didelote606ca32017-03-11 16:12:55 -05004755 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004756 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004757 .tag_protocol = DSA_TAG_PROTO_DSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004758 .ops = &mv88e6131_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004759 },
4760
Vivien Didelot990e27b2017-03-28 13:50:32 -04004761 [MV88E6141] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004762 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6141,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004763 .family = MV88E6XXX_FAMILY_6341,
Uwe Kleine-König79a68b22018-03-20 10:44:40 +01004764 .name = "Marvell 88E6141",
Vivien Didelot990e27b2017-03-28 13:50:32 -04004765 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004766 .num_macs = 2048,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004767 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004768 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004769 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004770 .max_vid = 4095,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004771 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004772 .phy_base_addr = 0x10,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004773 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004774 .global2_addr = 0x1c,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004775 .age_time_coeff = 3750,
4776 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01004777 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004778 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04004779 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004780 .multi_chip = true,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004781 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelot990e27b2017-03-28 13:50:32 -04004782 .ops = &mv88e6141_ops,
4783 },
4784
Vivien Didelotf81ec902016-05-09 13:22:58 -04004785 [MV88E6161] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004786 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6161,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004787 .family = MV88E6XXX_FAMILY_6165,
4788 .name = "Marvell 88E6161",
4789 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004790 .num_macs = 1024,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004791 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004792 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004793 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004794 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004795 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004796 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004797 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004798 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004799 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004800 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004801 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004802 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004803 .multi_chip = true,
Andrew Lunn5ebe31d2017-06-07 15:06:19 +02004804 .tag_protocol = DSA_TAG_PROTO_EDSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004805 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004806 .ops = &mv88e6161_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004807 },
4808
4809 [MV88E6165] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004810 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6165,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004811 .family = MV88E6XXX_FAMILY_6165,
4812 .name = "Marvell 88E6165",
4813 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004814 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004815 .num_ports = 6,
Andrew Lunnbc393152018-03-17 20:32:04 +01004816 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004817 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004818 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004819 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004820 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004821 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004822 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004823 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004824 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004825 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004826 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004827 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004828 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunndfa54342018-07-18 22:38:22 +02004829 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004830 .ops = &mv88e6165_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004831 },
4832
4833 [MV88E6171] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004834 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6171,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004835 .family = MV88E6XXX_FAMILY_6351,
4836 .name = "Marvell 88E6171",
4837 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004838 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004839 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004840 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004841 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004842 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004843 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004844 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004845 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004846 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004847 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004848 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004849 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004850 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004851 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004852 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004853 .ops = &mv88e6171_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004854 },
4855
4856 [MV88E6172] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004857 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6172,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004858 .family = MV88E6XXX_FAMILY_6352,
4859 .name = "Marvell 88E6172",
4860 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004861 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004862 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004863 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004864 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004865 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004866 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004867 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004868 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004869 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004870 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004871 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004872 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004873 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004874 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004875 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004876 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004877 .ops = &mv88e6172_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004878 },
4879
4880 [MV88E6175] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004881 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6175,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004882 .family = MV88E6XXX_FAMILY_6351,
4883 .name = "Marvell 88E6175",
4884 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004885 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004886 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004887 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004888 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004889 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004890 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004891 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004892 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004893 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004894 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004895 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004896 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004897 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004898 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004899 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004900 .ops = &mv88e6175_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004901 },
4902
4903 [MV88E6176] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004904 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6176,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004905 .family = MV88E6XXX_FAMILY_6352,
4906 .name = "Marvell 88E6176",
4907 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004908 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004909 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01004910 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004911 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004912 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004913 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004914 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004915 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004916 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004917 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004918 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004919 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05004920 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04004921 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004922 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004923 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004924 .ops = &mv88e6176_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004925 },
4926
4927 [MV88E6185] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004928 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6185,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004929 .family = MV88E6XXX_FAMILY_6185,
4930 .name = "Marvell 88E6185",
4931 .num_databases = 256,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004932 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004933 .num_ports = 10,
Andrew Lunnbc393152018-03-17 20:32:04 +01004934 .num_internal_phys = 0,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04004935 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04004936 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004937 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04004938 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004939 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04004940 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02004941 .g1_irqs = 8,
Vivien Didelote606ca32017-03-11 16:12:55 -05004942 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004943 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004944 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04004945 .ops = &mv88e6185_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04004946 },
4947
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004948 [MV88E6190] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004949 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004950 .family = MV88E6XXX_FAMILY_6390,
4951 .name = "Marvell 88E6190",
4952 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004953 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004954 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004955 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004956 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004957 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004958 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004959 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004960 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004961 .global2_addr = 0x1c,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004962 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004963 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004964 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004965 .g2_irqs = 14,
Vivien Didelotf3645652017-03-30 17:37:07 -04004966 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004967 .multi_chip = true,
Vivien Didelote606ca32017-03-11 16:12:55 -05004968 .atu_move_port_mask = 0x1f,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004969 .ops = &mv88e6190_ops,
4970 },
4971
4972 [MV88E6190X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004973 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6190X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004974 .family = MV88E6XXX_FAMILY_6390,
4975 .name = "Marvell 88E6190X",
4976 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01004977 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004978 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01004979 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01004980 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04004981 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004982 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02004983 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004984 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04004985 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01004986 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004987 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04004988 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05004989 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04004990 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04004991 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01004992 .tag_protocol = DSA_TAG_PROTO_DSA,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004993 .ops = &mv88e6190x_ops,
4994 },
4995
4996 [MV88E6191] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04004997 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01004998 .family = MV88E6XXX_FAMILY_6390,
4999 .name = "Marvell 88E6191",
5000 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005001 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005002 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005003 .num_internal_phys = 9,
Vivien Didelot931d1822017-05-01 14:05:27 -04005004 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005005 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005006 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005007 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005008 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005009 .age_time_coeff = 3750,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005010 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005011 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005012 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005013 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005014 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005015 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005016 .ptp_support = true,
Vivien Didelot2cf4cefb2017-03-28 13:50:34 -04005017 .ops = &mv88e6191_ops,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005018 },
5019
Hubert Feurstein49022642019-07-31 10:23:46 +02005020 [MV88E6220] = {
5021 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6220,
5022 .family = MV88E6XXX_FAMILY_6250,
5023 .name = "Marvell 88E6220",
5024 .num_databases = 64,
5025
5026 /* Ports 2-4 are not routed to pins
5027 * => usable ports 0, 1, 5, 6
5028 */
5029 .num_ports = 7,
5030 .num_internal_phys = 2,
Hubert Feursteinc8574862019-07-31 10:23:48 +02005031 .invalid_port_mask = BIT(2) | BIT(3) | BIT(4),
Hubert Feurstein49022642019-07-31 10:23:46 +02005032 .max_vid = 4095,
5033 .port_base_addr = 0x08,
5034 .phy_base_addr = 0x00,
5035 .global1_addr = 0x0f,
5036 .global2_addr = 0x07,
5037 .age_time_coeff = 15000,
5038 .g1_irqs = 9,
5039 .g2_irqs = 10,
5040 .atu_move_port_mask = 0xf,
5041 .dual_chip = true,
5042 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005043 .ptp_support = true,
Hubert Feurstein49022642019-07-31 10:23:46 +02005044 .ops = &mv88e6250_ops,
5045 },
5046
Vivien Didelotf81ec902016-05-09 13:22:58 -04005047 [MV88E6240] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005048 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6240,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005049 .family = MV88E6XXX_FAMILY_6352,
5050 .name = "Marvell 88E6240",
5051 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005052 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005053 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005054 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005055 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005056 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005057 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005058 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005059 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005060 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005061 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005062 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005063 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005064 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005065 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005066 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005067 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005068 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005069 .ops = &mv88e6240_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005070 },
5071
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005072 [MV88E6250] = {
5073 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6250,
5074 .family = MV88E6XXX_FAMILY_6250,
5075 .name = "Marvell 88E6250",
5076 .num_databases = 64,
5077 .num_ports = 7,
5078 .num_internal_phys = 5,
5079 .max_vid = 4095,
5080 .port_base_addr = 0x08,
5081 .phy_base_addr = 0x00,
5082 .global1_addr = 0x0f,
5083 .global2_addr = 0x07,
5084 .age_time_coeff = 15000,
5085 .g1_irqs = 9,
5086 .g2_irqs = 10,
5087 .atu_move_port_mask = 0xf,
5088 .dual_chip = true,
5089 .tag_protocol = DSA_TAG_PROTO_DSA,
Hubert Feurstein71509612019-07-31 10:23:51 +02005090 .ptp_support = true,
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005091 .ops = &mv88e6250_ops,
5092 },
5093
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005094 [MV88E6290] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005095 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6290,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005096 .family = MV88E6XXX_FAMILY_6390,
5097 .name = "Marvell 88E6290",
5098 .num_databases = 4096,
5099 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005100 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005101 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005102 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005103 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005104 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005105 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005106 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005107 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005108 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005109 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005110 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005111 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005112 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005113 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005114 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005115 .ops = &mv88e6290_ops,
5116 },
5117
Vivien Didelotf81ec902016-05-09 13:22:58 -04005118 [MV88E6320] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005119 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6320,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005120 .family = MV88E6XXX_FAMILY_6320,
5121 .name = "Marvell 88E6320",
5122 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005123 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005124 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005125 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005126 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005127 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005128 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005129 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005130 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005131 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005132 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005133 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005134 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005135 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005136 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005137 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005138 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005139 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005140 .ops = &mv88e6320_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005141 },
5142
5143 [MV88E6321] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005144 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6321,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005145 .family = MV88E6XXX_FAMILY_6320,
5146 .name = "Marvell 88E6321",
5147 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005148 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005149 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005150 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005151 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005152 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005153 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005154 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005155 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005156 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005157 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005158 .g1_irqs = 8,
Andrew Lunnbc393152018-03-17 20:32:04 +01005159 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005160 .atu_move_port_mask = 0xf,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005161 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005162 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005163 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005164 .ops = &mv88e6321_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005165 },
5166
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005167 [MV88E6341] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005168 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6341,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005169 .family = MV88E6XXX_FAMILY_6341,
5170 .name = "Marvell 88E6341",
5171 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005172 .num_macs = 2048,
Andrew Lunnbc393152018-03-17 20:32:04 +01005173 .num_internal_phys = 5,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005174 .num_ports = 6,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005175 .num_gpio = 11,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005176 .max_vid = 4095,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005177 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005178 .phy_base_addr = 0x10,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005179 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005180 .global2_addr = 0x1c,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005181 .age_time_coeff = 3750,
Vivien Didelote606ca32017-03-11 16:12:55 -05005182 .atu_move_port_mask = 0x1f,
Andrew Lunnadfccf12018-03-17 20:32:03 +01005183 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005184 .g2_irqs = 10,
Vivien Didelotf3645652017-03-30 17:37:07 -04005185 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005186 .multi_chip = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005187 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005188 .ptp_support = true,
Gregory CLEMENTa75961d2017-01-30 20:29:34 +01005189 .ops = &mv88e6341_ops,
5190 },
5191
Vivien Didelotf81ec902016-05-09 13:22:58 -04005192 [MV88E6350] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005193 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6350,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005194 .family = MV88E6XXX_FAMILY_6351,
5195 .name = "Marvell 88E6350",
5196 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005197 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005198 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005199 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005200 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005201 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005202 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005203 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005204 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005205 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005206 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005207 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005208 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005209 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005210 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005211 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005212 .ops = &mv88e6350_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005213 },
5214
5215 [MV88E6351] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005216 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6351,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005217 .family = MV88E6XXX_FAMILY_6351,
5218 .name = "Marvell 88E6351",
5219 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005220 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005221 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005222 .num_internal_phys = 5,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005223 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005224 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005225 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005226 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005227 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005228 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005229 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005230 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005231 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005232 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005233 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005234 .tag_protocol = DSA_TAG_PROTO_EDSA,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005235 .ops = &mv88e6351_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005236 },
5237
5238 [MV88E6352] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005239 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6352,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005240 .family = MV88E6XXX_FAMILY_6352,
5241 .name = "Marvell 88E6352",
5242 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005243 .num_macs = 8192,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005244 .num_ports = 7,
Andrew Lunnbc393152018-03-17 20:32:04 +01005245 .num_internal_phys = 5,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005246 .num_gpio = 15,
Vivien Didelot3cf3c842017-05-01 14:05:10 -04005247 .max_vid = 4095,
Vivien Didelot9dddd472016-06-20 13:14:10 -04005248 .port_base_addr = 0x10,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005249 .phy_base_addr = 0x0,
Vivien Didelota935c052016-09-29 12:21:53 -04005250 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005251 .global2_addr = 0x1c,
Vivien Didelotacddbd22016-07-18 20:45:39 -04005252 .age_time_coeff = 15000,
Andrew Lunndc30c352016-10-16 19:56:49 +02005253 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005254 .g2_irqs = 10,
Vivien Didelote606ca32017-03-11 16:12:55 -05005255 .atu_move_port_mask = 0xf,
Vivien Didelotf3645652017-03-30 17:37:07 -04005256 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005257 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005258 .tag_protocol = DSA_TAG_PROTO_EDSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005259 .ptp_support = true,
Vivien Didelotb3469dd2016-09-29 12:22:00 -04005260 .ops = &mv88e6352_ops,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005261 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005262 [MV88E6390] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005263 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005264 .family = MV88E6XXX_FAMILY_6390,
5265 .name = "Marvell 88E6390",
5266 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005267 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005268 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005269 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005270 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005271 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005272 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005273 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005274 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005275 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005276 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005277 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005278 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005279 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005280 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005281 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005282 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005283 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005284 .ops = &mv88e6390_ops,
5285 },
5286 [MV88E6390X] = {
Vivien Didelot107fcc12017-06-12 12:37:36 -04005287 .prod_num = MV88E6XXX_PORT_SWITCH_ID_PROD_6390X,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005288 .family = MV88E6XXX_FAMILY_6390,
5289 .name = "Marvell 88E6390X",
5290 .num_databases = 4096,
Andrew Lunnd9ea5622019-11-05 01:12:58 +01005291 .num_macs = 16384,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005292 .num_ports = 11, /* 10 + Z80 */
Heiner Kallweit95150f22019-03-02 10:06:05 +01005293 .num_internal_phys = 9,
Brandon Streiffa73ccd62018-02-14 01:07:46 +01005294 .num_gpio = 16,
Vivien Didelot931d1822017-05-01 14:05:27 -04005295 .max_vid = 8191,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005296 .port_base_addr = 0x0,
Andrew Lunn9255bac2018-05-05 20:58:22 +02005297 .phy_base_addr = 0x0,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005298 .global1_addr = 0x1b,
Vivien Didelot9069c132017-07-17 13:03:44 -04005299 .global2_addr = 0x1c,
Andrew Lunnb91e0552017-02-02 00:46:15 +01005300 .age_time_coeff = 3750,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005301 .g1_irqs = 9,
Vivien Didelotd6c5e6a2017-07-17 13:03:40 -04005302 .g2_irqs = 14,
Vivien Didelote606ca32017-03-11 16:12:55 -05005303 .atu_move_port_mask = 0x1f,
Vivien Didelotf3645652017-03-30 17:37:07 -04005304 .pvt = true,
Vivien Didelotb3e05aa2017-07-17 13:03:46 -04005305 .multi_chip = true,
Andrew Lunn443d5a12016-12-03 04:35:18 +01005306 .tag_protocol = DSA_TAG_PROTO_DSA,
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005307 .ptp_support = true,
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005308 .ops = &mv88e6390x_ops,
5309 },
Vivien Didelotf81ec902016-05-09 13:22:58 -04005310};
5311
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005312static const struct mv88e6xxx_info *mv88e6xxx_lookup_info(unsigned int prod_num)
Vivien Didelotb9b37712015-10-30 19:39:48 -04005313{
Vivien Didelota439c062016-04-17 13:23:58 -04005314 int i;
Vivien Didelotb9b37712015-10-30 19:39:48 -04005315
Vivien Didelot5f7c0362016-06-20 13:14:04 -04005316 for (i = 0; i < ARRAY_SIZE(mv88e6xxx_table); ++i)
5317 if (mv88e6xxx_table[i].prod_num == prod_num)
5318 return &mv88e6xxx_table[i];
Vivien Didelotb9b37712015-10-30 19:39:48 -04005319
Vivien Didelotb9b37712015-10-30 19:39:48 -04005320 return NULL;
5321}
5322
Vivien Didelotfad09c72016-06-21 12:28:20 -04005323static int mv88e6xxx_detect(struct mv88e6xxx_chip *chip)
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005324{
5325 const struct mv88e6xxx_info *info;
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005326 unsigned int prod_num, rev;
5327 u16 id;
5328 int err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005329
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005330 mv88e6xxx_reg_lock(chip);
Vivien Didelot107fcc12017-06-12 12:37:36 -04005331 err = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID, &id);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005332 mv88e6xxx_reg_unlock(chip);
Vivien Didelot8f6345b2016-07-20 18:18:36 -04005333 if (err)
5334 return err;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005335
Vivien Didelot107fcc12017-06-12 12:37:36 -04005336 prod_num = id & MV88E6XXX_PORT_SWITCH_ID_PROD_MASK;
5337 rev = id & MV88E6XXX_PORT_SWITCH_ID_REV_MASK;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005338
5339 info = mv88e6xxx_lookup_info(prod_num);
5340 if (!info)
5341 return -ENODEV;
5342
Vivien Didelotcaac8542016-06-20 13:14:09 -04005343 /* Update the compatible info with the probed one */
Vivien Didelotfad09c72016-06-21 12:28:20 -04005344 chip->info = info;
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005345
Vivien Didelotca070c12016-09-02 14:45:34 -04005346 err = mv88e6xxx_g2_require(chip);
5347 if (err)
5348 return err;
5349
Vivien Didelotfad09c72016-06-21 12:28:20 -04005350 dev_info(chip->dev, "switch 0x%x detected: %s, revision %u\n",
5351 chip->info->prod_num, chip->info->name, rev);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005352
5353 return 0;
5354}
5355
Vivien Didelotfad09c72016-06-21 12:28:20 -04005356static struct mv88e6xxx_chip *mv88e6xxx_alloc_chip(struct device *dev)
Vivien Didelot469d7292016-06-20 13:14:06 -04005357{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005358 struct mv88e6xxx_chip *chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005359
Vivien Didelotfad09c72016-06-21 12:28:20 -04005360 chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
5361 if (!chip)
Vivien Didelot469d7292016-06-20 13:14:06 -04005362 return NULL;
5363
Vivien Didelotfad09c72016-06-21 12:28:20 -04005364 chip->dev = dev;
Vivien Didelot469d7292016-06-20 13:14:06 -04005365
Vivien Didelotfad09c72016-06-21 12:28:20 -04005366 mutex_init(&chip->reg_lock);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005367 INIT_LIST_HEAD(&chip->mdios);
Vivien Didelotda7dc872019-09-07 16:00:49 -04005368 idr_init(&chip->policies);
Vivien Didelot469d7292016-06-20 13:14:06 -04005369
Vivien Didelotfad09c72016-06-21 12:28:20 -04005370 return chip;
Vivien Didelot469d7292016-06-20 13:14:06 -04005371}
5372
Florian Fainelli5ed4e3e2017-11-10 15:22:52 -08005373static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
Florian Fainelli4d776482020-01-07 21:06:05 -08005374 int port,
5375 enum dsa_tag_protocol m)
Andrew Lunn7b314362016-08-22 16:01:01 +02005376{
Vivien Didelot04bed142016-08-31 18:06:13 -04005377 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn2bbb33b2016-08-22 16:01:02 +02005378
Andrew Lunn443d5a12016-12-03 04:35:18 +01005379 return chip->info->tag_protocol;
Andrew Lunn7b314362016-08-22 16:01:01 +02005380}
5381
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005382static int mv88e6xxx_port_mdb_prepare(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005383 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005384{
5385 /* We don't need any dynamic resource from the kernel (yet),
5386 * so skip the prepare phase.
5387 */
5388
5389 return 0;
5390}
5391
5392static void mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
Vivien Didelot3709aad2017-11-30 11:23:58 -05005393 const struct switchdev_obj_port_mdb *mdb)
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005394{
Vivien Didelot04bed142016-08-31 18:06:13 -04005395 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005396
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005397 mv88e6xxx_reg_lock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005398 if (mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
Vivien Didelot27c0e602017-06-15 12:14:01 -04005399 MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC))
Vivien Didelot774439e52017-06-08 18:34:08 -04005400 dev_err(ds->dev, "p%d: failed to load multicast MAC address\n",
5401 port);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005402 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005403}
5404
5405static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
5406 const struct switchdev_obj_port_mdb *mdb)
5407{
Vivien Didelot04bed142016-08-31 18:06:13 -04005408 struct mv88e6xxx_chip *chip = ds->priv;
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005409 int err;
5410
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005411 mv88e6xxx_reg_lock(chip);
Vivien Didelotd8291a92019-09-07 16:00:47 -04005412 err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid, 0);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005413 mv88e6xxx_reg_unlock(chip);
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005414
5415 return err;
5416}
5417
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005418static int mv88e6xxx_port_mirror_add(struct dsa_switch *ds, int port,
5419 struct dsa_mall_mirror_tc_entry *mirror,
5420 bool ingress)
5421{
5422 enum mv88e6xxx_egress_direction direction = ingress ?
5423 MV88E6XXX_EGRESS_DIR_INGRESS :
5424 MV88E6XXX_EGRESS_DIR_EGRESS;
5425 struct mv88e6xxx_chip *chip = ds->priv;
5426 bool other_mirrors = false;
5427 int i;
5428 int err;
5429
5430 if (!chip->info->ops->set_egress_port)
5431 return -EOPNOTSUPP;
5432
5433 mutex_lock(&chip->reg_lock);
5434 if ((ingress ? chip->ingress_dest_port : chip->egress_dest_port) !=
5435 mirror->to_local_port) {
5436 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5437 other_mirrors |= ingress ?
5438 chip->ports[i].mirror_ingress :
5439 chip->ports[i].mirror_egress;
5440
5441 /* Can't change egress port when other mirror is active */
5442 if (other_mirrors) {
5443 err = -EBUSY;
5444 goto out;
5445 }
5446
5447 err = chip->info->ops->set_egress_port(chip,
5448 direction,
5449 mirror->to_local_port);
5450 if (err)
5451 goto out;
5452 }
5453
5454 err = mv88e6xxx_port_set_mirror(chip, port, direction, true);
5455out:
5456 mutex_unlock(&chip->reg_lock);
5457
5458 return err;
5459}
5460
5461static void mv88e6xxx_port_mirror_del(struct dsa_switch *ds, int port,
5462 struct dsa_mall_mirror_tc_entry *mirror)
5463{
5464 enum mv88e6xxx_egress_direction direction = mirror->ingress ?
5465 MV88E6XXX_EGRESS_DIR_INGRESS :
5466 MV88E6XXX_EGRESS_DIR_EGRESS;
5467 struct mv88e6xxx_chip *chip = ds->priv;
5468 bool other_mirrors = false;
5469 int i;
5470
5471 mutex_lock(&chip->reg_lock);
5472 if (mv88e6xxx_port_set_mirror(chip, port, direction, false))
5473 dev_err(ds->dev, "p%d: failed to disable mirroring\n", port);
5474
5475 for (i = 0; i < mv88e6xxx_num_ports(chip); i++)
5476 other_mirrors |= mirror->ingress ?
5477 chip->ports[i].mirror_ingress :
5478 chip->ports[i].mirror_egress;
5479
5480 /* Reset egress port when no other mirror is active */
5481 if (!other_mirrors) {
5482 if (chip->info->ops->set_egress_port(chip,
5483 direction,
5484 dsa_upstream_port(ds,
Colin Ian King4e4637b2019-11-12 13:05:23 +00005485 port)))
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005486 dev_err(ds->dev, "failed to set egress port\n");
5487 }
5488
5489 mutex_unlock(&chip->reg_lock);
5490}
5491
Russell King4f859012019-02-20 15:35:05 -08005492static int mv88e6xxx_port_egress_floods(struct dsa_switch *ds, int port,
5493 bool unicast, bool multicast)
5494{
5495 struct mv88e6xxx_chip *chip = ds->priv;
5496 int err = -EOPNOTSUPP;
5497
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005498 mv88e6xxx_reg_lock(chip);
Russell King4f859012019-02-20 15:35:05 -08005499 if (chip->info->ops->port_set_egress_floods)
5500 err = chip->info->ops->port_set_egress_floods(chip, port,
5501 unicast,
5502 multicast);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005503 mv88e6xxx_reg_unlock(chip);
Russell King4f859012019-02-20 15:35:05 -08005504
5505 return err;
5506}
5507
Florian Fainellia82f67a2017-01-08 14:52:08 -08005508static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
Andrew Lunn7b314362016-08-22 16:01:01 +02005509 .get_tag_protocol = mv88e6xxx_get_tag_protocol,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005510 .setup = mv88e6xxx_setup,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005511 .teardown = mv88e6xxx_teardown,
Russell Kingc9a23562018-05-10 13:17:35 -07005512 .phylink_validate = mv88e6xxx_validate,
Russell Kinga5a68582020-03-14 10:15:43 +00005513 .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state,
Russell Kingc9a23562018-05-10 13:17:35 -07005514 .phylink_mac_config = mv88e6xxx_mac_config,
Russell Kinga5a68582020-03-14 10:15:43 +00005515 .phylink_mac_an_restart = mv88e6xxx_serdes_pcs_an_restart,
Russell Kingc9a23562018-05-10 13:17:35 -07005516 .phylink_mac_link_down = mv88e6xxx_mac_link_down,
5517 .phylink_mac_link_up = mv88e6xxx_mac_link_up,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005518 .get_strings = mv88e6xxx_get_strings,
5519 .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
5520 .get_sset_count = mv88e6xxx_get_sset_count,
Andrew Lunn04aca992017-05-26 01:03:24 +02005521 .port_enable = mv88e6xxx_port_enable,
5522 .port_disable = mv88e6xxx_port_disable,
Vivien Didelot08f50062017-08-01 16:32:41 -04005523 .get_mac_eee = mv88e6xxx_get_mac_eee,
5524 .set_mac_eee = mv88e6xxx_set_mac_eee,
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005525 .get_eeprom_len = mv88e6xxx_get_eeprom_len,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005526 .get_eeprom = mv88e6xxx_get_eeprom,
5527 .set_eeprom = mv88e6xxx_set_eeprom,
5528 .get_regs_len = mv88e6xxx_get_regs_len,
5529 .get_regs = mv88e6xxx_get_regs,
Vivien Didelotda7dc872019-09-07 16:00:49 -04005530 .get_rxnfc = mv88e6xxx_get_rxnfc,
5531 .set_rxnfc = mv88e6xxx_set_rxnfc,
Vivien Didelot2cfcd962016-07-18 20:45:40 -04005532 .set_ageing_time = mv88e6xxx_set_ageing_time,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005533 .port_bridge_join = mv88e6xxx_port_bridge_join,
5534 .port_bridge_leave = mv88e6xxx_port_bridge_leave,
Russell King4f859012019-02-20 15:35:05 -08005535 .port_egress_floods = mv88e6xxx_port_egress_floods,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005536 .port_stp_state_set = mv88e6xxx_port_stp_state_set,
Vivien Didelot749efcb2016-09-22 16:49:24 -04005537 .port_fast_age = mv88e6xxx_port_fast_age,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005538 .port_vlan_filtering = mv88e6xxx_port_vlan_filtering,
5539 .port_vlan_prepare = mv88e6xxx_port_vlan_prepare,
5540 .port_vlan_add = mv88e6xxx_port_vlan_add,
5541 .port_vlan_del = mv88e6xxx_port_vlan_del,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005542 .port_fdb_add = mv88e6xxx_port_fdb_add,
5543 .port_fdb_del = mv88e6xxx_port_fdb_del,
5544 .port_fdb_dump = mv88e6xxx_port_fdb_dump,
Vivien Didelot7df8fbd2016-08-31 11:50:05 -04005545 .port_mdb_prepare = mv88e6xxx_port_mdb_prepare,
5546 .port_mdb_add = mv88e6xxx_port_mdb_add,
5547 .port_mdb_del = mv88e6xxx_port_mdb_del,
Iwan R Timmerf0942e02019-11-07 22:11:14 +01005548 .port_mirror_add = mv88e6xxx_port_mirror_add,
5549 .port_mirror_del = mv88e6xxx_port_mirror_del,
Vivien Didelotaec5ac82017-03-30 17:37:15 -04005550 .crosschip_bridge_join = mv88e6xxx_crosschip_bridge_join,
5551 .crosschip_bridge_leave = mv88e6xxx_crosschip_bridge_leave,
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005552 .port_hwtstamp_set = mv88e6xxx_port_hwtstamp_set,
5553 .port_hwtstamp_get = mv88e6xxx_port_hwtstamp_get,
5554 .port_txtstamp = mv88e6xxx_port_txtstamp,
5555 .port_rxtstamp = mv88e6xxx_port_rxtstamp,
5556 .get_ts_info = mv88e6xxx_get_ts_info,
Andrew Lunn23e8b472019-10-25 01:03:52 +02005557 .devlink_param_get = mv88e6xxx_devlink_param_get,
5558 .devlink_param_set = mv88e6xxx_devlink_param_set,
Vivien Didelotf81ec902016-05-09 13:22:58 -04005559};
5560
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005561static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005562{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005563 struct device *dev = chip->dev;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005564 struct dsa_switch *ds;
5565
Vivien Didelot7e99e342019-10-21 16:51:30 -04005566 ds = devm_kzalloc(dev, sizeof(*ds), GFP_KERNEL);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005567 if (!ds)
5568 return -ENOMEM;
5569
Vivien Didelot7e99e342019-10-21 16:51:30 -04005570 ds->dev = dev;
5571 ds->num_ports = mv88e6xxx_num_ports(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005572 ds->priv = chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005573 ds->dev = dev;
Vivien Didelot9d490b42016-08-23 12:38:56 -04005574 ds->ops = &mv88e6xxx_switch_ops;
Vivien Didelot9ff74f22017-03-15 15:53:50 -04005575 ds->ageing_time_min = chip->info->age_time_coeff;
5576 ds->ageing_time_max = chip->info->age_time_coeff * U8_MAX;
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005577
5578 dev_set_drvdata(dev, ds);
5579
Vivien Didelot23c9ee42017-05-26 18:12:51 -04005580 return dsa_register_switch(ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005581}
5582
Vivien Didelotfad09c72016-06-21 12:28:20 -04005583static void mv88e6xxx_unregister_switch(struct mv88e6xxx_chip *chip)
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005584{
Vivien Didelotfad09c72016-06-21 12:28:20 -04005585 dsa_unregister_switch(chip->ds);
Vivien Didelotb7e66a52016-06-20 13:14:02 -04005586}
5587
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005588static const void *pdata_device_get_match_data(struct device *dev)
5589{
5590 const struct of_device_id *matches = dev->driver->of_match_table;
5591 const struct dsa_mv88e6xxx_pdata *pdata = dev->platform_data;
5592
5593 for (; matches->name[0] || matches->type[0] || matches->compatible[0];
5594 matches++) {
5595 if (!strcmp(pdata->compatible, matches->compatible))
5596 return matches->data;
5597 }
5598 return NULL;
5599}
5600
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005601/* There is no suspend to RAM support at DSA level yet, the switch configuration
5602 * would be lost after a power cycle so prevent it to be suspended.
5603 */
5604static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
5605{
5606 return -EOPNOTSUPP;
5607}
5608
5609static int __maybe_unused mv88e6xxx_resume(struct device *dev)
5610{
5611 return 0;
5612}
5613
5614static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
5615
Vivien Didelot57d32312016-06-20 13:13:58 -04005616static int mv88e6xxx_probe(struct mdio_device *mdiodev)
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005617{
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005618 struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
David S. Miller7ddae242018-05-20 19:04:24 -04005619 const struct mv88e6xxx_info *compat_info = NULL;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005620 struct device *dev = &mdiodev->dev;
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005621 struct device_node *np = dev->of_node;
Vivien Didelotfad09c72016-06-21 12:28:20 -04005622 struct mv88e6xxx_chip *chip;
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005623 int port;
Andrew Lunn52638f72016-05-10 23:27:22 +02005624 int err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005625
Andrew Lunn7bb8c992018-05-31 00:15:42 +02005626 if (!np && !pdata)
5627 return -EINVAL;
5628
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005629 if (np)
5630 compat_info = of_device_get_match_data(dev);
5631
5632 if (pdata) {
5633 compat_info = pdata_device_get_match_data(dev);
5634
5635 if (!pdata->netdev)
5636 return -EINVAL;
5637
5638 for (port = 0; port < DSA_MAX_PORTS; port++) {
5639 if (!(pdata->enabled_ports & (1 << port)))
5640 continue;
5641 if (strcmp(pdata->cd.port_names[port], "cpu"))
5642 continue;
5643 pdata->cd.netdev[port] = &pdata->netdev->dev;
5644 break;
5645 }
5646 }
5647
Vivien Didelotcaac8542016-06-20 13:14:09 -04005648 if (!compat_info)
5649 return -EINVAL;
5650
Vivien Didelotfad09c72016-06-21 12:28:20 -04005651 chip = mv88e6xxx_alloc_chip(dev);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005652 if (!chip) {
5653 err = -ENOMEM;
5654 goto out;
5655 }
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005656
Vivien Didelotfad09c72016-06-21 12:28:20 -04005657 chip->info = compat_info;
Vivien Didelotcaac8542016-06-20 13:14:09 -04005658
Vivien Didelotfad09c72016-06-21 12:28:20 -04005659 err = mv88e6xxx_smi_init(chip, mdiodev->bus, mdiodev->addr);
Vivien Didelot4a70c4a2016-06-20 13:14:07 -04005660 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005661 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005662
Andrew Lunnb4308f02016-11-21 23:26:55 +01005663 chip->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005664 if (IS_ERR(chip->reset)) {
5665 err = PTR_ERR(chip->reset);
5666 goto out;
5667 }
Baruch Siach7b75e492019-06-27 21:17:39 +03005668 if (chip->reset)
5669 usleep_range(1000, 2000);
Andrew Lunnb4308f02016-11-21 23:26:55 +01005670
Vivien Didelotfad09c72016-06-21 12:28:20 -04005671 err = mv88e6xxx_detect(chip);
Vivien Didelotbc46a3d2016-06-20 13:14:08 -04005672 if (err)
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005673 goto out;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005674
Vivien Didelote57e5e72016-08-15 17:19:00 -04005675 mv88e6xxx_phy_init(chip);
5676
Andrew Lunn00baabe2018-05-19 22:31:35 +02005677 if (chip->info->ops->get_eeprom) {
5678 if (np)
5679 of_property_read_u32(np, "eeprom-length",
5680 &chip->eeprom_len);
5681 else
5682 chip->eeprom_len = pdata->eeprom_len;
5683 }
Andrew Lunnf8cd8752016-05-10 23:27:25 +02005684
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005685 mv88e6xxx_reg_lock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005686 err = mv88e6xxx_switch_reset(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005687 mv88e6xxx_reg_unlock(chip);
Andrew Lunnb516d452016-06-04 21:17:06 +02005688 if (err)
Andrew Lunndc30c352016-10-16 19:56:49 +02005689 goto out;
Andrew Lunnb516d452016-06-04 21:17:06 +02005690
Andrew Lunna27415d2019-05-01 00:10:50 +02005691 if (np) {
5692 chip->irq = of_irq_get(np, 0);
5693 if (chip->irq == -EPROBE_DEFER) {
5694 err = chip->irq;
5695 goto out;
5696 }
Andrew Lunn83c0afa2016-06-04 21:17:07 +02005697 }
5698
Andrew Lunna27415d2019-05-01 00:10:50 +02005699 if (pdata)
5700 chip->irq = pdata->irq;
5701
Andrew Lunn294d7112018-02-22 22:58:32 +01005702 /* Has to be performed before the MDIO bus is created, because
Uwe Kleine-Königa7087672018-03-20 10:44:41 +01005703 * the PHYs will link their interrupts to these interrupt
Andrew Lunn294d7112018-02-22 22:58:32 +01005704 * controllers
5705 */
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005706 mv88e6xxx_reg_lock(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005707 if (chip->irq > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005708 err = mv88e6xxx_g1_irq_setup(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005709 else
5710 err = mv88e6xxx_irq_poll_setup(chip);
Rasmus Villemoesc9acece2019-06-20 13:50:42 +00005711 mv88e6xxx_reg_unlock(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005712
Andrew Lunn294d7112018-02-22 22:58:32 +01005713 if (err)
5714 goto out;
5715
5716 if (chip->info->g2_irqs > 0) {
5717 err = mv88e6xxx_g2_irq_setup(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005718 if (err)
Andrew Lunn294d7112018-02-22 22:58:32 +01005719 goto out_g1_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005720 }
5721
Andrew Lunn294d7112018-02-22 22:58:32 +01005722 err = mv88e6xxx_g1_atu_prob_irq_setup(chip);
5723 if (err)
5724 goto out_g2_irq;
5725
5726 err = mv88e6xxx_g1_vtu_prob_irq_setup(chip);
5727 if (err)
5728 goto out_g1_atu_prob_irq;
5729
Andrew Lunna3c53be52017-01-24 14:53:50 +01005730 err = mv88e6xxx_mdios_register(chip, np);
Andrew Lunndc30c352016-10-16 19:56:49 +02005731 if (err)
Andrew Lunn62eb1162018-01-14 02:32:45 +01005732 goto out_g1_vtu_prob_irq;
Andrew Lunndc30c352016-10-16 19:56:49 +02005733
Florian Fainelli55ed0ce2017-01-26 10:45:51 -08005734 err = mv88e6xxx_register_switch(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005735 if (err)
5736 goto out_mdio;
5737
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005738 return 0;
Andrew Lunndc30c352016-10-16 19:56:49 +02005739
5740out_mdio:
Andrew Lunna3c53be52017-01-24 14:53:50 +01005741 mv88e6xxx_mdios_unregister(chip);
Andrew Lunn62eb1162018-01-14 02:32:45 +01005742out_g1_vtu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005743 mv88e6xxx_g1_vtu_prob_irq_free(chip);
Andrew Lunn09776442018-01-14 02:32:44 +01005744out_g1_atu_prob_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005745 mv88e6xxx_g1_atu_prob_irq_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005746out_g2_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005747 if (chip->info->g2_irqs > 0)
Andrew Lunndc30c352016-10-16 19:56:49 +02005748 mv88e6xxx_g2_irq_free(chip);
5749out_g1_irq:
Andrew Lunn294d7112018-02-22 22:58:32 +01005750 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005751 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn294d7112018-02-22 22:58:32 +01005752 else
5753 mv88e6xxx_irq_poll_free(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005754out:
Andrew Lunn877b7cb2018-05-19 22:31:34 +02005755 if (pdata)
5756 dev_put(pdata->netdev);
5757
Andrew Lunndc30c352016-10-16 19:56:49 +02005758 return err;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005759}
5760
5761static void mv88e6xxx_remove(struct mdio_device *mdiodev)
5762{
5763 struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
Vivien Didelot04bed142016-08-31 18:06:13 -04005764 struct mv88e6xxx_chip *chip = ds->priv;
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005765
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005766 if (chip->info->ptp_support) {
5767 mv88e6xxx_hwtstamp_free(chip);
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005768 mv88e6xxx_ptp_free(chip);
Brandon Streiffc6fe0ad2018-02-14 01:07:50 +01005769 }
Brandon Streiff2fa8d3a2018-02-14 01:07:45 +01005770
Andrew Lunn930188c2016-08-22 16:01:03 +02005771 mv88e6xxx_phy_destroy(chip);
Vivien Didelotfad09c72016-06-21 12:28:20 -04005772 mv88e6xxx_unregister_switch(chip);
Andrew Lunna3c53be52017-01-24 14:53:50 +01005773 mv88e6xxx_mdios_unregister(chip);
Andrew Lunndc30c352016-10-16 19:56:49 +02005774
Andrew Lunn76f38f12018-03-17 20:21:09 +01005775 mv88e6xxx_g1_vtu_prob_irq_free(chip);
5776 mv88e6xxx_g1_atu_prob_irq_free(chip);
5777
5778 if (chip->info->g2_irqs > 0)
5779 mv88e6xxx_g2_irq_free(chip);
5780
Andrew Lunn76f38f12018-03-17 20:21:09 +01005781 if (chip->irq > 0)
Andrew Lunn467126442016-11-20 20:14:15 +01005782 mv88e6xxx_g1_irq_free(chip);
Andrew Lunn76f38f12018-03-17 20:21:09 +01005783 else
5784 mv88e6xxx_irq_poll_free(chip);
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005785}
5786
5787static const struct of_device_id mv88e6xxx_of_match[] = {
Vivien Didelotcaac8542016-06-20 13:14:09 -04005788 {
5789 .compatible = "marvell,mv88e6085",
5790 .data = &mv88e6xxx_table[MV88E6085],
5791 },
Andrew Lunn1a3b39e2016-11-21 23:26:57 +01005792 {
5793 .compatible = "marvell,mv88e6190",
5794 .data = &mv88e6xxx_table[MV88E6190],
5795 },
Rasmus Villemoes1f718362019-06-04 07:34:32 +00005796 {
5797 .compatible = "marvell,mv88e6250",
5798 .data = &mv88e6xxx_table[MV88E6250],
5799 },
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005800 { /* sentinel */ },
5801};
5802
5803MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
5804
5805static struct mdio_driver mv88e6xxx_driver = {
5806 .probe = mv88e6xxx_probe,
5807 .remove = mv88e6xxx_remove,
5808 .mdiodrv.driver = {
5809 .name = "mv88e6085",
5810 .of_match_table = mv88e6xxx_of_match,
Miquel Raynalbcd3d9d2019-02-05 12:07:28 +01005811 .pm = &mv88e6xxx_pm_ops,
Andrew Lunn14c7b3c2016-05-10 23:27:21 +02005812 },
5813};
5814
Andrew Lunn7324d502019-04-27 19:19:10 +02005815mdio_module_driver(mv88e6xxx_driver);
Ben Hutchings3d825ed2011-11-25 14:37:16 +00005816
5817MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
5818MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips");
5819MODULE_LICENSE("GPL");